Chilkat Online Tools

DescribeActivities DataFlex Example

Amazon WorkDocs

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vAuthAws
    Handle hoAuthAws
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Integer iRespStatusCode
    Handle hoJResp
    String sCommentId
    String sCommentStatus
    Integer iCreatedTimestamp
    String sEmailAddress
    String sGivenName
    String sId
    String sLocale
    Integer iModifiedTimestamp
    String sOrganizationId
    String sRecycleBinFolderId
    String sRootFolderId
    String sStatus
    Integer iStorageAllocatedInBytes
    String sStorageType
    Integer iStorageUtilizedInBytes
    String sSurname
    String sTimeZoneId
    String sV_Type
    String sUsername
    Integer iCommentMetadataCreatedTimestamp
    String sRecipientId
    String sInitiatorEmailAddress
    String sInitiatorGivenName
    String sInitiatorId
    String sInitiatorSurname
    String sInitiatorUsername
    Integer iIsIndirectActivity
    String sOriginalParentId
    String sName
    String sOriginalName
    String sOwnerEmailAddress
    String sOwnerGivenName
    String sOwnerId
    String sOwnerSurname
    String sOwnerUsername
    String sParentId
    String sOriginalParentType
    String sVersionId
    String sResourceMetadataId
    String sResourceMetadataName
    String sResourceMetadataOriginalName
    String sResourceMetadataParentId
    String sResourceMetadataType
    String sResourceMetadataVersionId
    Integer iTimeStamp
    Integer j
    Integer iCount_j
    String sMarker
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get Create (RefClass(cComChilkatAuthAws)) To hoAuthAws
    If (Not(IsComObjectCreated(hoAuthAws))) Begin
        Send CreateComObject of hoAuthAws
    End
    Set ComAccessKey Of hoAuthAws To "AWS_ACCESS_KEY"
    Set ComSecretKey Of hoAuthAws To "AWS_SECRET_KEY"

    // Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
    Set ComRegion Of hoAuthAws To "us-west-2"
    Set ComServiceName Of hoAuthAws To "workdocs"
    // SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
    Get pvComObject of hoAuthAws to vAuthAws
    Get ComSetAuthAws Of hoRest vAuthAws To iSuccess

    // URL: https://workdocs.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    Get ComConnect Of hoRest "workdocs.us-west-2.amazonaws.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComAddHeader Of hoRest "Content-Type" "application/x-amz-json-1.1" To iSuccess
    Get ComAddHeader Of hoRest "X-Amz-Target" "DescribeActivities" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/api/v1/activities" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iRespStatusCode
    Showln "response status code = " iRespStatusCode
    If (iRespStatusCode <> 200) Begin
        Showln "Response Header:"
        Get ComResponseHeader Of hoRest To sTemp1
        Showln sTemp1
        Showln "Response Body:"
        Get ComGetAsString Of hoSbResponseBody To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess

    // The following code parses the JSON response.
    // A sample JSON response is shown below the sample code.

    // Use this online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    Get ComStringOf Of hoJResp "Marker" To sMarker
    Move 0 To i
    Get ComSizeOfArray Of hoJResp "UserActivities" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.CommentId" To sCommentId
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.CommentStatus" To sCommentStatus
        Get ComIntOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.CreatedTimestamp" To iCreatedTimestamp
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.EmailAddress" To sEmailAddress
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.GivenName" To sGivenName
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Id" To sId
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Locale" To sLocale
        Get ComIntOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.ModifiedTimestamp" To iModifiedTimestamp
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.OrganizationId" To sOrganizationId
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.RecycleBinFolderId" To sRecycleBinFolderId
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.RootFolderId" To sRootFolderId
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Status" To sStatus
        Get ComIntOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageAllocatedInBytes" To iStorageAllocatedInBytes
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageType" To sStorageType
        Get ComIntOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Storage.StorageUtilizedInBytes" To iStorageUtilizedInBytes
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Surname" To sSurname
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.TimeZoneId" To sTimeZoneId
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Type" To sV_Type
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.Contributor.Username" To sUsername
        Get ComIntOf Of hoJResp "UserActivities[i].CommentMetadata.CreatedTimestamp" To iCommentMetadataCreatedTimestamp
        Get ComStringOf Of hoJResp "UserActivities[i].CommentMetadata.RecipientId" To sRecipientId
        Get ComStringOf Of hoJResp "UserActivities[i].Initiator.EmailAddress" To sInitiatorEmailAddress
        Get ComStringOf Of hoJResp "UserActivities[i].Initiator.GivenName" To sInitiatorGivenName
        Get ComStringOf Of hoJResp "UserActivities[i].Initiator.Id" To sInitiatorId
        Get ComStringOf Of hoJResp "UserActivities[i].Initiator.Surname" To sInitiatorSurname
        Get ComStringOf Of hoJResp "UserActivities[i].Initiator.Username" To sInitiatorUsername
        Get ComIntOf Of hoJResp "UserActivities[i].IsIndirectActivity" To iIsIndirectActivity
        Get ComStringOf Of hoJResp "UserActivities[i].OrganizationId" To sOrganizationId
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Id" To sOriginalParentId
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Name" To sName
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.OriginalName" To sOriginalName
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Owner.EmailAddress" To sOwnerEmailAddress
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Owner.GivenName" To sOwnerGivenName
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Owner.Id" To sOwnerId
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Owner.Surname" To sOwnerSurname
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Owner.Username" To sOwnerUsername
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.ParentId" To sParentId
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.Type" To sOriginalParentType
        Get ComStringOf Of hoJResp "UserActivities[i].OriginalParent.VersionId" To sVersionId
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Id" To sResourceMetadataId
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Name" To sResourceMetadataName
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.OriginalName" To sResourceMetadataOriginalName
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Owner.EmailAddress" To sOwnerEmailAddress
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Owner.GivenName" To sOwnerGivenName
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Owner.Id" To sOwnerId
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Owner.Surname" To sOwnerSurname
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Owner.Username" To sOwnerUsername
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.ParentId" To sResourceMetadataParentId
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.Type" To sResourceMetadataType
        Get ComStringOf Of hoJResp "UserActivities[i].ResourceMetadata.VersionId" To sResourceMetadataVersionId
        Get ComIntOf Of hoJResp "UserActivities[i].TimeStamp" To iTimeStamp
        Get ComStringOf Of hoJResp "UserActivities[i].Type" To sV_Type
        Move 0 To j
        Get ComSizeOfArray Of hoJResp "UserActivities[i].Participants.Groups" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Groups[j].Id" To sId
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Groups[j].Name" To sName
            Move (j + 1) To j
        Loop

        Move 0 To j
        Get ComSizeOfArray Of hoJResp "UserActivities[i].Participants.Users" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJResp To j
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Users[j].EmailAddress" To sEmailAddress
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Users[j].GivenName" To sGivenName
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Users[j].Id" To sId
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Users[j].Surname" To sSurname
            Get ComStringOf Of hoJResp "UserActivities[i].Participants.Users[j].Username" To sUsername
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    // A sample JSON response body parsed by the above code:

    // {
    //   "Marker": "string",
    //   "UserActivities": [
    //     {
    //       "CommentMetadata": {
    //         "CommentId": "string",
    //         "CommentStatus": "string",
    //         "Contributor": {
    //           "CreatedTimestamp": number,
    //           "EmailAddress": "string",
    //           "GivenName": "string",
    //           "Id": "string",
    //           "Locale": "string",
    //           "ModifiedTimestamp": number,
    //           "OrganizationId": "string",
    //           "RecycleBinFolderId": "string",
    //           "RootFolderId": "string",
    //           "Status": "string",
    //           "Storage": {
    //             "StorageRule": {
    //               "StorageAllocatedInBytes": number,
    //               "StorageType": "string"
    //             },
    //             "StorageUtilizedInBytes": number
    //           },
    //           "Surname": "string",
    //           "TimeZoneId": "string",
    //           "Type": "string",
    //           "Username": "string"
    //         },
    //         "CreatedTimestamp": number,
    //         "RecipientId": "string"
    //       },
    //       "Initiator": {
    //         "EmailAddress": "string",
    //         "GivenName": "string",
    //         "Id": "string",
    //         "Surname": "string",
    //         "Username": "string"
    //       },
    //       "IsIndirectActivity": boolean,
    //       "OrganizationId": "string",
    //       "OriginalParent": {
    //         "Id": "string",
    //         "Name": "string",
    //         "OriginalName": "string",
    //         "Owner": {
    //           "EmailAddress": "string",
    //           "GivenName": "string",
    //           "Id": "string",
    //           "Surname": "string",
    //           "Username": "string"
    //         },
    //         "ParentId": "string",
    //         "Type": "string",
    //         "VersionId": "string"
    //       },
    //       "Participants": {
    //         "Groups": [
    //           {
    //             "Id": "string",
    //             "Name": "string"
    //           }
    //         ],
    //         "Users": [
    //           {
    //             "EmailAddress": "string",
    //             "GivenName": "string",
    //             "Id": "string",
    //             "Surname": "string",
    //             "Username": "string"
    //           }
    //         ]
    //       },
    //       "ResourceMetadata": {
    //         "Id": "string",
    //         "Name": "string",
    //         "OriginalName": "string",
    //         "Owner": {
    //           "EmailAddress": "string",
    //           "GivenName": "string",
    //           "Id": "string",
    //           "Surname": "string",
    //           "Username": "string"
    //         },
    //         "ParentId": "string",
    //         "Type": "string",
    //         "VersionId": "string"
    //       },
    //       "TimeStamp": number,
    //       "Type": "string"
    //     }
    //   ]
    // }


End_Procedure