React Native
React Native
Docusign: Return Brand Data Associated with a User
See more DocuSign Examples
Demonstrates a call using an OAuth2 access token in combination with the account ID for which we have authorization.Chilkat React Native Downloads
import { Http, JsonObject, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new Http();
// 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.
const jsonToken = new JsonObject();
// Load a previously obtained OAuth2 access token.
try {
jsonToken.loadFile('qa_data/tokens/docusign.json');
} catch {
console.log(jsonToken.lastErrorText);
return;
}
http.authToken = jsonToken.stringOf('access_token');
// Use an account ID obtained from DocuSign Get User Account Data
const sbResponseBody = new StringBuilder();
try {
await http.quickGetSbAsync('https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands', sbResponseBody);
} catch {
console.log(http.lastErrorText);
return;
}
const json = new JsonObject();
json.loadSb(sbResponseBody);
json.emitCompact = false;
console.log('Response Body:');
console.log(json.emit());
const respStatusCode = http.lastStatus;
console.log(`Response Status Code = ${respStatusCode}`);
if (respStatusCode >= 400) {
console.log('Response Header:');
console.log(http.lastHeader);
console.log('Failed.');
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
let brandCompany = '';
let brandId = '';
let brandName = '';
let errorDetailsErrorCode = '';
let errorDetailsMessage = '';
let isOverridingCompanyName = '';
let isSendingDefault = '';
let isSigningDefault = '';
let logosPrimary = '';
let logosSecondary = '';
let logosEmail = '';
let resourcesEmail = '';
let resourcesSending = '';
let resourcesSigning = '';
let resourcesSigningCaptive = '';
let j = 0;
let countJ = 0;
let linkType = '';
let urlOrMailTo = '';
let linkText = '';
let showLink = '';
let emailContentType = '';
let content = '';
let emailToLink = '';
const recipientBrandIdDefault = json.stringOf('recipientBrandIdDefault');
const senderBrandIdDefault = json.stringOf('senderBrandIdDefault');
let i = 0;
const countI = json.sizeOfArray('brands');
while (i < countI) {
json.i = i;
brandCompany = json.stringOf('brands[i].brandCompany');
brandId = json.stringOf('brands[i].brandId');
brandName = json.stringOf('brands[i].brandName');
errorDetailsErrorCode = json.stringOf('brands[i].errorDetails.errorCode');
errorDetailsMessage = json.stringOf('brands[i].errorDetails.message');
isOverridingCompanyName = json.stringOf('brands[i].isOverridingCompanyName');
isSendingDefault = json.stringOf('brands[i].isSendingDefault');
isSigningDefault = json.stringOf('brands[i].isSigningDefault');
logosPrimary = json.stringOf('brands[i].logos.primary');
logosSecondary = json.stringOf('brands[i].logos.secondary');
logosEmail = json.stringOf('brands[i].logos.email');
resourcesEmail = json.stringOf('brands[i].resources.email');
resourcesSending = json.stringOf('brands[i].resources.sending');
resourcesSigning = json.stringOf('brands[i].resources.signing');
resourcesSigningCaptive = json.stringOf('brands[i].resources.signingCaptive');
j = 0;
countJ = json.sizeOfArray('brands[i].colors');
while (j < countJ) {
json.j = j;
j++;
}
j = 0;
countJ = json.sizeOfArray('brands[i].landingPages');
while (j < countJ) {
json.j = j;
j++;
}
j = 0;
countJ = json.sizeOfArray('brands[i].links');
while (j < countJ) {
json.j = j;
linkType = json.stringOf('brands[i].links[j].linkType');
urlOrMailTo = json.stringOf('brands[i].links[j].urlOrMailTo');
linkText = json.stringOf('brands[i].links[j].linkText');
showLink = json.stringOf('brands[i].links[j].showLink');
j++;
}
j = 0;
countJ = json.sizeOfArray('brands[i].emailContent');
while (j < countJ) {
json.j = j;
emailContentType = json.stringOf('brands[i].emailContent[j].emailContentType');
content = json.stringOf('brands[i].emailContent[j].content');
emailToLink = json.stringOf('brands[i].emailContent[j].emailToLink');
linkText = json.stringOf('brands[i].emailContent[j].linkText');
j++;
}
i++;
}
}