Lua
Lua
Isabel Connect Get Account
See more Ibanity Examples
Get the details for a specific account.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local 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.
local cert = chilkat.Cert.new()
local success = cert:load_from_file("qa_data/pem/my_ibanity_certificate.pem")
if not success then
print(cert.last_error_text)
return
end
local privKey = chilkat.PrivateKey.new()
success = privKey:load_encrypted_pem_file("qa_data/pem/my_ibanity_private_key.pem", "my_pem_password")
if not success then
print(privKey.last_error_text)
return
end
success = cert:set_private_key(privKey)
if not success then
print(cert.last_error_text)
return
end
success = http:set_ssl_client_cert(cert)
if not success then
print(http.last_error_text)
return
end
-- Load the previously obtained access token.
local jsonToken = chilkat.JsonObject.new()
success = jsonToken:load_file("qa_data/tokens/isabel_access_token.json")
if not success then
print("No existing access token.")
return
end
-- This causes the "Authorization: Bearer ***" header to be added to the HTTP request.
http.auth_token = jsonToken:string_of("access_token")
http.accept = "application/vnd.api+json"
http:set_url_var("id", "93ecb1fdbfb7848e7b7896c0f2d207aed3d8b4c1")
local jsonStr = http:quick_get_str("https://api.ibanity.com/isabel-connect/accounts/{$id}")
if not http.last_method_success then
print(http.last_error_text)
return
end
local jResp = chilkat.JsonObject.new()
jResp:load(jsonStr)
jResp.emit_compact = false
print("Response Body:")
print(jResp:emit())
local respStatusCode = http.last_status
print("Response Status Code = " .. respStatusCode)
if respStatusCode >= 400 then
print("Response Header:")
print(http.last_response_header)
print("Failed.")
return
end
-- 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
local dataAttributesCountry = jResp:string_of("data.attributes.country")
local dataAttributesCurrency = jResp:string_of("data.attributes.currency")
local dataAttributesDescription = jResp:string_of("data.attributes.description")
local dataAttributesFinancialInstitutionBic = jResp:string_of("data.attributes.financialInstitutionBic")
local dataAttributesHolderAddress = jResp:string_of("data.attributes.holderAddress")
local dataAttributesHolderAddressCountry = jResp:string_of("data.attributes.holderAddressCountry")
local dataAttributesHolderName = jResp:string_of("data.attributes.holderName")
local dataAttributesReference = jResp:string_of("data.attributes.reference")
local dataAttributesReferenceType = jResp:string_of("data.attributes.referenceType")
local dataId = jResp:string_of("data.id")
local dataType = jResp:string_of("data.type")