Class: NordigenOBClient
- Inherits:
-
Object
- Object
- NordigenOBClient
- Defined in:
- lib/nordigen_ob_client.rb
Instance Method Summary collapse
-
#create_requisition(redirect_url, selected_bank_id, reference) ⇒ Object
> Name: create_requisition.
-
#delete_requisition(requisition_id) ⇒ Object
> Name: delete_requisition.
-
#get_access_token(secret_id, secret_key) ⇒ Object
> Name: get_access_token.
-
#get_account_balances(account_id) ⇒ Object
> Name: get_account_balances.
-
#get_account_details(account_id) ⇒ Object
> Name: get_account_details.
-
#get_account_overview(account_id) ⇒ Object
> Name: get_account_overview.
-
#get_account_transactions(account_id) ⇒ Object
> Name: get_account_transactions.
-
#get_banks_by_country(country) ⇒ Object
> Name: get_banks_by_country.
-
#initialize ⇒ NordigenOBClient
constructor
A new instance of NordigenOBClient.
-
#list_accounts(requisition_id) ⇒ Object
> Name: list_accounts.
Constructor Details
#initialize ⇒ NordigenOBClient
Returns a new instance of NordigenOBClient.
6 7 |
# File 'lib/nordigen_ob_client.rb', line 6 def initialize end |
Instance Method Details
#create_requisition(redirect_url, selected_bank_id, reference) ⇒ Object
> Name: create_requisition
> Description: It creates a new requisition ID that will enable the user
to connect his bank accounts.
> Parameters: redirect_url: The URL to which the user will be redirected
after logging in to his bank environment.
selected_bank_id: The Nordigen ID of the bank the user
will be redirected.
reference: A unique user identifier that will associate
the user who will log in with the new requisition ID.
> Returns: The access token
224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/nordigen_ob_client.rb', line 224 def create_requisition redirect_url, selected_bank_id, reference request_body = { "redirect" => redirect_url, "institution_id" => selected_bank_id, "user_language" => "EN", "reference" => reference }.to_json response = RestClient.post( "https://ob.nordigen.com/api/v2/requisitions/", request_body, headers=@request_header) JSON.parse(response.body) end |
#delete_requisition(requisition_id) ⇒ Object
> Name: delete_requisition
> Description: It deletes the provided requisition ID.
> Parameters: requisition_id: The requisition to delete.
> Returns: The result of the operation
251 252 253 254 255 256 257 |
# File 'lib/nordigen_ob_client.rb', line 251 def delete_requisition requisition_id response = RestClient.delete( "https://ob.nordigen.com/api/v2/requisitions/#{requisition_id}", headers=@request_header) JSON.parse(response.body) response end |
#get_access_token(secret_id, secret_key) ⇒ Object
> Name: get_access_token
> Description: Retrieve the access token that will be used to access all
other endpoints in Nordigen's backend.
> Parameters: secret_id: The Secret ID part of the credentials,
provided by Nordigen.
secret_key: The Secret Key part of the credentials,
provided by Nordigen.
> Returns: The access token
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nordigen_ob_client.rb', line 25 def get_access_token secret_id, secret_key access_token_params = { "secret_id" => secret_id, "secret_key" => secret_key }.to_json response_json = RestClient.post("https://ob.nordigen.com/api/v2/token/new/", access_token_params, {content_type: :json, accept: :json}) response = JSON.parse(response_json.body) @access_token = response["access"] @request_header = { content_type: :json, accept: :json, authorization: "Bearer #{@access_token}" } @access_token end |
#get_account_balances(account_id) ⇒ Object
> Name: get_account_balances
> Description: Return’s the balances for the given account. The balances
can be more than one, since accounts allow overdraft or
might have frozen limits.
> Parameters: account_id: The id of the account (IBAN)
for which the balances will be returned.
> Returns: The details available for the account. They can vary from bank
to bank. The fields we see been returned always are:
- Balance amount
- Currency
- Type of balances
- Balance date
142 143 144 145 146 147 148 |
# File 'lib/nordigen_ob_client.rb', line 142 def get_account_balances account_id response = RestClient.get( "https://ob.nordigen.com/api/v2/accounts/#{account_id}/balances", headers=@request_header) accounts = JSON.parse(response.body) accounts end |
#get_account_details(account_id) ⇒ Object
> Name: get_account_details
> Description: Return’s all the information available for the account.
> Parameters: account_id: The id of the account (IBAN)
for which the information will be returned.
> Returns: The details available for the account. They can vary from bank
to bank. The fields we see been returned always are:
- IBAN
- Currency
- Owner Name
- Product / account type (e.g. Savings, holding, etc.)
- BIC
- Usage: Private / Bureau
113 114 115 116 117 118 119 |
# File 'lib/nordigen_ob_client.rb', line 113 def get_account_details account_id response = RestClient.get( "https://ob.nordigen.com/api/v2/accounts/#{account_id}/details", headers=@request_header) accounts = JSON.parse(response.body) accounts end |
#get_account_overview(account_id) ⇒ Object
> Name: get_account_overview
> Description: Return’s the basic information available for the account.
> Parameters: account_id: The id of the account (IBAN)
for which the information will be returned.
> Returns: A summaru available for the account. THe fields included are:
- IBAN
- Nordigen's institution ID
- Status: ready, inactive
- Owner's name
168 169 170 171 172 173 174 |
# File 'lib/nordigen_ob_client.rb', line 168 def get_account_overview account_id response = RestClient.get( "https://ob.nordigen.com/api/v2/accounts/#{account_id}", headers=@request_header) accounts = JSON.parse(response.body) accounts end |
#get_account_transactions(account_id) ⇒ Object
> Name: get_account_transactions
> Description: Return’s the account statement for the last 90 days.
> Parameters: account_id: The id of the account (IBAN)
for which the information will be returned.
> Returns: The list of transactions performed. THe fields included are:
- Booking date, when the transaction was logged on the account.
- Reference date, when it actually occured.
- Transaction amount
- Currency
- Debitor BIC
- Creditor BIC
196 197 198 199 200 201 202 |
# File 'lib/nordigen_ob_client.rb', line 196 def get_account_transactions account_id response = RestClient.get( "https://ob.nordigen.com/api/v2/accounts/#{account_id}/transactions", headers=@request_header) accounts = JSON.parse(response.body) accounts end |
#get_banks_by_country(country) ⇒ Object
> Name: get_banks_by_country
> Description: Returns a list of the available institutions by country,
including
> Parameters: country: The selected country, in ISO 3166 format.
Supported countries are EEA countries.
> Returns: The list of supported institutions in the selected country.
60 61 62 63 64 65 66 67 68 |
# File 'lib/nordigen_ob_client.rb', line 60 def get_banks_by_country country response = RestClient.get( "https://ob.nordigen.com/api/v2/institutions/?country=#{country}", headers=@request_header) available_banks = JSON.parse(response.body, :external_encoding => 'iso-8859-1') available_banks end |
#list_accounts(requisition_id) ⇒ Object
> Name: list_accounts
> Description: Return a list of the available accounts connected to the
given user account.
> Parameters: requisition_id: The id of the requisition (bank login)
for which the parameters will be parsed.
> Returns: The list of available accounts.
85 86 87 88 89 90 91 |
# File 'lib/nordigen_ob_client.rb', line 85 def list_accounts requisition_id response = RestClient.get( "https://ob.nordigen.com/api/v2/requisitions/#{requisition_id}", headers=@request_header) accounts = JSON.parse(response.body) accounts end |