Chilkat Online Tools

DescribeActivities autoit Example

Amazon WorkDocs

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

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.SecretKey = "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.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "workdocs"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://workdocs.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("workdocs.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","DescribeActivities")

$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestNoBodySb("GET","/api/v1/activities",$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; 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

Local $sCommentId
Local $sCommentStatus
Local $iCreatedTimestamp
Local $sEmailAddress
Local $sGivenName
Local $sId
Local $sLocale
Local $iModifiedTimestamp
Local $sOrganizationId
Local $sRecycleBinFolderId
Local $sRootFolderId
Local $sStatus
Local $iStorageAllocatedInBytes
Local $sStorageType
Local $iStorageUtilizedInBytes
Local $sSurname
Local $sTimeZoneId
Local $sV_Type
Local $sUsername
Local $iCommentMetadataCreatedTimestamp
Local $sRecipientId
Local $sInitiatorEmailAddress
Local $sInitiatorGivenName
Local $sInitiatorId
Local $sInitiatorSurname
Local $sInitiatorUsername
Local $iIsIndirectActivity
Local $sOriginalParentId
Local $sName
Local $sOriginalName
Local $sOwnerEmailAddress
Local $sOwnerGivenName
Local $sOwnerId
Local $sOwnerSurname
Local $sOwnerUsername
Local $sParentId
Local $sOriginalParentType
Local $sVersionId
Local $sResourceMetadataId
Local $sResourceMetadataName
Local $sResourceMetadataOriginalName
Local $sResourceMetadataParentId
Local $sResourceMetadataType
Local $sResourceMetadataVersionId
Local $iTimeStamp
Local $iJ
Local $iCount_j

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

; 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"
;     }
;   ]
; }