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
(C) 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
#include <C_CkHttp.h> #include <C_CkJsonObject.h> #include <C_CkStringBuilder.h> void ChilkatSample(void) { HCkHttp http; BOOL success; HCkJsonObject jsonToken; HCkStringBuilder sbResponseBody; HCkJsonObject json; int respStatusCode; const char *brandCompany; const char *brandId; const char *brandName; const char *errorDetailsErrorCode; const char *errorDetailsMessage; const char *isOverridingCompanyName; const char *isSendingDefault; const char *isSigningDefault; const char *logosPrimary; const char *logosSecondary; const char *logosEmail; const char *resourcesEmail; const char *resourcesSending; const char *resourcesSigning; const char *resourcesSigningCaptive; int j; int count_j; const char *linkType; const char *urlOrMailTo; const char *linkText; const char *showLink; const char *emailContentType; const char *content; const char *emailToLink; const char *recipientBrandIdDefault; const char *senderBrandIdDefault; int i; int count_i; // 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) { printf("%s\n",CkJsonObject_lastErrorText(jsonToken)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); return; } 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) { printf("%s\n",CkHttp_lastErrorText(http)); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); return; } json = CkJsonObject_Create(); CkJsonObject_LoadSb(json,sbResponseBody); CkJsonObject_putEmitCompact(json,FALSE); printf("Response Body:\n"); printf("%s\n",CkJsonObject_emit(json)); respStatusCode = CkHttp_getLastStatus(http); printf("Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { printf("Response Header:\n"); printf("%s\n",CkHttp_lastHeader(http)); printf("Failed.\n"); CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(json); return; } // 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 // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. recipientBrandIdDefault = CkJsonObject_stringOf(json,"recipientBrandIdDefault"); senderBrandIdDefault = CkJsonObject_stringOf(json,"senderBrandIdDefault"); i = 0; count_i = CkJsonObject_SizeOfArray(json,"brands"); while (i < count_i) { 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) { CkJsonObject_putJ(json,j); j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(json,"brands[i].landingPages"); while (j < count_j) { CkJsonObject_putJ(json,j); j = j + 1; } j = 0; count_j = CkJsonObject_SizeOfArray(json,"brands[i].links"); while (j < count_j) { 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; } j = 0; count_j = CkJsonObject_SizeOfArray(json,"brands[i].emailContent"); while (j < count_j) { 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; } i = i + 1; } CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.