Objective-C
Objective-C
Yousign: List Files
See more Yousign Examples
List Yousign files.Chilkat Objective-C Downloads
#import <CkoHttp.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
BOOL success = NO;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttp *http = [[CkoHttp alloc] init];
// Implements the following CURL command:
// curl --location --request GET 'https://staging-api.yousign.com/files' \
// --header 'Authorization: Bearer YOUR_API_KEY' \
// --header 'Content-Type: application/json'
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
// Adds the "Authorization: Bearer YOUR_API_KEY" header.
http.AuthToken = @"YOUR_API_KEY";
[http SetRequestHeader: @"Content-Type" value: @"application/json"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [http QuickGetSb: @"https://staging-api.yousign.com/files" sbContent: sbResponseBody];
if (success == NO) {
NSLog(@"%@",http.LastErrorText);
return;
}
CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json LoadSb: sbResponseBody];
json.EmitCompact = NO;
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[json Emit]);
int respStatusCode = [http.LastStatus intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",http.LastHeader);
NSLog(@"%@",@"Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "id": "\/files\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "name": "abc.pdf",
// "type": "signable",
// "contentType": "application\/pdf",
// "description": null,
// "createdAt": "2020-05-27T09:14:12+02:00",
// "updatedAt": "2020-05-27T09:14:12+02:00",
// "sha256": "ea2a92b0eff5bebfa3ccd869fd61e27bb7fe973d0dff63f106d8b0d614469fa0",
// "metadata": [
// ],
// "workspace": "\/workspaces\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
// "creator": null,
// "fileObjects": [
// ],
// "protected": false,
// "position": 0,
// "parent": null,
// "fieldsCompatible": true,
// "company": "\/companies\/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
// }
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
NSString *id = [json StringOf: @"id"];
NSString *name = [json StringOf: @"name"];
NSString *v_type = [json StringOf: @"type"];
NSString *contentType = [json StringOf: @"contentType"];
NSString *description = [json StringOf: @"description"];
NSString *createdAt = [json StringOf: @"createdAt"];
NSString *updatedAt = [json StringOf: @"updatedAt"];
NSString *sha256 = [json StringOf: @"sha256"];
NSString *workspace = [json StringOf: @"workspace"];
NSString *creator = [json StringOf: @"creator"];
BOOL v_protected = [json BoolOf: @"protected"];
int position = [[json IntOf: @"position"] intValue];
NSString *parent = [json StringOf: @"parent"];
BOOL fieldsCompatible = [json BoolOf: @"fieldsCompatible"];
NSString *company = [json StringOf: @"company"];
int i = 0;
int count_i = [[json SizeOfArray: @"metadata"] intValue];
while (i < count_i) {
json.I = [NSNumber numberWithInt: i];
i = i + 1;
}
i = 0;
count_i = [[json SizeOfArray: @"fileObjects"] intValue];
while (i < count_i) {
json.I = [NSNumber numberWithInt: i];
i = i + 1;
}