Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Yousign Create Procedure after Uploading the PDFDemonstrates the 2nd step of Yousign procedure creation. This is the call to create the procedure after previously uploading the PDF file. For more information, see https://dev.yousign.com/?version=latest#c2e03a8b-f782-4d3e-96d1-04517c083497
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example assumes the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i ; Implements the following CURL command: ; curl --location --request POST 'https://staging-api.yousign.com/procedures' \ ; --header 'Authorization: Bearer YOUR_API_KEY' \ ; --header 'Content-Type: application/json' \ ; --data-raw '{ ; "name": "My first procedure", ; "description": "Awesome! Here is the description of my first procedure", ; "members": [ ; { ; "firstname": "John", ; "lastname": "Doe", ; "email": "john.doe@yousign.fr", ; "phone": "+33612345678", ; "fileObjects": [ ; { ; "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "page": 2, ; "position": "230,499,464,589", ; "mention": "Read and approved", ; "mention2": "Signed by John Doe" ; } ; ] ; } ; ] ; }' ; Use the following online tool to generate HTTP code from a CURL command ; Convert a cURL Command to HTTP Source Code ; Use this online tool to generate code from sample JSON: ; Generate Code to Create JSON ; The following JSON is sent in the request body. ; { ; "name": "My first procedure", ; "description": "Awesome! Here is the description of my first procedure", ; "members": [ ; { ; "firstname": "John", ; "lastname": "Doe", ; "email": "john.doe@yousign.fr", ; "phone": "+33612345678", ; "fileObjects": [ ; { ; "file": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "page": 2, ; "position": "230,499,464,589", ; "mention": "Read and approved", ; "mention2": "Signed by John Doe" ; } ; ] ; } ; ] ; } json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckUpdateString(json,"name","My first procedure") CkJsonObject::ckUpdateString(json,"description","Awesome! Here is the description of my first procedure") CkJsonObject::ckUpdateString(json,"members[0].firstname","John") CkJsonObject::ckUpdateString(json,"members[0].lastname","Doe") CkJsonObject::ckUpdateString(json,"members[0].email","john.doe@yousign.fr") CkJsonObject::ckUpdateString(json,"members[0].phone","+33612345678") CkJsonObject::ckUpdateString(json,"members[0].fileObjects[0].file","/files/6c123a8d-e5cf-4534-8da0-81886376ba2c") CkJsonObject::ckUpdateInt(json,"members[0].fileObjects[0].page",2) CkJsonObject::ckUpdateString(json,"members[0].fileObjects[0].position","230,499,464,589") CkJsonObject::ckUpdateString(json,"members[0].fileObjects[0].mention","Read and approved") CkJsonObject::ckUpdateString(json,"members[0].fileObjects[0].mention2","Signed by John Doe") ; Adds the "Authorization: Bearer YOUR_API_KEY" header. CkHttp::setCkAuthToken(http, "YOUR_API_KEY") CkHttp::ckSetRequestHeader(http,"Content-Type","application/json") resp.i = CkHttp::ckPostJson3(http,"https://staging-api.yousign.com/procedures","application/json",json) If CkHttp::ckLastMethodSuccess(http) = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) ProcedureReturn EndIf sbResponseBody.i = CkStringBuilder::ckCreate() If sbResponseBody.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttpResponse::ckGetBodySb(resp,sbResponseBody) jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbResponseBody) CkJsonObject::setCkEmitCompact(jResp, 0) Debug "Response Body:" Debug CkJsonObject::ckEmit(jResp) respStatusCode.i = CkHttpResponse::ckStatusCode(resp) Debug "Response Status Code = " + Str(respStatusCode) If respStatusCode >= 400 Debug "Response Header:" Debug CkHttpResponse::ckHeader(resp) Debug "Failed." CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndIf CkHttpResponse::ckDispose(resp) ; Sample JSON response: ; (Sample code for parsing the JSON response is shown below) ; { ; "id": "/procedures/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "name": "My first procedure", ; "description": "Awesome! Here is the description of my first procedure", ; "createdAt": "2018-12-01T11:49:11+01:00", ; "updatedAt": "2018-12-01T11:49:11+01:00", ; "finishedAt": null, ; "expiresAt": null, ; "status": "active", ; "creator": null, ; "creatorFirstName": null, ; "creatorLastName": null, ; "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "template": false, ; "ordered": false, ; "parent": null, ; "metadata": [ ; ], ; "config": [ ; ], ; "members": [ ; { ; "id": "/members/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "user": null, ; "type": "signer", ; "firstname": "John", ; "lastname": "Doe", ; "email": "john.doe@yousign.fr", ; "phone": "+33612345678", ; "position": 1, ; "createdAt": "2018-12-01T11:49:11+01:00", ; "updatedAt": "2018-12-01T11:49:11+01:00", ; "finishedAt": null, ; "status": "pending", ; "fileObjects": [ ; { ; "id": "/file_objects/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "file": { ; "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "name": "The best name for my file.pdf", ; "type": "signable", ; "contentType": "application/pdf", ; "description": null, ; "createdAt": "2018-12-01T11:36:20+01:00", ; "updatedAt": "2018-12-01T11:49:11+01:00", ; "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", ; "metadata": [ ; ], ; "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "creator": null, ; "protected": false, ; "position": 0, ; "parent": null ; }, ; "page": 2, ; "position": "230,499,464,589", ; "fieldName": null, ; "mention": "Read and approved", ; "mention2": "Signed by John Doe", ; "createdAt": "2018-12-01T11:49:11+01:00", ; "updatedAt": "2018-12-01T11:49:11+01:00", ; "parent": null, ; "reason": "Signed by Yousign" ; } ; ], ; "comment": null, ; "notificationsEmail": [ ; ], ; "operationLevel": "custom", ; "operationCustomModes": [ ; "sms" ; ], ; "operationModeSmsConfig": null, ; "parent": null ; } ; ], ; "subscribers": [ ; ], ; "files": [ ; { ; "id": "/files/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "name": "The best name for my file.pdf", ; "type": "signable", ; "contentType": "application/pdf", ; "description": null, ; "createdAt": "2018-12-01T11:36:20+01:00", ; "updatedAt": "2018-12-01T11:49:11+01:00", ; "sha256": "bb57ae2b2ca6ad0133a699350d1a6f6c8cdfde3cf872cf526585d306e4675cc2", ; "metadata": [ ; ], ; "workspace": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", ; "creator": null, ; "protected": false, ; "position": 0, ; "parent": null ; } ; ], ; "relatedFilesEnable": false, ; "archive": false, ; "archiveMetadata": [ ; ], ; "fields": [ ; ], ; "permissions": [ ; ] ; } ; Sample code for parsing the JSON response... ; Use the following online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON user.s v_type.s firstname.s lastname.s email.s phone.s position.i comment.s operationLevel.s operationModeSmsConfig.s j.i count_j.i fileId.s fileName.s fileType.s fileContentType.s fileDescription.s fileCreatedAt.s fileUpdatedAt.s fileSha256.s fileWorkspace.s fileCreator.s fileProtected.i filePosition.i fileParent.s page.i position_str.s fieldName.s mention.s mention2.s reason.s k.i count_k.i strVal.s contentType.s sha256.s v_protected.i id.s = CkJsonObject::ckStringOf(jResp,"id") name.s = CkJsonObject::ckStringOf(jResp,"name") description.s = CkJsonObject::ckStringOf(jResp,"description") createdAt.s = CkJsonObject::ckStringOf(jResp,"createdAt") updatedAt.s = CkJsonObject::ckStringOf(jResp,"updatedAt") finishedAt.s = CkJsonObject::ckStringOf(jResp,"finishedAt") expiresAt.s = CkJsonObject::ckStringOf(jResp,"expiresAt") status.s = CkJsonObject::ckStringOf(jResp,"status") creator.s = CkJsonObject::ckStringOf(jResp,"creator") creatorFirstName.s = CkJsonObject::ckStringOf(jResp,"creatorFirstName") creatorLastName.s = CkJsonObject::ckStringOf(jResp,"creatorLastName") workspace.s = CkJsonObject::ckStringOf(jResp,"workspace") template.i = CkJsonObject::ckBoolOf(jResp,"template") ordered.i = CkJsonObject::ckBoolOf(jResp,"ordered") parent.s = CkJsonObject::ckStringOf(jResp,"parent") relatedFilesEnable.i = CkJsonObject::ckBoolOf(jResp,"relatedFilesEnable") archive.i = CkJsonObject::ckBoolOf(jResp,"archive") i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"metadata") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"config") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"members") While i < count_i CkJsonObject::setCkI(jResp, i) id = CkJsonObject::ckStringOf(jResp,"members[i].id") user = CkJsonObject::ckStringOf(jResp,"members[i].user") v_type = CkJsonObject::ckStringOf(jResp,"members[i].type") firstname = CkJsonObject::ckStringOf(jResp,"members[i].firstname") lastname = CkJsonObject::ckStringOf(jResp,"members[i].lastname") email = CkJsonObject::ckStringOf(jResp,"members[i].email") phone = CkJsonObject::ckStringOf(jResp,"members[i].phone") position = CkJsonObject::ckIntOf(jResp,"members[i].position") createdAt = CkJsonObject::ckStringOf(jResp,"members[i].createdAt") updatedAt = CkJsonObject::ckStringOf(jResp,"members[i].updatedAt") finishedAt = CkJsonObject::ckStringOf(jResp,"members[i].finishedAt") status = CkJsonObject::ckStringOf(jResp,"members[i].status") comment = CkJsonObject::ckStringOf(jResp,"members[i].comment") operationLevel = CkJsonObject::ckStringOf(jResp,"members[i].operationLevel") operationModeSmsConfig = CkJsonObject::ckStringOf(jResp,"members[i].operationModeSmsConfig") parent = CkJsonObject::ckStringOf(jResp,"members[i].parent") j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"members[i].fileObjects") While j < count_j CkJsonObject::setCkJ(jResp, j) id = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].id") fileId = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.id") fileName = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.name") fileType = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.type") fileContentType = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.contentType") fileDescription = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.description") fileCreatedAt = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.createdAt") fileUpdatedAt = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.updatedAt") fileSha256 = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.sha256") fileWorkspace = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.workspace") fileCreator = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.creator") fileProtected = CkJsonObject::ckBoolOf(jResp,"members[i].fileObjects[j].file.protected") filePosition = CkJsonObject::ckIntOf(jResp,"members[i].fileObjects[j].file.position") fileParent = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].file.parent") page = CkJsonObject::ckIntOf(jResp,"members[i].fileObjects[j].page") position_str = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].position") fieldName = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].fieldName") mention = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].mention") mention2 = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].mention2") createdAt = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].createdAt") updatedAt = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].updatedAt") parent = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].parent") reason = CkJsonObject::ckStringOf(jResp,"members[i].fileObjects[j].reason") k = 0 count_k = CkJsonObject::ckSizeOfArray(jResp,"members[i].fileObjects[j].file.metadata") While k < count_k CkJsonObject::setCkK(jResp, k) k = k + 1 Wend j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"members[i].notificationsEmail") While j < count_j CkJsonObject::setCkJ(jResp, j) j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"members[i].operationCustomModes") While j < count_j CkJsonObject::setCkJ(jResp, j) strVal = CkJsonObject::ckStringOf(jResp,"members[i].operationCustomModes[j]") j = j + 1 Wend i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"subscribers") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"files") While i < count_i CkJsonObject::setCkI(jResp, i) id = CkJsonObject::ckStringOf(jResp,"files[i].id") name = CkJsonObject::ckStringOf(jResp,"files[i].name") v_type = CkJsonObject::ckStringOf(jResp,"files[i].type") contentType = CkJsonObject::ckStringOf(jResp,"files[i].contentType") description = CkJsonObject::ckStringOf(jResp,"files[i].description") createdAt = CkJsonObject::ckStringOf(jResp,"files[i].createdAt") updatedAt = CkJsonObject::ckStringOf(jResp,"files[i].updatedAt") sha256 = CkJsonObject::ckStringOf(jResp,"files[i].sha256") workspace = CkJsonObject::ckStringOf(jResp,"files[i].workspace") creator = CkJsonObject::ckStringOf(jResp,"files[i].creator") v_protected = CkJsonObject::ckBoolOf(jResp,"files[i].protected") position = CkJsonObject::ckIntOf(jResp,"files[i].position") parent = CkJsonObject::ckStringOf(jResp,"files[i].parent") j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"files[i].metadata") While j < count_j CkJsonObject::setCkJ(jResp, j) j = j + 1 Wend i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"archiveMetadata") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"fields") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend i = 0 count_i = CkJsonObject::ckSizeOfArray(jResp,"permissions") While i < count_i CkJsonObject::setCkI(jResp, i) i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(json) CkStringBuilder::ckDispose(sbResponseBody) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.