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) Docusign: Return Brand Data Associated with a UserDemonstrates a call using an OAuth2 access token in combination with the account ID for which we have authorization. For more information, see https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, JsonObject; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; success: Boolean; jsonToken: HCkJsonObject; sbResponseBody: HCkStringBuilder; json: HCkJsonObject; respStatusCode: Integer; brandCompany: PWideChar; brandId: PWideChar; brandName: PWideChar; errorDetailsErrorCode: PWideChar; errorDetailsMessage: PWideChar; isOverridingCompanyName: PWideChar; isSendingDefault: PWideChar; isSigningDefault: PWideChar; logosPrimary: PWideChar; logosSecondary: PWideChar; logosEmail: PWideChar; resourcesEmail: PWideChar; resourcesSending: PWideChar; resourcesSigning: PWideChar; resourcesSigningCaptive: PWideChar; j: Integer; count_j: Integer; linkType: PWideChar; urlOrMailTo: PWideChar; linkText: PWideChar; showLink: PWideChar; emailContentType: PWideChar; content: PWideChar; emailToLink: PWideChar; recipientBrandIdDefault: PWideChar; senderBrandIdDefault: PWideChar; 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 --request GET https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands --header "Authorization: Bearer eyJ0eXAi.....UE8Kl_V8KroQ" // 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 eyJ0eXAi.....UE8Kl_V8KroQ" header. jsonToken := CkJsonObject_Create(); // Load a previously obtained OAuth2 access token. success := CkJsonObject_LoadFile(jsonToken,'qa_data/tokens/docusign.json'); if (success = False) then begin Memo1.Lines.Add(CkJsonObject__lastErrorText(jsonToken)); Exit; end; CkHttp_putAuthToken(http,CkJsonObject__stringOf(jsonToken,'access_token')); // Use an account ID obtained from DocuSign Get User Account Data sbResponseBody := CkStringBuilder_Create(); success := CkHttp_QuickGetSb(http,'https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands',sbResponseBody); if (success = False) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; json := CkJsonObject_Create(); CkJsonObject_LoadSb(json,sbResponseBody); CkJsonObject_putEmitCompact(json,False); Memo1.Lines.Add('Response Body:'); Memo1.Lines.Add(CkJsonObject__emit(json)); respStatusCode := CkHttp_getLastStatus(http); Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode)); if (respStatusCode >= 400) then begin Memo1.Lines.Add('Response Header:'); Memo1.Lines.Add(CkHttp__lastHeader(http)); Memo1.Lines.Add('Failed.'); Exit; end; // Sample JSON response: // (Sample code for parsing the JSON response is shown below) // { // "recipientBrandIdDefault": "sample string 1", // "senderBrandIdDefault": "sample string 2", // "brands": [ // { // "brandCompany": "sample string 1", // "brandId": "sample string 2", // "brandName": "sample string 3", // "colors": [ // {} // ], // "errorDetails": { // "errorCode": "sample string 1", // "message": "sample string 2" // }, // "isOverridingCompanyName": "sample string 4", // "isSendingDefault": "sample string 5", // "isSigningDefault": "sample string 6", // "landingPages": [ // {} // ], // "links": [ // { // "linkType": "sample string 1", // "urlOrMailTo": "sample string 2", // "linkText": "sample string 3", // "showLink": "sample string 4" // } // ], // "emailContent": [ // { // "emailContentType": "sample string 1", // "content": "sample string 2", // "emailToLink": "sample string 3", // "linkText": "sample string 4" // } // ], // "logos": { // "primary": "sample string 1", // "secondary": "sample string 2", // "email": "sample string 3" // }, // "resources": { // "email": "sample string 1", // "sending": "sample string 2", // "signing": "sample string 3", // "signingCaptive": "sample string 4" // } // } // ] // } // Sample code for parsing the JSON response... // Use the following online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON recipientBrandIdDefault := CkJsonObject__stringOf(json,'recipientBrandIdDefault'); senderBrandIdDefault := CkJsonObject__stringOf(json,'senderBrandIdDefault'); i := 0; count_i := CkJsonObject_SizeOfArray(json,'brands'); while i < count_i do begin CkJsonObject_putI(json,i); brandCompany := CkJsonObject__stringOf(json,'brands[i].brandCompany'); brandId := CkJsonObject__stringOf(json,'brands[i].brandId'); brandName := CkJsonObject__stringOf(json,'brands[i].brandName'); errorDetailsErrorCode := CkJsonObject__stringOf(json,'brands[i].errorDetails.errorCode'); errorDetailsMessage := CkJsonObject__stringOf(json,'brands[i].errorDetails.message'); isOverridingCompanyName := CkJsonObject__stringOf(json,'brands[i].isOverridingCompanyName'); isSendingDefault := CkJsonObject__stringOf(json,'brands[i].isSendingDefault'); isSigningDefault := CkJsonObject__stringOf(json,'brands[i].isSigningDefault'); logosPrimary := CkJsonObject__stringOf(json,'brands[i].logos.primary'); logosSecondary := CkJsonObject__stringOf(json,'brands[i].logos.secondary'); logosEmail := CkJsonObject__stringOf(json,'brands[i].logos.email'); resourcesEmail := CkJsonObject__stringOf(json,'brands[i].resources.email'); resourcesSending := CkJsonObject__stringOf(json,'brands[i].resources.sending'); resourcesSigning := CkJsonObject__stringOf(json,'brands[i].resources.signing'); resourcesSigningCaptive := CkJsonObject__stringOf(json,'brands[i].resources.signingCaptive'); j := 0; count_j := CkJsonObject_SizeOfArray(json,'brands[i].colors'); while j < count_j do begin CkJsonObject_putJ(json,j); j := j + 1; end; j := 0; count_j := CkJsonObject_SizeOfArray(json,'brands[i].landingPages'); while j < count_j do begin CkJsonObject_putJ(json,j); j := j + 1; end; j := 0; count_j := CkJsonObject_SizeOfArray(json,'brands[i].links'); while j < count_j do begin CkJsonObject_putJ(json,j); linkType := CkJsonObject__stringOf(json,'brands[i].links[j].linkType'); urlOrMailTo := CkJsonObject__stringOf(json,'brands[i].links[j].urlOrMailTo'); linkText := CkJsonObject__stringOf(json,'brands[i].links[j].linkText'); showLink := CkJsonObject__stringOf(json,'brands[i].links[j].showLink'); j := j + 1; end; j := 0; count_j := CkJsonObject_SizeOfArray(json,'brands[i].emailContent'); while j < count_j do begin CkJsonObject_putJ(json,j); emailContentType := CkJsonObject__stringOf(json,'brands[i].emailContent[j].emailContentType'); content := CkJsonObject__stringOf(json,'brands[i].emailContent[j].content'); emailToLink := CkJsonObject__stringOf(json,'brands[i].emailContent[j].emailToLink'); linkText := CkJsonObject__stringOf(json,'brands[i].emailContent[j].linkText'); j := j + 1; end; i := i + 1; end; CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(json); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.