Module: Figo
- Included in:
- Connection, Session
- Defined in:
- lib/figo.rb,
lib/base.rb,
lib/bank/model.rb,
lib/task/model.rb,
lib/user/model.rb,
lib/account/model.rb,
lib/bank/api_call.rb,
lib/helpers/error.rb,
lib/helpers/https.rb,
lib/payment/model.rb,
lib/task/api_call.rb,
lib/user/api_call.rb,
lib/security/model.rb,
lib/account/api_call.rb,
lib/payment/api_call.rb,
lib/security/api_call.rb,
lib/transaction/model.rb,
lib/notification/model.rb,
lib/standing_order/model.rb,
lib/transaction/api_call.rb,
lib/account_balance/model.rb,
lib/notification/api_call.rb,
lib/standing_order/api_call.rb,
lib/account_balance/api_call.rb,
lib/authentification/api_call.rb,
lib/synchronization_status/model.rb,
lib/synchronization_status/api_call.rb
Overview
Ruby bindings for the figo Connect API: developer.figo.me
Defined Under Namespace
Classes: Account, AccountBalance, Bank, Base, Connection, Error, HTTPS, Notification, Payment, Security, Session, StandingOrder, SynchronizationStatus, TaskState, TaskToken, Transaction, User
Instance Method Summary collapse
-
#account_sort_order(accounts) ⇒ Object
Set bank account sort order.
-
#accounts ⇒ Array
Retrieve all accounts.
-
#add_account(country, credentials, bank_code, iban, save_pin) ⇒ Object
Add new bank account_sort_order.
-
#add_notification(notification) ⇒ Notification
Register a new notification.
-
#add_payment(payment) ⇒ Payment
Create new payment.
-
#cancel_task(task_token) ⇒ Object
Cancel a task.
-
#create_user(name, email, password, language = 'de', send_newsletter = true) ⇒ Hash
Create a new figo Account.
-
#credential_login(username, password, device_name = nil, device_type = nil, device_udid = nil, scope = nil) ⇒ Object
Return a Token dictionary which tokens are used for further API calls.
-
#delete_transaction(account_id, transaction_id) ⇒ Object
Delete transaction.
-
#find_bank(bank_code, country_code = "DE") ⇒ Hash
Get bank information from standard bank code.
-
#get_account(account_id) ⇒ Account
Retrieve specific account.
-
#get_account_balance(account_id) ⇒ AccountBalance
Retrieve balance of an account.
-
#get_account_standing_orders(account_id) ⇒ StandingOrder
Get all standing orders.
-
#get_bank(bank_id) ⇒ Bank
Retrieve specific bank.
-
#get_notification(notification_id) ⇒ Notification
Retrieve specific notification.
-
#get_payment(account_id, payment_id) ⇒ Payment
Retrieve specific payment.
-
#get_payment_proposals ⇒ Object
Retreive payment proposals.
-
#get_securities(options = nil) ⇒ Security
Retrieve securities of one or all accounts.
-
#get_security(account_id, security_id) ⇒ Security
Retrieve a security.
-
#get_standing_order(standing_order_id) ⇒ StandingOrder
Retreive a specific standing order.
-
#get_standing_orders ⇒ StandingOrder
Get all standing orders.
-
#get_supported_payment_services(country_code = "DE", service) ⇒ Object
Get supported services.
-
#get_sync_url(redirect_uri, state) ⇒ String
Retrieve the URL a user should open in the web browser to start the synchronization process.
-
#get_task_state(task, options) ⇒ TaskState
Poll the task progress.
-
#get_transaction(account_id, transaction_id) ⇒ Transaction
Retrieve a specific transaction.
-
#login_url(state, scope = nil) ⇒ String
Get the URL a user should open in the web browser to start the login process.
-
#modify_account(account) ⇒ Account
Modify specific account.
-
#modify_account_balance(account_id, account_balance) ⇒ AccountBalance
Modify balance or account limits.
-
#modify_bank(bank) ⇒ Bank
Modify bank.
-
#modify_notification(notification) ⇒ Notification
Modify notification.
-
#modify_payment(payment) ⇒ Payment
Modify payment.
-
#modify_securities(visited, account_id = nil) ⇒ Object
Modify securities of one or all accounts.
-
#modify_security(account_id, security_id, visited) ⇒ Object
Modify a security.
-
#modify_transaction(account_id, transaction_id, visited) ⇒ Object
Modify trasnaction.
-
#modify_transactions(visited, account_id = nil) ⇒ Object
Modify transactions.
-
#modify_user(user) ⇒ User
Modify the current user.
-
#notifications ⇒ Notification
Retrieve list of registered notifications.
-
#obtain_access_token(authorization_code_or_refresh_token, scope = nil) ⇒ Hash
Exchange authorization code or refresh token for access token.
-
#payments(account_id = nil) ⇒ Payment
Retrieve list of all payments (on all accounts or one).
-
#remove_account(account) ⇒ Object
Remove specific account.
-
#remove_bank_pin(bank) ⇒ nil
Remove stored PIN from bank.
-
#remove_notification(notification) ⇒ Object
Unregister notification.
-
#remove_payment(payment) ⇒ Object
Remove payment.
-
#remove_user ⇒ Object
Remove the current user Note: this has immidiate effect and you wont be able to interact with the user after this call.
-
#resend_verification ⇒ Object
Re-send verification email.
-
#revoke_token(refresh_token_or_access_token) ⇒ nil
Revoke refresh token or access token.
-
#start_task(task_token) ⇒ Object
Start communication with bank server.
-
#submit_payment(payment, tan_scheme_id, state, redirect_uri) ⇒ String
The result parameter is the URL to be opened by the user.
-
#sync_url(redirect_uri, state, if_not_synced_since = 0) ⇒ String
Retrieve the URL a user should open in the web browser to start the synchronization process.
-
#transactions(account_id = nil, since = nil, count = 1000, offset = 0, include_pending = false) ⇒ Array
Retrieve list of transactions (on all or a specific account).
-
#user ⇒ User
Retrieve current User.
Instance Method Details
#account_sort_order(accounts) ⇒ Object
Set bank account sort order
36 37 38 |
# File 'lib/account/api_call.rb', line 36 def account_sort_order (accounts) query_api "/rest/accounts", accounts, "PUT" end |
#accounts ⇒ Array
Retrieve all accounts
6 7 8 |
# File 'lib/account/api_call.rb', line 6 def accounts query_api_object Account, "/rest/accounts", nil, "GET", "accounts" end |
#add_account(country, credentials, bank_code, iban, save_pin) ⇒ Object
Add new bank account_sort_order
47 48 49 50 51 52 53 54 |
# File 'lib/account/api_call.rb', line 47 def add_account(country, credentials, bank_code, iban, save_pin) data = {"country" => country, "credentials" => credentials} data["iban"] = iban if (iban) data["bank_code"] = bank_code if(bank_code) data["save_pin"] = !!save_pin == save_pin ? save_pin : false query_api_object TaskToken, "/rest/accounts", data, "POST" end |
#add_notification(notification) ⇒ Notification
Register a new notification.
22 23 24 |
# File 'lib/notification/api_call.rb', line 22 def add_notification(notification) query_api_object Notification, "/rest/notifications", notification.dump(), "POST" end |
#add_payment(payment) ⇒ Payment
Create new payment
24 25 26 |
# File 'lib/payment/api_call.rb', line 24 def add_payment(payment) query_api_object Payment, "/rest/accounts/#{payment.account_id}/payments", payment.dump(), "POST" end |
#cancel_task(task_token) ⇒ Object
Cancel a task.
33 34 35 36 |
# File 'lib/task/api_call.rb', line 33 def cancel_task(task_token) ["id"] = task_token["task_token"] query_api_object TaskToken, "/task/cancel?id=" + task_token["task_token"], .to_query, "POST", nil end |
#create_user(name, email, password, language = 'de', send_newsletter = true) ⇒ Hash
Create a new figo Account
38 39 40 41 42 43 44 |
# File 'lib/user/api_call.rb', line 38 def create_user(name, email, password, language, =nil) = { name: name, email: email, password: password, send_newsletter: } ["language"] = language if (language) ["send_newsletter"] = !! == ? : nil query_api "/auth/user", end |
#credential_login(username, password, device_name = nil, device_type = nil, device_udid = nil, scope = nil) ⇒ Object
Return a Token dictionary which tokens are used for further API calls.
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/authentification/api_call.rb', line 77 def credential_login(username, password, device_name = nil, device_type = nil, device_udid = nil, scope = nil) = { grant_type: "password", username: username, password: password } [:device_name] = device_name if (device_name) [:device_type] = device_type if (device_type) [:device_udid] = device_udid if (device_udid) [:scope] = scope if (scope) query_api "/auth/token", end |
#delete_transaction(account_id, transaction_id) ⇒ Object
Delete transaction
54 55 56 |
# File 'lib/transaction/api_call.rb', line 54 def delete_transaction(account_id, transaction_id) query_api "/rest/accounts/" + account_id + "/transactions/" + transaction_id, nil, "DELETE" end |
#find_bank(bank_code, country_code = "DE") ⇒ Hash
Get bank information from standard bank code
31 32 33 |
# File 'lib/bank/api_call.rb', line 31 def find_bank(bank_code, country_code = "DE") query_api "/rest/catalog/banks/#{country_code}/#{bank_code}" end |
#get_account(account_id) ⇒ Account
Retrieve specific account.
14 15 16 |
# File 'lib/account/api_call.rb', line 14 def get_account(account_id) query_api_object Account, "/rest/accounts/#{account_id}" end |
#get_account_balance(account_id) ⇒ AccountBalance
Retrieve balance of an account.
6 7 8 |
# File 'lib/account_balance/api_call.rb', line 6 def get_account_balance(account_id) query_api_object AccountBalance, "/rest/accounts/#{account_id}/balance" end |
#get_account_standing_orders(account_id) ⇒ StandingOrder
Get all standing orders.
21 22 23 |
# File 'lib/standing_order/api_call.rb', line 21 def get_account_standing_orders(account_id) query_api_object StandingOrder, "/rest/accounts/#{account_id}/standing_orders", nil, "GET", "standing_orders" end |
#get_bank(bank_id) ⇒ Bank
Retrieve specific bank
6 7 8 |
# File 'lib/bank/api_call.rb', line 6 def get_bank(bank_id) query_api_object Bank, "/rest/banks/#{bank_id}" end |
#get_notification(notification_id) ⇒ Notification
Retrieve specific notification.
14 15 16 |
# File 'lib/notification/api_call.rb', line 14 def get_notification(notification_id) query_api_object Notification, "/rest/notifications/#{notification_id}" end |
#get_payment(account_id, payment_id) ⇒ Payment
Retrieve specific payment.
16 17 18 |
# File 'lib/payment/api_call.rb', line 16 def get_payment(account_id, payment_id) query_api_object Payment, "/rest/accounts/#{account_id}/payments/#{payment_id}" end |
#get_payment_proposals ⇒ Object
Retreive payment proposals
68 69 70 |
# File 'lib/payment/api_call.rb', line 68 def get_payment_proposals query_api "/rest/address_book", nil, "GET" end |
#get_securities(options = nil) ⇒ Security
Retrieve securities of one or all accounts.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/security/api_call.rb', line 24 def get_securities( = nil) ||= {} ["count"] ||= 1000 ["offset"] ||= 0 if(!["account_id"]) query_api_object Security, "/rest/securities?" + URI.encode_www_form(), nil, "GET", 'securities' else account_id = ["account_id"] .delete("account_id") query_api_object Security, "/rest/accounts/" + account_id + "/securities?" + URI.encode_www_form(), nil, "GET", "securities" end end |
#get_security(account_id, security_id) ⇒ Security
Retrieve a security.
10 11 12 |
# File 'lib/security/api_call.rb', line 10 def get_security(account_id, security_id) query_api_object Security, "/rest/accounts/" + account_id + "/securities/" + security_id, nil, "GET", nil end |
#get_standing_order(standing_order_id) ⇒ StandingOrder
Retreive a specific standing order.
7 8 9 |
# File 'lib/standing_order/api_call.rb', line 7 def get_standing_order(standing_order_id) query_api_object StandingOrder, "/rest/standing_orders/" + standing_order_id, nil, "GET", nil end |
#get_standing_orders ⇒ StandingOrder
Get all standing orders.
14 15 16 |
# File 'lib/standing_order/api_call.rb', line 14 def get_standing_orders() query_api_object StandingOrder, "/rest/standing_orders", nil, "GET", "standing_orders" end |
#get_supported_payment_services(country_code = "DE", service) ⇒ Object
Get supported services
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bank/api_call.rb', line 39 def get_supported_payment_services(country_code="DE", service) case service when "banks" query_api("/rest/catalog/banks/" + country_code, nil) when "service" query_api("/rest/catalog/services/" + country_code, nil) else query_api("/rest/catalog/" + country_code, nil) end end |
#get_sync_url(redirect_uri, state) ⇒ String
Retrieve the URL a user should open in the web browser to start the synchronization process.
8 9 10 11 12 |
# File 'lib/synchronization_status/api_call.rb', line 8 def get_sync_url(redirect_uri, state) res = query_api "/rest/sync", {redirect_uri: redirect_uri, state: state}.to_query, "POST" "https://" + Config.api_endpoint + "/task/start?id=" + res["task_token"] end |
#get_task_state(task, options) ⇒ TaskState
Poll the task progress.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/task/api_call.rb', line 19 def get_task_state(task, ) ||= {} ["id"] = task["task_token"] if (.pin) .save_pin ||= 0 end .continue ||= 0 query_api_object TaskState, "/task/progress?id=" + task.task_token, .to_query, "POST", nil end |
#get_transaction(account_id, transaction_id) ⇒ Transaction
Retrieve a specific transaction
25 26 27 |
# File 'lib/transaction/api_call.rb', line 25 def get_transaction(account_id, transaction_id) query_api_object Transaction, "/rest/accounts/#{account_id}/transactions/#{transaction_id}" end |
#login_url(state, scope = nil) ⇒ String
Get the URL a user should open in the web browser to start the login process.
When the process is completed, the user is redirected to the URL provided to the constructor and passes on an authentication code. This code can be converted into an access token for data access.
14 15 16 17 18 19 |
# File 'lib/authentification/api_call.rb', line 14 def login_url(state, scope = nil) data = { "response_type" => "code", "client_id" => @client_id, "state" => state } data["redirect_uri"] = @redirect_uri unless @redirect_uri.nil? data["scope"] = scope unless scope.nil? return "https://#{$api_endpoint}/auth/code?" + URI.encode_www_form(data) end |
#modify_account(account) ⇒ Account
Modify specific account
22 23 24 |
# File 'lib/account/api_call.rb', line 22 def modify_account(account) query_api_object Account, "/rest/accounts/#{account.account_id}", account.dump(), "PUT" end |
#modify_account_balance(account_id, account_balance) ⇒ AccountBalance
Modify balance or account limits
15 16 17 |
# File 'lib/account_balance/api_call.rb', line 15 def modify_account_balance(account_id, account_balance) query_api_object AccountBalance, "/rest/accounts/#{account_id}/balance", account_balance.dump(), "PUT" end |
#modify_bank(bank) ⇒ Bank
Modify bank
14 15 16 |
# File 'lib/bank/api_call.rb', line 14 def modify_bank(bank) query_api_object Bank, "/rest/banks/#{bank.bank_id}", bank.dump(), "PUT" end |
#modify_notification(notification) ⇒ Notification
Modify notification.
30 31 32 |
# File 'lib/notification/api_call.rb', line 30 def modify_notification(notification) query_api_object Notification, "/rest/notifications/#{notification.notification_id}", notification.dump(), "PUT" end |
#modify_payment(payment) ⇒ Payment
Modify payment
32 33 34 |
# File 'lib/payment/api_call.rb', line 32 def modify_payment(payment) query_api_object Payment, "/rest/accounts/#{payment.account_id}/payments/#{payment.payment_id}", payment.dump(), "PUT" end |
#modify_securities(visited, account_id = nil) ⇒ Object
Modify securities of one or all accounts.
51 52 53 54 55 56 57 58 |
# File 'lib/security/api_call.rb', line 51 def modify_securities (visited, account_id = nil) data = {visited: visited} if (account_id) query_api "/rest/accounts/" + account_id + "/securities", data, "PUT" else query_api "/rest/securities", data, "PUT" end end |
#modify_security(account_id, security_id, visited) ⇒ Object
Modify a security.
42 43 44 45 |
# File 'lib/security/api_call.rb', line 42 def modify_security (account_id, security_id, visited) data = {:visited => visited} query_api "/rest/accounts/" + account_id + "/securities/" + security_id, data, "PUT" end |
#modify_transaction(account_id, transaction_id, visited) ⇒ Object
Modify trasnaction
34 35 36 |
# File 'lib/transaction/api_call.rb', line 34 def modify_transaction(account_id, transaction_id, visited) query_api_object Transaction, "/rest/accounts/" + account_id + "/transactions/" + transaction_id, {"visited" => visited}, "PUT" end |
#modify_transactions(visited, account_id = nil) ⇒ Object
Modify transactions
42 43 44 45 46 47 48 |
# File 'lib/transaction/api_call.rb', line 42 def modify_transactions(visited, account_id = nil) if account_id query_api "/rest/accounts/" + account_id + "/transactions", {"visited" => visited}, "PUT" else query_api "/rest/transactions", {"visited" => visited}, "PUT" end end |
#modify_user(user) ⇒ User
Modify the current user
14 15 16 |
# File 'lib/user/api_call.rb', line 14 def modify_user(user) query_api_object User, "/rest/user", user.dump(), "PUT" end |
#notifications ⇒ Notification
Retrieve list of registered notifications.
6 7 8 |
# File 'lib/notification/api_call.rb', line 6 def notifications query_api_object Notification, "/rest/notifications", nil, "GET", "notifications" end |
#obtain_access_token(authorization_code_or_refresh_token, scope = nil) ⇒ Hash
Exchange authorization code or refresh token for access token.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/authentification/api_call.rb', line 30 def obtain_access_token(, scope = nil) # Authorization codes always start with "O" and refresh tokens always start with "R". if [0] == "O" data = { "grant_type" => "authorization_code", "code" => } data["redirect_uri"] = @redirect_uri unless @redirect_uri.nil? elsif [0] == "R" data = { "grant_type" => "refresh_token", "refresh_token" => } data["scope"] = scope unless scope.nil? end query_api "/auth/token", data end |
#payments(account_id = nil) ⇒ Payment
Retrieve list of all payments (on all accounts or one)
7 8 9 |
# File 'lib/payment/api_call.rb', line 7 def payments(account_id = nil) query_api_object Payment, account_id.nil? ? "/rest/payments" : "/rest/accounts/#{account_id}/payments", nil, "GET", "payments" end |
#remove_account(account) ⇒ Object
Remove specific account
29 30 31 |
# File 'lib/account/api_call.rb', line 29 def remove_account(account) query_api account.is_a?(String) ? "/rest/accounts/#{account}" : "/rest/accounts/#{account.account_id}", nil, "DELETE" end |
#remove_bank_pin(bank) ⇒ nil
Remove stored PIN from bank
22 23 24 |
# File 'lib/bank/api_call.rb', line 22 def remove_bank_pin(bank) query_api bank.is_a?(String) ? "/rest/banks/#{bank}/remove_pin" : "/rest/banks/#{bank.bank_id}/remove_pin", nil, "POST" end |
#remove_notification(notification) ⇒ Object
Unregister notification.
37 38 39 |
# File 'lib/notification/api_call.rb', line 37 def remove_notification(notification) query_api notification.is_a?(String) ? "/rest/notifications/#{notification}" : "/rest/notifications/#{notification.notification_id}", nil, "DELETE" end |
#remove_payment(payment) ⇒ Object
Remove payment
62 63 64 |
# File 'lib/payment/api_call.rb', line 62 def remove_payment(payment) query_api "/rest/accounts/#{payment.account_id}/payments/#{payment.payment_id}", nil, "DELETE" end |
#remove_user ⇒ Object
Remove the current user Note: this has immidiate effect and you wont be able to interact with the user after this call
21 22 23 |
# File 'lib/user/api_call.rb', line 21 def remove_user query_api "/rest/user", nil, "DELETE" end |
#resend_verification ⇒ Object
Re-send verification email
27 28 29 |
# File 'lib/user/api_call.rb', line 27 def resend_verification query_api "/rest/user/resend_verification", nil, "POST" end |
#revoke_token(refresh_token_or_access_token) ⇒ nil
this action has immediate effect, i.e. you will not be able use that token anymore after this call.
Revoke refresh token or access token.
48 49 50 51 |
# File 'lib/authentification/api_call.rb', line 48 def revoke_token(refresh_token_or_access_token) data = { "token" => refresh_token_or_access_token } query_api "/auth/revoke", data end |
#start_task(task_token) ⇒ Object
Start communication with bank server.
6 7 8 |
# File 'lib/task/api_call.rb', line 6 def start_task(task_token) query_api("/task/start?id=" + task_token.task_token, nil, "GET"); end |
#submit_payment(payment, tan_scheme_id, state, redirect_uri) ⇒ String
Returns The result parameter is the URL to be opened by the user.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/payment/api_call.rb', line 43 def submit_payment (payment, tan_scheme_id, state, redirect_uri) params = {tan_scheme_id: tan_scheme_id, state: state} if(redirect_uri) params["redirect_uri"] = redirect_uri; end res = query_api("/rest/accounts/" + payment.account_id + "/payments/" + payment.payment_id + "/submit", params, "POST") if(res.task_token) "https://" + Config.api_endpoint + "/task/start?id=" + result.task_token callback(error); else res end end |
#sync_url(redirect_uri, state, if_not_synced_since = 0) ⇒ String
Retrieve the URL a user should open in the web browser to start the synchronization process.
23 24 25 26 |
# File 'lib/synchronization_status/api_call.rb', line 23 def sync_url(redirect_uri, state, if_not_synced_since = 0) response = query_api "/rest/sync", {"redirect_uri" => redirect_uri, "state" => state, "if_not_synced_since" => if_not_synced_since}, "POST" return "https://#{$api_endpoint}/task/start?id=#{response["task_token"]}" end |
#transactions(account_id = nil, since = nil, count = 1000, offset = 0, include_pending = false) ⇒ Array
Retrieve list of transactions (on all or a specific account)
13 14 15 16 17 18 |
# File 'lib/transaction/api_call.rb', line 13 def transactions(account_id = nil, since = nil, count = 1000, offset = 0, include_pending = false) data = {"count" => count.to_s, "offset" => offset.to_s, "include_pending" => include_pending ? "1" : "0"} data["since"] = ((since.is_a?(Date) ? since.to_s : since) unless since.nil?) query_api_object Transaction, (account_id.nil? ? "/rest/transactions?" : "/rest/accounts/#{account_id}/transactions?") + URI.encode_www_form(data), nil, "GET", "transactions" end |
#user ⇒ User
Retrieve current User
6 7 8 |
# File 'lib/user/api_call.rb', line 6 def user query_api_object User, "/rest/user" end |