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
(Unicode 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 <CkHttpW.h> #include <CkJsonObjectW.h> #include <CkStringBuilderW.h> void ChilkatSample(void) { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; bool success; // 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. CkJsonObjectW jsonToken; // Load a previously obtained OAuth2 access token. success = jsonToken.LoadFile(L"qa_data/tokens/docusign.json"); if (success == false) { wprintf(L"%s\n",jsonToken.lastErrorText()); return; } http.put_AuthToken(jsonToken.stringOf(L"access_token")); // Use an account ID obtained from DocuSign Get User Account Data CkStringBuilderW sbResponseBody; success = http.QuickGetSb(L"https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands",sbResponseBody); if (success == false) { wprintf(L"%s\n",http.lastErrorText()); return; } CkJsonObjectW json; json.LoadSb(sbResponseBody); json.put_EmitCompact(false); wprintf(L"Response Body:\n"); wprintf(L"%s\n",json.emit()); int respStatusCode = http.get_LastStatus(); wprintf(L"Response Status Code = %d\n",respStatusCode); if (respStatusCode >= 400) { wprintf(L"Response Header:\n"); wprintf(L"%s\n",http.lastHeader()); wprintf(L"Failed.\n"); 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. const wchar_t *brandCompany = 0; const wchar_t *brandId = 0; const wchar_t *brandName = 0; const wchar_t *errorDetailsErrorCode = 0; const wchar_t *errorDetailsMessage = 0; const wchar_t *isOverridingCompanyName = 0; const wchar_t *isSendingDefault = 0; const wchar_t *isSigningDefault = 0; const wchar_t *logosPrimary = 0; const wchar_t *logosSecondary = 0; const wchar_t *logosEmail = 0; const wchar_t *resourcesEmail = 0; const wchar_t *resourcesSending = 0; const wchar_t *resourcesSigning = 0; const wchar_t *resourcesSigningCaptive = 0; int j; int count_j; const wchar_t *linkType = 0; const wchar_t *urlOrMailTo = 0; const wchar_t *linkText = 0; const wchar_t *showLink = 0; const wchar_t *emailContentType = 0; const wchar_t *content = 0; const wchar_t *emailToLink = 0; const wchar_t *recipientBrandIdDefault = json.stringOf(L"recipientBrandIdDefault"); const wchar_t *senderBrandIdDefault = json.stringOf(L"senderBrandIdDefault"); int i = 0; int count_i = json.SizeOfArray(L"brands"); while (i < count_i) { json.put_I(i); brandCompany = json.stringOf(L"brands[i].brandCompany"); brandId = json.stringOf(L"brands[i].brandId"); brandName = json.stringOf(L"brands[i].brandName"); errorDetailsErrorCode = json.stringOf(L"brands[i].errorDetails.errorCode"); errorDetailsMessage = json.stringOf(L"brands[i].errorDetails.message"); isOverridingCompanyName = json.stringOf(L"brands[i].isOverridingCompanyName"); isSendingDefault = json.stringOf(L"brands[i].isSendingDefault"); isSigningDefault = json.stringOf(L"brands[i].isSigningDefault"); logosPrimary = json.stringOf(L"brands[i].logos.primary"); logosSecondary = json.stringOf(L"brands[i].logos.secondary"); logosEmail = json.stringOf(L"brands[i].logos.email"); resourcesEmail = json.stringOf(L"brands[i].resources.email"); resourcesSending = json.stringOf(L"brands[i].resources.sending"); resourcesSigning = json.stringOf(L"brands[i].resources.signing"); resourcesSigningCaptive = json.stringOf(L"brands[i].resources.signingCaptive"); j = 0; count_j = json.SizeOfArray(L"brands[i].colors"); while (j < count_j) { json.put_J(j); j = j + 1; } j = 0; count_j = json.SizeOfArray(L"brands[i].landingPages"); while (j < count_j) { json.put_J(j); j = j + 1; } j = 0; count_j = json.SizeOfArray(L"brands[i].links"); while (j < count_j) { json.put_J(j); linkType = json.stringOf(L"brands[i].links[j].linkType"); urlOrMailTo = json.stringOf(L"brands[i].links[j].urlOrMailTo"); linkText = json.stringOf(L"brands[i].links[j].linkText"); showLink = json.stringOf(L"brands[i].links[j].showLink"); j = j + 1; } j = 0; count_j = json.SizeOfArray(L"brands[i].emailContent"); while (j < count_j) { json.put_J(j); emailContentType = json.stringOf(L"brands[i].emailContent[j].emailContentType"); content = json.stringOf(L"brands[i].emailContent[j].content"); emailToLink = json.stringOf(L"brands[i].emailContent[j].emailToLink"); linkText = json.stringOf(L"brands[i].emailContent[j].linkText"); j = j + 1; } i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.