React Native
React Native
Isabel Connect Get Account
See more Ibanity Examples
Get the details for a specific account.Chilkat React Native Downloads
import { Cert, Http, JsonObject, PrivateKey } 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 -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.
const cert = new Cert();
try {
cert.loadFromFile('qa_data/pem/my_ibanity_certificate.pem');
} catch {
console.log(cert.lastErrorText);
return;
}
const privKey = new PrivateKey();
try {
privKey.loadEncryptedPemFile('qa_data/pem/my_ibanity_private_key.pem', 'my_pem_password');
} catch {
console.log(privKey.lastErrorText);
return;
}
try {
cert.setPrivateKey(privKey);
} catch {
console.log(cert.lastErrorText);
return;
}
try {
http.setSslClientCert(cert);
} catch {
console.log(http.lastErrorText);
return;
}
// Load the previously obtained access token.
const jsonToken = new JsonObject();
try {
jsonToken.loadFile('qa_data/tokens/isabel_access_token.json');
} catch {
console.log('No existing access token.');
return;
}
// This causes the "Authorization: Bearer ***" header to be added to the HTTP request.
http.authToken = jsonToken.stringOf('access_token');
http.accept = 'application/vnd.api+json';
http.setUrlVar('id', '93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1');
let jsonStr: string;
try {
jsonStr = await http.quickGetStrAsync('https://api.ibanity.com/isabel-connect/accounts/{$id}');
} catch {
console.log(http.lastErrorText);
return;
}
const jResp = new JsonObject();
jResp.load(jsonStr);
jResp.emitCompact = false;
console.log('Response Body:');
console.log(jResp.emit());
const respStatusCode = http.lastStatus;
console.log(`Response Status Code = ${respStatusCode}`);
if (respStatusCode >= 400) {
console.log('Response Header:');
console.log(http.lastResponseHeader);
console.log('Failed.');
return;
}
// 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
const dataAttributesCountry = jResp.stringOf('data.attributes.country');
const dataAttributesCurrency = jResp.stringOf('data.attributes.currency');
const dataAttributesDescription = jResp.stringOf('data.attributes.description');
const dataAttributesFinancialInstitutionBic = jResp.stringOf('data.attributes.financialInstitutionBic');
const dataAttributesHolderAddress = jResp.stringOf('data.attributes.holderAddress');
const dataAttributesHolderAddressCountry = jResp.stringOf('data.attributes.holderAddressCountry');
const dataAttributesHolderName = jResp.stringOf('data.attributes.holderName');
const dataAttributesReference = jResp.stringOf('data.attributes.reference');
const dataAttributesReferenceType = jResp.stringOf('data.attributes.referenceType');
const dataId = jResp.stringOf('data.id');
const dataType = jResp.stringOf('data.type');
}