Xbase++
Xbase++
Isabel Connect Get Account
See more Ibanity Examples
Get the details for a specific account.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL oCert
LOCAL oPrivKey
LOCAL oJsonToken
LOCAL cJsonStr
LOCAL oJResp
LOCAL nRespStatusCode
LOCAL cDataAttributesCountry
LOCAL cDataAttributesCurrency
LOCAL cDataAttributesDescription
LOCAL cDataAttributesFinancialInstitutionBic
LOCAL cDataAttributesHolderAddress
LOCAL cDataAttributesHolderAddressCountry
LOCAL cDataAttributesHolderName
LOCAL cDataAttributesReference
LOCAL cDataAttributesReferenceType
LOCAL cDataId
LOCAL cDataType
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// Implements the following CURL command:
// curl -X GET https://api.ibanity.com/isabel-connect/accounts/93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1 \
// --cert certificate.pem:qwertyuiop1 \
// --key private_key.pem \
// -H "Authorization: Bearer access_token_1603365407" \
// -H "Accept: application/vnd.api+json"
// Other Chilkat examples for Ibanity show how to set the SSL client certificate using the .pfx.
// This example will demonstrate using the PEM files.
oCert := CreateObject("Chilkat.Cert")
nSuccess := oCert:LoadFromFile("qa_data/pem/my_ibanity_certificate.pem")
IF (nSuccess == 0)
? oCert:LastErrorText
oHttp:destroy()
oCert:destroy()
RETURN
ENDIF
oPrivKey := CreateObject("Chilkat.PrivateKey")
nSuccess := oPrivKey:LoadEncryptedPemFile("qa_data/pem/my_ibanity_private_key.pem", "my_pem_password")
IF (nSuccess == 0)
? oPrivKey:LastErrorText
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
RETURN
ENDIF
nSuccess := oCert:SetPrivateKey(oPrivKey)
IF (nSuccess == 0)
? oCert:LastErrorText
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
RETURN
ENDIF
nSuccess := oHttp:SetSslClientCert(oCert)
IF (nSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
RETURN
ENDIF
// Load the previously obtained access token.
oJsonToken := CreateObject("Chilkat.JsonObject")
nSuccess := oJsonToken:LoadFile("qa_data/tokens/isabel_access_token.json")
IF (nSuccess == 0)
? "No existing access token."
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
oJsonToken:destroy()
RETURN
ENDIF
// This causes the "Authorization: Bearer ***" header to be added to the HTTP request.
oHttp:AuthToken := oJsonToken:StringOf("access_token")
oHttp:Accept := "application/vnd.api+json"
oHttp:SetUrlVar("id", "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1")
cJsonStr := oHttp:QuickGetStr("https://api.ibanity.com/isabel-connect/accounts/{$id}")
IF (oHttp:LastMethodSuccess == 0)
? oHttp:LastErrorText
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
oJsonToken:destroy()
RETURN
ENDIF
oJResp := CreateObject("Chilkat.JsonObject")
oJResp:Load(cJsonStr)
oJResp:EmitCompact := 0
? "Response Body:"
? oJResp:Emit()
nRespStatusCode := oHttp:LastStatus
? "Response Status Code = " + Str(nRespStatusCode)
IF (nRespStatusCode >= 400)
? "Response Header:"
? oHttp:LastResponseHeader
? "Failed."
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
oJsonToken:destroy()
oJResp:destroy()
RETURN
ENDIF
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "data": {
// "attributes": {
// "country": "BE",
// "currency": "EUR",
// "description": "current account",
// "financialInstitutionBic": "KREDBEBB",
// "holderAddress": "STREET NUMBER, ZIPCODE CITY",
// "holderAddressCountry": "BE",
// "holderName": "COMPANY",
// "reference": "BE96153112434405",
// "referenceType": "IBAN"
// },
// "id": "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1",
// "type": "account"
// }
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
cDataAttributesCountry := oJResp:StringOf("data.attributes.country")
cDataAttributesCurrency := oJResp:StringOf("data.attributes.currency")
cDataAttributesDescription := oJResp:StringOf("data.attributes.description")
cDataAttributesFinancialInstitutionBic := oJResp:StringOf("data.attributes.financialInstitutionBic")
cDataAttributesHolderAddress := oJResp:StringOf("data.attributes.holderAddress")
cDataAttributesHolderAddressCountry := oJResp:StringOf("data.attributes.holderAddressCountry")
cDataAttributesHolderName := oJResp:StringOf("data.attributes.holderName")
cDataAttributesReference := oJResp:StringOf("data.attributes.reference")
cDataAttributesReferenceType := oJResp:StringOf("data.attributes.referenceType")
cDataId := oJResp:StringOf("data.id")
cDataType := oJResp:StringOf("data.type")
oHttp:destroy()
oCert:destroy()
oPrivKey:destroy()
oJsonToken:destroy()
oJResp:destroy()