Sample code for 30+ languages & platforms
Rust

Isabel Connect Get Account

See more Ibanity Examples

Get the details for a specific account.

Chilkat Rust Downloads

Rust

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let http = chilkat::Http::new();

// 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.
let cert = chilkat::Cert::new();
if cert.load_from_file("qa_data/pem/my_ibanity_certificate.pem").is_err() {
    println!("{}", cert.last_error_text());
    return;
}

let priv_key = chilkat::PrivateKey::new();
if priv_key.load_encrypted_pem_file("qa_data/pem/my_ibanity_private_key.pem", "my_pem_password").is_err() {
    println!("{}", priv_key.last_error_text());
    return;
}

if cert.set_private_key(&priv_key).is_err() {
    println!("{}", cert.last_error_text());
    return;
}

if http.set_ssl_client_cert(&cert).is_err() {
    println!("{}", http.last_error_text());
    return;
}

// Load the previously obtained access token.
let json_token = chilkat::JsonObject::new();
if json_token.load_file("qa_data/tokens/isabel_access_token.json").is_err() {
    println!("No existing access token.");
    return;
}

// This causes the "Authorization: Bearer ***" header to be added to the HTTP request.
http.set_auth_token(&json_token.string_of("access_token").unwrap_or_default());

http.set_accept("application/vnd.api+json");

let _ = http.set_url_var("id", "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1");
let Ok(json_str) = http.quick_get_str("https://api.ibanity.com/isabel-connect/accounts/{$id}") else {
    println!("{}", http.last_error_text());
    return;
};

let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load(&json_str);
j_resp.set_emit_compact(false);

println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());

let resp_status_code = http.last_status();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", http.last_response_header());
    println!("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

let data_attributes_country = j_resp.string_of("data.attributes.country").unwrap_or_default();
let data_attributes_currency = j_resp.string_of("data.attributes.currency").unwrap_or_default();
let data_attributes_description = j_resp.string_of("data.attributes.description").unwrap_or_default();
let data_attributes_financial_institution_bic = j_resp.string_of("data.attributes.financialInstitutionBic").unwrap_or_default();
let data_attributes_holder_address = j_resp.string_of("data.attributes.holderAddress").unwrap_or_default();
let data_attributes_holder_address_country = j_resp.string_of("data.attributes.holderAddressCountry").unwrap_or_default();
let data_attributes_holder_name = j_resp.string_of("data.attributes.holderName").unwrap_or_default();
let data_attributes_reference = j_resp.string_of("data.attributes.reference").unwrap_or_default();
let data_attributes_reference_type = j_resp.string_of("data.attributes.referenceType").unwrap_or_default();
let data_id = j_resp.string_of("data.id").unwrap_or_default();
let data_type = j_resp.string_of("data.type").unwrap_or_default();