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
(Swift 3,4,5...) 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
func chilkatTest() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let http = CkoHttp()! var success: Bool // 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. let jsonToken = CkoJsonObject()! // Load a previously obtained OAuth2 access token. success = jsonToken.loadFile("qa_data/tokens/docusign.json") if success == false { print("\(jsonToken.lastErrorText!)") return } http.authToken = jsonToken.string(of: "access_token") // Use an account ID obtained from DocuSign Get User Account Data let sbResponseBody = CkoStringBuilder()! success = http.quickGetSb("https://account-d.docusign.com/restapi/v2/accounts/18b4799a-xxxx-xxxx-xxxx-b5b4b8a97604/brands", sbContent: sbResponseBody) if success == false { print("\(http.lastErrorText!)") return } let json = CkoJsonObject()! json.loadSb(sbResponseBody) json.emitCompact = false print("Response Body:") print("\(json.emit()!)") var respStatusCode: Int = http.lastStatus.intValue print("Response Status Code = \(respStatusCode)") if respStatusCode >= 400 { print("Response Header:") print("\(http.lastHeader!)") print("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 var brandCompany: String? var brandId: String? var brandName: String? var errorDetailsErrorCode: String? var errorDetailsMessage: String? var isOverridingCompanyName: String? var isSendingDefault: String? var isSigningDefault: String? var logosPrimary: String? var logosSecondary: String? var logosEmail: String? var resourcesEmail: String? var resourcesSending: String? var resourcesSigning: String? var resourcesSigningCaptive: String? var j: Int var count_j: Int var linkType: String? var urlOrMailTo: String? var linkText: String? var showLink: String? var emailContentType: String? var content: String? var emailToLink: String? var recipientBrandIdDefault: String? = json.string(of: "recipientBrandIdDefault") var senderBrandIdDefault: String? = json.string(of: "senderBrandIdDefault") var i: Int = 0 var count_i: Int = json.size(ofArray: "brands").intValue while i < count_i { json.i = i brandCompany = json.string(of: "brands[i].brandCompany") brandId = json.string(of: "brands[i].brandId") brandName = json.string(of: "brands[i].brandName") errorDetailsErrorCode = json.string(of: "brands[i].errorDetails.errorCode") errorDetailsMessage = json.string(of: "brands[i].errorDetails.message") isOverridingCompanyName = json.string(of: "brands[i].isOverridingCompanyName") isSendingDefault = json.string(of: "brands[i].isSendingDefault") isSigningDefault = json.string(of: "brands[i].isSigningDefault") logosPrimary = json.string(of: "brands[i].logos.primary") logosSecondary = json.string(of: "brands[i].logos.secondary") logosEmail = json.string(of: "brands[i].logos.email") resourcesEmail = json.string(of: "brands[i].resources.email") resourcesSending = json.string(of: "brands[i].resources.sending") resourcesSigning = json.string(of: "brands[i].resources.signing") resourcesSigningCaptive = json.string(of: "brands[i].resources.signingCaptive") j = 0 count_j = json.size(ofArray: "brands[i].colors").intValue while j < count_j { json.j = j j = j + 1 } j = 0 count_j = json.size(ofArray: "brands[i].landingPages").intValue while j < count_j { json.j = j j = j + 1 } j = 0 count_j = json.size(ofArray: "brands[i].links").intValue while j < count_j { json.j = j linkType = json.string(of: "brands[i].links[j].linkType") urlOrMailTo = json.string(of: "brands[i].links[j].urlOrMailTo") linkText = json.string(of: "brands[i].links[j].linkText") showLink = json.string(of: "brands[i].links[j].showLink") j = j + 1 } j = 0 count_j = json.size(ofArray: "brands[i].emailContent").intValue while j < count_j { json.j = j emailContentType = json.string(of: "brands[i].emailContent[j].emailContentType") content = json.string(of: "brands[i].emailContent[j].content") emailToLink = json.string(of: "brands[i].emailContent[j].emailToLink") linkText = json.string(of: "brands[i].emailContent[j].linkText") j = j + 1 } i = i + 1 } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.