Chilkat Online Tools

DescribeActivities Foxpro Example

Amazon WorkDocs

LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcCommentId
LOCAL lcCommentStatus
LOCAL lnCreatedTimestamp
LOCAL lcEmailAddress
LOCAL lcGivenName
LOCAL lcId
LOCAL lcLocale
LOCAL lnModifiedTimestamp
LOCAL lcOrganizationId
LOCAL lcRecycleBinFolderId
LOCAL lcRootFolderId
LOCAL lcStatus
LOCAL lnStorageAllocatedInBytes
LOCAL lcStorageType
LOCAL lnStorageUtilizedInBytes
LOCAL lcSurname
LOCAL lcTimeZoneId
LOCAL lcV_Type
LOCAL lcUsername
LOCAL lnCommentMetadataCreatedTimestamp
LOCAL lcRecipientId
LOCAL lcInitiatorEmailAddress
LOCAL lcInitiatorGivenName
LOCAL lcInitiatorId
LOCAL lcInitiatorSurname
LOCAL lcInitiatorUsername
LOCAL lnIsIndirectActivity
LOCAL lcOriginalParentId
LOCAL lcName
LOCAL lcOriginalName
LOCAL lcOwnerEmailAddress
LOCAL lcOwnerGivenName
LOCAL lcOwnerId
LOCAL lcOwnerSurname
LOCAL lcOwnerUsername
LOCAL lcParentId
LOCAL lcOriginalParentType
LOCAL lcVersionId
LOCAL lcResourceMetadataId
LOCAL lcResourceMetadataName
LOCAL lcResourceMetadataOriginalName
LOCAL lcResourceMetadataParentId
LOCAL lcResourceMetadataType
LOCAL lcResourceMetadataVersionId
LOCAL lnTimeStamp
LOCAL j
LOCAL lnCount_j
LOCAL lcMarker
LOCAL i
LOCAL lnCount_i

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

loRest = CreateObject('Chilkat_9_5_0.Rest')

loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "workdocs"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)

* URL: https://workdocs.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("workdocs.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    CANCEL
ENDIF

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

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/api/v1/activities",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loAuthAws
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)

* 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

lcMarker = loJResp.StringOf("Marker")
i = 0
lnCount_i = loJResp.SizeOfArray("UserActivities")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcCommentId = loJResp.StringOf("UserActivities[i].CommentMetadata.CommentId")
    lcCommentStatus = loJResp.StringOf("UserActivities[i].CommentMetadata.CommentStatus")
    lnCreatedTimestamp = loJResp.IntOf("UserActivities[i].CommentMetadata.Contributor.CreatedTimestamp")
    lcEmailAddress = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.EmailAddress")
    lcGivenName = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.GivenName")
    lcId = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Id")
    lcLocale = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Locale")
    lnModifiedTimestamp = loJResp.IntOf("UserActivities[i].CommentMetadata.Contributor.ModifiedTimestamp")
    lcOrganizationId = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.OrganizationId")
    lcRecycleBinFolderId = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.RecycleBinFolderId")
    lcRootFolderId = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.RootFolderId")
    lcStatus = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Status")
    lnStorageAllocatedInBytes = loJResp.IntOf("UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageAllocatedInBytes")
    lcStorageType = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageType")
    lnStorageUtilizedInBytes = loJResp.IntOf("UserActivities[i].CommentMetadata.Contributor.Storage.StorageUtilizedInBytes")
    lcSurname = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Surname")
    lcTimeZoneId = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.TimeZoneId")
    lcV_Type = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Type")
    lcUsername = loJResp.StringOf("UserActivities[i].CommentMetadata.Contributor.Username")
    lnCommentMetadataCreatedTimestamp = loJResp.IntOf("UserActivities[i].CommentMetadata.CreatedTimestamp")
    lcRecipientId = loJResp.StringOf("UserActivities[i].CommentMetadata.RecipientId")
    lcInitiatorEmailAddress = loJResp.StringOf("UserActivities[i].Initiator.EmailAddress")
    lcInitiatorGivenName = loJResp.StringOf("UserActivities[i].Initiator.GivenName")
    lcInitiatorId = loJResp.StringOf("UserActivities[i].Initiator.Id")
    lcInitiatorSurname = loJResp.StringOf("UserActivities[i].Initiator.Surname")
    lcInitiatorUsername = loJResp.StringOf("UserActivities[i].Initiator.Username")
    lnIsIndirectActivity = loJResp.IntOf("UserActivities[i].IsIndirectActivity")
    lcOrganizationId = loJResp.StringOf("UserActivities[i].OrganizationId")
    lcOriginalParentId = loJResp.StringOf("UserActivities[i].OriginalParent.Id")
    lcName = loJResp.StringOf("UserActivities[i].OriginalParent.Name")
    lcOriginalName = loJResp.StringOf("UserActivities[i].OriginalParent.OriginalName")
    lcOwnerEmailAddress = loJResp.StringOf("UserActivities[i].OriginalParent.Owner.EmailAddress")
    lcOwnerGivenName = loJResp.StringOf("UserActivities[i].OriginalParent.Owner.GivenName")
    lcOwnerId = loJResp.StringOf("UserActivities[i].OriginalParent.Owner.Id")
    lcOwnerSurname = loJResp.StringOf("UserActivities[i].OriginalParent.Owner.Surname")
    lcOwnerUsername = loJResp.StringOf("UserActivities[i].OriginalParent.Owner.Username")
    lcParentId = loJResp.StringOf("UserActivities[i].OriginalParent.ParentId")
    lcOriginalParentType = loJResp.StringOf("UserActivities[i].OriginalParent.Type")
    lcVersionId = loJResp.StringOf("UserActivities[i].OriginalParent.VersionId")
    lcResourceMetadataId = loJResp.StringOf("UserActivities[i].ResourceMetadata.Id")
    lcResourceMetadataName = loJResp.StringOf("UserActivities[i].ResourceMetadata.Name")
    lcResourceMetadataOriginalName = loJResp.StringOf("UserActivities[i].ResourceMetadata.OriginalName")
    lcOwnerEmailAddress = loJResp.StringOf("UserActivities[i].ResourceMetadata.Owner.EmailAddress")
    lcOwnerGivenName = loJResp.StringOf("UserActivities[i].ResourceMetadata.Owner.GivenName")
    lcOwnerId = loJResp.StringOf("UserActivities[i].ResourceMetadata.Owner.Id")
    lcOwnerSurname = loJResp.StringOf("UserActivities[i].ResourceMetadata.Owner.Surname")
    lcOwnerUsername = loJResp.StringOf("UserActivities[i].ResourceMetadata.Owner.Username")
    lcResourceMetadataParentId = loJResp.StringOf("UserActivities[i].ResourceMetadata.ParentId")
    lcResourceMetadataType = loJResp.StringOf("UserActivities[i].ResourceMetadata.Type")
    lcResourceMetadataVersionId = loJResp.StringOf("UserActivities[i].ResourceMetadata.VersionId")
    lnTimeStamp = loJResp.IntOf("UserActivities[i].TimeStamp")
    lcV_Type = loJResp.StringOf("UserActivities[i].Type")
    j = 0
    lnCount_j = loJResp.SizeOfArray("UserActivities[i].Participants.Groups")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcId = loJResp.StringOf("UserActivities[i].Participants.Groups[j].Id")
        lcName = loJResp.StringOf("UserActivities[i].Participants.Groups[j].Name")
        j = j + 1
    ENDDO
    j = 0
    lnCount_j = loJResp.SizeOfArray("UserActivities[i].Participants.Users")
    DO WHILE j < lnCount_j
        loJResp.J = j
        lcEmailAddress = loJResp.StringOf("UserActivities[i].Participants.Users[j].EmailAddress")
        lcGivenName = loJResp.StringOf("UserActivities[i].Participants.Users[j].GivenName")
        lcId = loJResp.StringOf("UserActivities[i].Participants.Users[j].Id")
        lcSurname = loJResp.StringOf("UserActivities[i].Participants.Users[j].Surname")
        lcUsername = loJResp.StringOf("UserActivities[i].Participants.Users[j].Username")
        j = j + 1
    ENDDO
    i = i + 1
ENDDO

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

RELEASE loRest
RELEASE loAuthAws
RELEASE loSbResponseBody
RELEASE loJResp