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
(Delphi DLL) 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
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, HttpResponse, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; success: Boolean; json: HCkJsonObject; resp: HCkHttpResponse; sbResponseBody: HCkStringBuilder; jResp: HCkJsonObject; respStatusCode: Integer; user: PWideChar; v_type: PWideChar; firstname: PWideChar; lastname: PWideChar; email: PWideChar; phone: PWideChar; position: Integer; comment: PWideChar; operationLevel: PWideChar; operationModeSmsConfig: PWideChar; j: Integer; count_j: Integer; fileId: PWideChar; fileName: PWideChar; fileType: PWideChar; fileContentType: PWideChar; fileDescription: PWideChar; fileCreatedAt: PWideChar; fileUpdatedAt: PWideChar; fileSha256: PWideChar; fileWorkspace: PWideChar; fileCreator: PWideChar; fileProtected: Boolean; filePosition: Integer; fileParent: PWideChar; page: Integer; position_str: PWideChar; fieldName: PWideChar; mention: PWideChar; mention2: PWideChar; reason: PWideChar; k: Integer; count_k: Integer; strVal: PWideChar; contentType: PWideChar; sha256: PWideChar; v_protected: Boolean; id: PWideChar; name: PWideChar; description: PWideChar; createdAt: PWideChar; updatedAt: PWideChar; finishedAt: PWideChar; expiresAt: PWideChar; status: PWideChar; creator: PWideChar; creatorFirstName: PWideChar; creatorLastName: PWideChar; workspace: PWideChar; template: Boolean; ordered: Boolean; parent: PWideChar; relatedFilesEnable: Boolean; archive: Boolean; i: Integer; count_i: Integer; begin // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := CkHttp_Create(); // 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 := CkJsonObject_Create(); CkJsonObject_UpdateString(json,'name','My first procedure'); CkJsonObject_UpdateString(json,'description','Awesome! Here is the description of my first procedure'); CkJsonObject_UpdateString(json,'members[0].firstname','John'); CkJsonObject_UpdateString(json,'members[0].lastname','Doe'); CkJsonObject_UpdateString(json,'members[0].email','john.doe@yousign.fr'); CkJsonObject_UpdateString(json,'members[0].phone','+33612345678'); CkJsonObject_UpdateString(json,'members[0].fileObjects[0].file','/files/6c123a8d-e5cf-4534-8da0-81886376ba2c'); CkJsonObject_UpdateInt(json,'members[0].fileObjects[0].page',2); CkJsonObject_UpdateString(json,'members[0].fileObjects[0].position','230,499,464,589'); CkJsonObject_UpdateString(json,'members[0].fileObjects[0].mention','Read and approved'); CkJsonObject_UpdateString(json,'members[0].fileObjects[0].mention2','Signed by John Doe'); // Adds the "Authorization: Bearer YOUR_API_KEY" header. CkHttp_putAuthToken(http,'YOUR_API_KEY'); CkHttp_SetRequestHeader(http,'Content-Type','application/json'); resp := CkHttp_PostJson3(http,'https://staging-api.yousign.com/procedures','application/json',json); if (CkHttp_getLastMethodSuccess(http) = False) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; sbResponseBody := CkStringBuilder_Create(); CkHttpResponse_GetBodySb(resp,sbResponseBody); jResp := CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,False); Memo1.Lines.Add('Response Body:'); Memo1.Lines.Add(CkJsonObject__emit(jResp)); respStatusCode := CkHttpResponse_getStatusCode(resp); Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode)); if (respStatusCode >= 400) then begin Memo1.Lines.Add('Response Header:'); Memo1.Lines.Add(CkHttpResponse__header(resp)); Memo1.Lines.Add('Failed.'); CkHttpResponse_Dispose(resp); Exit; end; CkHttpResponse_Dispose(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 id := CkJsonObject__stringOf(jResp,'id'); name := CkJsonObject__stringOf(jResp,'name'); description := CkJsonObject__stringOf(jResp,'description'); createdAt := CkJsonObject__stringOf(jResp,'createdAt'); updatedAt := CkJsonObject__stringOf(jResp,'updatedAt'); finishedAt := CkJsonObject__stringOf(jResp,'finishedAt'); expiresAt := CkJsonObject__stringOf(jResp,'expiresAt'); status := CkJsonObject__stringOf(jResp,'status'); creator := CkJsonObject__stringOf(jResp,'creator'); creatorFirstName := CkJsonObject__stringOf(jResp,'creatorFirstName'); creatorLastName := CkJsonObject__stringOf(jResp,'creatorLastName'); workspace := CkJsonObject__stringOf(jResp,'workspace'); template := CkJsonObject_BoolOf(jResp,'template'); ordered := CkJsonObject_BoolOf(jResp,'ordered'); parent := CkJsonObject__stringOf(jResp,'parent'); relatedFilesEnable := CkJsonObject_BoolOf(jResp,'relatedFilesEnable'); archive := CkJsonObject_BoolOf(jResp,'archive'); i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'metadata'); while i < count_i do begin CkJsonObject_putI(jResp,i); i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'config'); while i < count_i do begin CkJsonObject_putI(jResp,i); i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'members'); while i < count_i do begin CkJsonObject_putI(jResp,i); id := CkJsonObject__stringOf(jResp,'members[i].id'); user := CkJsonObject__stringOf(jResp,'members[i].user'); v_type := CkJsonObject__stringOf(jResp,'members[i].type'); firstname := CkJsonObject__stringOf(jResp,'members[i].firstname'); lastname := CkJsonObject__stringOf(jResp,'members[i].lastname'); email := CkJsonObject__stringOf(jResp,'members[i].email'); phone := CkJsonObject__stringOf(jResp,'members[i].phone'); position := CkJsonObject_IntOf(jResp,'members[i].position'); createdAt := CkJsonObject__stringOf(jResp,'members[i].createdAt'); updatedAt := CkJsonObject__stringOf(jResp,'members[i].updatedAt'); finishedAt := CkJsonObject__stringOf(jResp,'members[i].finishedAt'); status := CkJsonObject__stringOf(jResp,'members[i].status'); comment := CkJsonObject__stringOf(jResp,'members[i].comment'); operationLevel := CkJsonObject__stringOf(jResp,'members[i].operationLevel'); operationModeSmsConfig := CkJsonObject__stringOf(jResp,'members[i].operationModeSmsConfig'); parent := CkJsonObject__stringOf(jResp,'members[i].parent'); j := 0; count_j := CkJsonObject_SizeOfArray(jResp,'members[i].fileObjects'); while j < count_j do begin CkJsonObject_putJ(jResp,j); id := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].id'); fileId := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.id'); fileName := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.name'); fileType := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.type'); fileContentType := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.contentType'); fileDescription := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.description'); fileCreatedAt := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.createdAt'); fileUpdatedAt := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.updatedAt'); fileSha256 := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.sha256'); fileWorkspace := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.workspace'); fileCreator := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.creator'); fileProtected := CkJsonObject_BoolOf(jResp,'members[i].fileObjects[j].file.protected'); filePosition := CkJsonObject_IntOf(jResp,'members[i].fileObjects[j].file.position'); fileParent := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].file.parent'); page := CkJsonObject_IntOf(jResp,'members[i].fileObjects[j].page'); position_str := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].position'); fieldName := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].fieldName'); mention := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].mention'); mention2 := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].mention2'); createdAt := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].createdAt'); updatedAt := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].updatedAt'); parent := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].parent'); reason := CkJsonObject__stringOf(jResp,'members[i].fileObjects[j].reason'); k := 0; count_k := CkJsonObject_SizeOfArray(jResp,'members[i].fileObjects[j].file.metadata'); while k < count_k do begin CkJsonObject_putK(jResp,k); k := k + 1; end; j := j + 1; end; j := 0; count_j := CkJsonObject_SizeOfArray(jResp,'members[i].notificationsEmail'); while j < count_j do begin CkJsonObject_putJ(jResp,j); j := j + 1; end; j := 0; count_j := CkJsonObject_SizeOfArray(jResp,'members[i].operationCustomModes'); while j < count_j do begin CkJsonObject_putJ(jResp,j); strVal := CkJsonObject__stringOf(jResp,'members[i].operationCustomModes[j]'); j := j + 1; end; i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'subscribers'); while i < count_i do begin CkJsonObject_putI(jResp,i); i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'files'); while i < count_i do begin CkJsonObject_putI(jResp,i); id := CkJsonObject__stringOf(jResp,'files[i].id'); name := CkJsonObject__stringOf(jResp,'files[i].name'); v_type := CkJsonObject__stringOf(jResp,'files[i].type'); contentType := CkJsonObject__stringOf(jResp,'files[i].contentType'); description := CkJsonObject__stringOf(jResp,'files[i].description'); createdAt := CkJsonObject__stringOf(jResp,'files[i].createdAt'); updatedAt := CkJsonObject__stringOf(jResp,'files[i].updatedAt'); sha256 := CkJsonObject__stringOf(jResp,'files[i].sha256'); workspace := CkJsonObject__stringOf(jResp,'files[i].workspace'); creator := CkJsonObject__stringOf(jResp,'files[i].creator'); v_protected := CkJsonObject_BoolOf(jResp,'files[i].protected'); position := CkJsonObject_IntOf(jResp,'files[i].position'); parent := CkJsonObject__stringOf(jResp,'files[i].parent'); j := 0; count_j := CkJsonObject_SizeOfArray(jResp,'files[i].metadata'); while j < count_j do begin CkJsonObject_putJ(jResp,j); j := j + 1; end; i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'archiveMetadata'); while i < count_i do begin CkJsonObject_putI(jResp,i); i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'fields'); while i < count_i do begin CkJsonObject_putI(jResp,i); i := i + 1; end; i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'permissions'); while i < count_i do begin CkJsonObject_putI(jResp,i); i := i + 1; end; CkHttp_Dispose(http); CkJsonObject_Dispose(json); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.