DescribeActivities Objective-C Example
#import <CkoRest.h>
#import <CkoAuthAws.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
CkoAuthAws *authAws = [[CkoAuthAws alloc] init];
authAws.AccessKey = @"AWS_ACCESS_KEY";
authAws.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.)
authAws.Region = @"us-west-2";
authAws.ServiceName = @"workdocs";
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
[rest SetAuthAws: authAws];
// URL: https://workdocs.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = [rest Connect: @"workdocs.us-west-2.amazonaws.com" port: [NSNumber numberWithInt: 443] tls: YES autoReconnect: YES];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
[rest AddHeader: @"Content-Type" value: @"application/x-amz-json-1.1"];
[rest AddHeader: @"X-Amz-Target" value: @"DescribeActivities"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/api/v1/activities" sb: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
NSLog(@"%@%d",@"response status code = ",respStatusCode);
if (respStatusCode != 200) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
// 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
NSString *CommentId = 0;
NSString *CommentStatus = 0;
int CreatedTimestamp;
NSString *EmailAddress = 0;
NSString *GivenName = 0;
NSString *Id = 0;
NSString *Locale = 0;
int ModifiedTimestamp;
NSString *OrganizationId = 0;
NSString *RecycleBinFolderId = 0;
NSString *RootFolderId = 0;
NSString *Status = 0;
int StorageAllocatedInBytes;
NSString *StorageType = 0;
int StorageUtilizedInBytes;
NSString *Surname = 0;
NSString *TimeZoneId = 0;
NSString *v_Type = 0;
NSString *Username = 0;
int CommentMetadataCreatedTimestamp;
NSString *RecipientId = 0;
NSString *InitiatorEmailAddress = 0;
NSString *InitiatorGivenName = 0;
NSString *InitiatorId = 0;
NSString *InitiatorSurname = 0;
NSString *InitiatorUsername = 0;
int IsIndirectActivity;
NSString *OriginalParentId = 0;
NSString *Name = 0;
NSString *OriginalName = 0;
NSString *OwnerEmailAddress = 0;
NSString *OwnerGivenName = 0;
NSString *OwnerId = 0;
NSString *OwnerSurname = 0;
NSString *OwnerUsername = 0;
NSString *ParentId = 0;
NSString *OriginalParentType = 0;
NSString *VersionId = 0;
NSString *ResourceMetadataId = 0;
NSString *ResourceMetadataName = 0;
NSString *ResourceMetadataOriginalName = 0;
NSString *ResourceMetadataParentId = 0;
NSString *ResourceMetadataType = 0;
NSString *ResourceMetadataVersionId = 0;
int TimeStamp;
int j;
int count_j;
NSString *Marker = [jResp StringOf: @"Marker"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"UserActivities"] intValue];
while (i < count_i) {
jResp.I = [NSNumber numberWithInt: i];
CommentId = [jResp StringOf: @"UserActivities[i].CommentMetadata.CommentId"];
CommentStatus = [jResp StringOf: @"UserActivities[i].CommentMetadata.CommentStatus"];
CreatedTimestamp = [[jResp IntOf: @"UserActivities[i].CommentMetadata.Contributor.CreatedTimestamp"] intValue];
EmailAddress = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.EmailAddress"];
GivenName = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.GivenName"];
Id = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Id"];
Locale = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Locale"];
ModifiedTimestamp = [[jResp IntOf: @"UserActivities[i].CommentMetadata.Contributor.ModifiedTimestamp"] intValue];
OrganizationId = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.OrganizationId"];
RecycleBinFolderId = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.RecycleBinFolderId"];
RootFolderId = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.RootFolderId"];
Status = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Status"];
StorageAllocatedInBytes = [[jResp IntOf: @"UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageAllocatedInBytes"] intValue];
StorageType = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Storage.StorageRule.StorageType"];
StorageUtilizedInBytes = [[jResp IntOf: @"UserActivities[i].CommentMetadata.Contributor.Storage.StorageUtilizedInBytes"] intValue];
Surname = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Surname"];
TimeZoneId = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.TimeZoneId"];
v_Type = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Type"];
Username = [jResp StringOf: @"UserActivities[i].CommentMetadata.Contributor.Username"];
CommentMetadataCreatedTimestamp = [[jResp IntOf: @"UserActivities[i].CommentMetadata.CreatedTimestamp"] intValue];
RecipientId = [jResp StringOf: @"UserActivities[i].CommentMetadata.RecipientId"];
InitiatorEmailAddress = [jResp StringOf: @"UserActivities[i].Initiator.EmailAddress"];
InitiatorGivenName = [jResp StringOf: @"UserActivities[i].Initiator.GivenName"];
InitiatorId = [jResp StringOf: @"UserActivities[i].Initiator.Id"];
InitiatorSurname = [jResp StringOf: @"UserActivities[i].Initiator.Surname"];
InitiatorUsername = [jResp StringOf: @"UserActivities[i].Initiator.Username"];
IsIndirectActivity = [[jResp IntOf: @"UserActivities[i].IsIndirectActivity"] intValue];
OrganizationId = [jResp StringOf: @"UserActivities[i].OrganizationId"];
OriginalParentId = [jResp StringOf: @"UserActivities[i].OriginalParent.Id"];
Name = [jResp StringOf: @"UserActivities[i].OriginalParent.Name"];
OriginalName = [jResp StringOf: @"UserActivities[i].OriginalParent.OriginalName"];
OwnerEmailAddress = [jResp StringOf: @"UserActivities[i].OriginalParent.Owner.EmailAddress"];
OwnerGivenName = [jResp StringOf: @"UserActivities[i].OriginalParent.Owner.GivenName"];
OwnerId = [jResp StringOf: @"UserActivities[i].OriginalParent.Owner.Id"];
OwnerSurname = [jResp StringOf: @"UserActivities[i].OriginalParent.Owner.Surname"];
OwnerUsername = [jResp StringOf: @"UserActivities[i].OriginalParent.Owner.Username"];
ParentId = [jResp StringOf: @"UserActivities[i].OriginalParent.ParentId"];
OriginalParentType = [jResp StringOf: @"UserActivities[i].OriginalParent.Type"];
VersionId = [jResp StringOf: @"UserActivities[i].OriginalParent.VersionId"];
ResourceMetadataId = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Id"];
ResourceMetadataName = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Name"];
ResourceMetadataOriginalName = [jResp StringOf: @"UserActivities[i].ResourceMetadata.OriginalName"];
OwnerEmailAddress = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Owner.EmailAddress"];
OwnerGivenName = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Owner.GivenName"];
OwnerId = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Owner.Id"];
OwnerSurname = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Owner.Surname"];
OwnerUsername = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Owner.Username"];
ResourceMetadataParentId = [jResp StringOf: @"UserActivities[i].ResourceMetadata.ParentId"];
ResourceMetadataType = [jResp StringOf: @"UserActivities[i].ResourceMetadata.Type"];
ResourceMetadataVersionId = [jResp StringOf: @"UserActivities[i].ResourceMetadata.VersionId"];
TimeStamp = [[jResp IntOf: @"UserActivities[i].TimeStamp"] intValue];
v_Type = [jResp StringOf: @"UserActivities[i].Type"];
j = 0;
count_j = [[jResp SizeOfArray: @"UserActivities[i].Participants.Groups"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
Id = [jResp StringOf: @"UserActivities[i].Participants.Groups[j].Id"];
Name = [jResp StringOf: @"UserActivities[i].Participants.Groups[j].Name"];
j = j + 1;
}
j = 0;
count_j = [[jResp SizeOfArray: @"UserActivities[i].Participants.Users"] intValue];
while (j < count_j) {
jResp.J = [NSNumber numberWithInt: j];
EmailAddress = [jResp StringOf: @"UserActivities[i].Participants.Users[j].EmailAddress"];
GivenName = [jResp StringOf: @"UserActivities[i].Participants.Users[j].GivenName"];
Id = [jResp StringOf: @"UserActivities[i].Participants.Users[j].Id"];
Surname = [jResp StringOf: @"UserActivities[i].Participants.Users[j].Surname"];
Username = [jResp StringOf: @"UserActivities[i].Participants.Users[j].Username"];
j = j + 1;
}
i = i + 1;
}
// 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"
// }
// ]
// }