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

Instance Method Details

#account_sort_order(accounts) ⇒ Object

Set bank account sort order

Parameters:

  • accounts (Array)

    List of JSON objects with the field account_id set to the internal figo Connect account ID (the accounts will be sorted in the list order)



36
37
38
# File 'lib/account/api_call.rb', line 36

def  (accounts)
  query_api "/rest/accounts", accounts, "PUT"
end

#accountsArray

Retrieve all accounts

Returns:

  • (Array)

    an array of ‘Account` objects, one for each account the user has granted the app access



6
7
8
# File 'lib/account/api_call.rb', line 6

def accounts
  query_api_object , "/rest/accounts", nil, "GET", "accounts"
end

#add_account(country, credentials, bank_code, iban, save_pin) ⇒ Object

Add new bank account_sort_order

Parameters:

  • country_code (String)

    Two-letter country code

  • credentials (Array)

    List of login credential strings

  • bank_code (String)

    Bank code (will be overriden if IBAN is present)

  • iban (String)

    IBAN

  • save_pon (Boolean)

    This flag indicates whether the user has chosen to save the PIN on the figo Connect server



47
48
49
50
51
52
53
54
# File 'lib/account/api_call.rb', line 47

def (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.

Parameters:

  • notification (Notification)

    notification to be crated. It should not have a notification_id set.

Returns:



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

Parameters:

  • payment (Payment)

    payment object to be created. It should not have a payment_id set.

Returns:

  • (Payment)

    newly created ‘Payment` object



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.

Parameters:

  • task_token (Object)

    Task token object



33
34
35
36
# File 'lib/task/api_call.rb', line 33

def cancel_task(task_token)
  options["id"] = task_token["task_token"]
  query_api_object TaskToken, "/task/cancel?id=" + task_token["task_token"], options.to_query, "POST", nil
end

#create_user(name, email, password, language = 'de', send_newsletter = true) ⇒ Hash

Create a new figo Account

Parameters:

  • name (String)

    First and last name

  • email (String)

    Email address; It must obey the figo username & password policy

  • password (String)

    New figo Account password; It must obey the figo username & password policy

  • language (String) (defaults to: 'de')

    Two-letter code of preferred language

  • send_newsletter (Boolean) (defaults to: true)

    This flag indicates whether the user has agreed to be contacted by email – Not accepted by backend at the moment

Returns:

  • (Hash)

    object with the key ‘recovery_password` as documented in the figo Connect API specification



38
39
40
41
42
43
44
# File 'lib/user/api_call.rb', line 38

def create_user(name, email, password, language, send_newsletter=nil)
  options = { name: name, email: email, password: password, send_newsletter: send_newsletter }
  options["language"] = language if (language)
  options["send_newsletter"] = !!send_newsletter == send_newsletter ? send_newsletter : nil

  query_api "/auth/user", options
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.

Parameters:

  • username (String)

    figo username

  • password (String)

    figo password

Returns:

  • The result parameter is an object with the keys ‘access_token`, `token_type`, `expires_in`, `refresh_token` and `scope` as documented in the figo Connect API specification.



77
78
79
80
81
82
83
84
85
86
# File 'lib/authentification/api_call.rb', line 77

def (username, password, device_name = nil, device_type = nil, device_udid = nil, scope = nil)
  options = { grant_type: "password", username: username, password: password }

  options[:device_name] = device_name if (device_name)
  options[:device_type] = device_type if (device_type)
  options[:device_udid] = device_udid if (device_udid)
  options[:scope] = scope if (scope)

  query_api "/auth/token", options
end

#delete_transaction(account_id, transaction_id) ⇒ Object

Delete transaction

Parameters:

  • account_id (String)

    ID of an account the transaction belongs to

  • transaction_id (String)

    ID of transaction to be deleted



54
55
56
# File 'lib/transaction/api_call.rb', line 54

def delete_transaction(, transaction_id)
  query_api "/rest/accounts/" +  + "/transactions/" + transaction_id, nil, "DELETE"
end

#find_bank(bank_code, country_code = "DE") ⇒ Hash

Get bank information from standard bank code

Parameters:

  • country_code (String) (defaults to: "DE")
  • bank_code (String)

    bank sort code (Bankleitzahl)

Returns:

  • (Hash)

    JSON response



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.

Parameters:

  • account_id (String)

    ID of the account to be retrieved.

Returns:



14
15
16
# File 'lib/account/api_call.rb', line 14

def ()
  query_api_object , "/rest/accounts/#{account_id}"
end

#get_account_balance(account_id) ⇒ AccountBalance

Retrieve balance of an account.

Returns:



6
7
8
# File 'lib/account_balance/api_call.rb', line 6

def ()
  query_api_object AccountBalance, "/rest/accounts/#{account_id}/balance"
end

#get_account_standing_orders(account_id) ⇒ StandingOrder

Get all standing orders.

Parameters:

  • account_id (Boolean)
    • ID of account to standing order

Returns:



21
22
23
# File 'lib/standing_order/api_call.rb', line 21

def ()
  query_api_object StandingOrder, "/rest/accounts/#{account_id}/standing_orders", nil, "GET", "standing_orders"
end

#get_bank(bank_id) ⇒ Bank

Retrieve specific bank

Returns:

  • (Bank)

    bank object



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.

Parameters:

  • notification_id (String)

    ID of the notification to be retrieved

Returns:

  • (Notification)

    ‘Notification` object for the respective 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.

Parameters:

  • account_id (String)

    ID for the account on which the payment to be retrieved was created

  • payment_id (String)

    ID of the notification to be retrieved

Returns:

  • (Payment)

    ‘Payment` object for the respective payment



16
17
18
# File 'lib/payment/api_call.rb', line 16

def get_payment(, payment_id)
  query_api_object Payment, "/rest/accounts/#{account_id}/payments/#{payment_id}"
end

#get_payment_proposalsObject

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.

Parameters:

  • options (Object) (defaults to: nil)
    • further options (all are optional)

    @param options.account_id [String] - ID of the account for which to retrieve the securities @param options.accounts [Array] - filter the securities to be only from these accounts @param options.since [Date] - ISO date filtering the returned securities by their creation or last modification date @param options.since_type [String] - defines hot the ‘since` will be interpreted: `traded`, `created` or `modified` @param options.count [Number] - limit the number of returned transactions @param options.offset [Number] - offset into the implicit list of transactions

Returns:

  • (Security)
    • An array of ‘Security` objects.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/security/api_call.rb', line 24

def get_securities(options = nil)
  options ||= {}
  options["count"] ||= 1000
  options["offset"] ||= 0
  if(!options["account_id"])
    query_api_object Security, "/rest/securities?" +  URI.encode_www_form(options), nil, "GET", 'securities'
  else
     = options["account_id"]
    options.delete("account_id")
    query_api_object Security, "/rest/accounts/" +  + "/securities?" + URI.encode_www_form(options), nil, "GET", "securities"
  end
end

#get_security(account_id, security_id) ⇒ Security

Retrieve a security.

Parameters:

  • account_id (String)
    • ID of the account the security belongs to

  • security_id (String)
    • ID of the security to retrieve

Returns:

  • (Security)
    • A single security object.



10
11
12
# File 'lib/security/api_call.rb', line 10

def get_security(, security_id)
  query_api_object Security, "/rest/accounts/" +  + "/securities/" + security_id, nil, "GET", nil
end

#get_standing_order(standing_order_id) ⇒ StandingOrder

Retreive a specific standing order.

Parameters:

  • standing_order_id (String)
    • ID of standing order to retreive

  • cents (Boolean)
    • whether to show the balance in cents (optional)

Returns:



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_ordersStandingOrder

Get all standing orders.

Parameters:

  • cents (Boolean)
    • whether to show the balance in cents (optional)

Returns:



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

Parameters:

  • country_code (String) (defaults to: "DE")

    the country code the service comes from

  • service (String)

    filter the type of service to request (optional): ‘banks`, `services` or everything (default)



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.

Parameters:

  • redirect_uri (String)

    The user will be redirected to this URL after the sync process completes.

  • state (String)

    This string will be passed on through the complete synchronization process

Returns:

  • (String)

    The result parameter is the URL to be opened by the user.



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.

Parameters:

  • task (Object)
    • Task object

  • options (Object)
    • further options (optional)

    @param options.pin [Boolean] - submit PIN @param options.continue [Boolean] - this flag signals to continue after an error condition or to skip a PIN or challenge-response entry @param options.save_pin [Boolean] - this flag indicates whether the user has chosen to save the PIN on the figo Connect server @param options.response [Boolean] - submit response to challenge

Returns:

  • (TaskState)

    The result parameter is a TaskState object which represents the current status of the task.



19
20
21
22
23
24
25
26
27
28
# File 'lib/task/api_call.rb', line 19

def get_task_state(task, options)
  options ||= {}
  options["id"] = task["task_token"]
  if (options.pin)
    options.save_pin ||= 0
  end
  options.continue ||= 0

  query_api_object TaskState, "/task/progress?id=" + task.task_token, options.to_query, "POST", nil
end

#get_transaction(account_id, transaction_id) ⇒ Transaction

Retrieve a specific transaction

Parameters:

  • account_id (String)

    ID of the account on which the transaction occured

  • transaction_id (String)

    ID of the transaction to be retrieved

Returns:



25
26
27
# File 'lib/transaction/api_call.rb', line 25

def get_transaction(, 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.

Parameters:

  • state (String)

    this string will be passed on through the complete login process and to the redirect target at the end. It should be used to validated the authenticity of the call to the redirect URL

  • scope (String) (defaults to: nil)

    optional scope of data access to ask the user for, e.g. ‘accounts=ro`

Returns:

  • (String)

    the URL to be opened by the user.



14
15
16
17
18
19
# File 'lib/authentification/api_call.rb', line 14

def (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

Parameters:

  • account (Account)

    modified account to be saved

Returns:

  • (Account)

    modified account returned by the server



22
23
24
# File 'lib/account/api_call.rb', line 22

def ()
  query_api_object , "/rest/accounts/#{account.account_id}", .dump(), "PUT"
end

#modify_account_balance(account_id, account_balance) ⇒ AccountBalance

Modify balance or account limits

Parameters:

  • account_id (String)

    ID of the account which balance should be modified

  • account_balance (AccountBalance)

    modified AccountBalance to be saved

Returns:



15
16
17
# File 'lib/account_balance/api_call.rb', line 15

def (, )
  query_api_object AccountBalance, "/rest/accounts/#{account_id}/balance", .dump(), "PUT"
end

#modify_bank(bank) ⇒ Bank

Modify bank

Parameters:

  • bank (Bank)

    modified bank object

Returns:

  • (Bank)

    modified bank object returned by server



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.

Parameters:

  • notification (Notification)

    modified notification object

Returns:

  • (Notification)

    modified notification returned by server



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

Parameters:

  • payment (Payment)

    modified payment object

Returns:

  • (Payment)

    modified payment object



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.

Parameters:

  • visited (Boolean)
    • a bit showing whether the user has already seen these securities or not

  • account_id (String) (defaults to: nil)
    • ID of the account securities belongs to (optional)



51
52
53
54
55
56
57
58
# File 'lib/security/api_call.rb', line 51

def modify_securities (visited,  = nil)
  data = {visited: visited}
  if ()
    query_api "/rest/accounts/" +  + "/securities", data, "PUT"
  else
    query_api "/rest/securities", data, "PUT"
  end
end

#modify_security(account_id, security_id, visited) ⇒ Object

Modify a security.

Parameters:

  • account_id (String)
    • ID of the account the security belongs to

  • security_id (String)
    • ID of the security to change

  • visited (Boolean)
    • a bit showing whether the user has already seen this security or not



42
43
44
45
# File 'lib/security/api_call.rb', line 42

def modify_security (, security_id, visited)
  data = {:visited => visited}
  query_api "/rest/accounts/" +  + "/securities/" + security_id, data, "PUT"
end

#modify_transaction(account_id, transaction_id, visited) ⇒ Object

Modify trasnaction

Parameters:

  • account_id (String)

    ID of an account the transaction belongs to

  • transaction_id (String)

    ID of the transaction

  • visited (Boolean)

    a bit showing whether the user has already seen this transaction or not



34
35
36
# File 'lib/transaction/api_call.rb', line 34

def modify_transaction(, transaction_id, visited)
  query_api_object Transaction, "/rest/accounts/" +  + "/transactions/" + transaction_id, {"visited" => visited}, "PUT"
end

#modify_transactions(visited, account_id = nil) ⇒ Object

Modify transactions

Parameters:

  • visited (Boolean)

    a bit showing whether the user has already seen this transaction or not

  • account_id (String) (defaults to: nil)

    ID of the account transactions belongs to (optional)



42
43
44
45
46
47
48
# File 'lib/transaction/api_call.rb', line 42

def modify_transactions(visited,  = nil)
  if 
    query_api "/rest/accounts/" +  + "/transactions", {"visited" => visited}, "PUT"
  else
    query_api "/rest/transactions", {"visited" => visited}, "PUT"
  end
end

#modify_user(user) ⇒ User

Modify the current user

Parameters:

  • user (User)

    the modified user object to be saved

Returns:

  • (User)

    the modified user returned



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

#notificationsNotification

Retrieve list of registered notifications.

Returns:

  • (Notification)

    an array of ‘Notification` objects, one for each registered notification



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.

Parameters:

  • authorization_code_or_refresh_token (String)

    either the authorization code received as part of the call to the redirect URL at the end of the logon process, or a refresh token

  • scope (String) (defaults to: nil)

    optional scope of data access to ask the user for, e.g. ‘accounts=ro`

Returns:

  • (Hash)

    object with the keys ‘access_token`, `refresh_token` and `expires`, as documented in the figo Connect API specification.



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/authentification/api_call.rb', line 30

def obtain_access_token(authorization_code_or_refresh_token, scope = nil)
  # Authorization codes always start with "O" and refresh tokens always start with "R".
  if authorization_code_or_refresh_token[0] == "O"
    data = { "grant_type" => "authorization_code", "code" => authorization_code_or_refresh_token }
    data["redirect_uri"] = @redirect_uri unless @redirect_uri.nil?
  elsif authorization_code_or_refresh_token[0] == "R"
    data = { "grant_type" => "refresh_token", "refresh_token" => authorization_code_or_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)

Parameters:

  • account_id (String) (defaults to: nil)

    ID of the account for whicht to list the payments

Returns:

  • (Payment)

    an array of ‘Payment` objects, one for each payment



7
8
9
# File 'lib/payment/api_call.rb', line 7

def payments( = nil)
  query_api_object Payment, .nil? ? "/rest/payments" : "/rest/accounts/#{account_id}/payments", nil, "GET", "payments"
end

#remove_account(account) ⇒ Object

Remove specific account

Parameters:

  • account (Account, String)

    the account to be removed or its ID



29
30
31
# File 'lib/account/api_call.rb', line 29

def ()
  query_api .is_a?(String) ? "/rest/accounts/#{account}" : "/rest/accounts/#{account.account_id}", nil, "DELETE"
end

#remove_bank_pin(bank) ⇒ nil

Remove stored PIN from bank

Parameters:

  • bank (Bank, String)

    the bank whose stored PIN should be removed or its ID

Returns:

  • (nil)


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.

Parameters:

  • notification (Notification, String)

    notification object which should be deleted or its ID



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

Parameters:

  • payment (Payment, String)

    payment object which should be removed



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_userObject

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_verificationObject

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

Note:

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.

Parameters:

  • refresh_token_or_access_token (String)

    access or refresh token to be revoked

Returns:

  • (nil)


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.

Parameters:

  • task_token (Object)

    Task token object from the initial request



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.

Parameters:

  • payment (Payment)

    payment to be submitted

  • tan_scheme_id (String)

    TAN scheme ID of user-selected TAN scheme

  • state (String)

    Any kind of string that will be forwarded in the callback response message

  • redirect_uri (String)

    At the end of the submission process a response will be sent to this callback URL

Returns:

  • (String)

    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. + "/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.

Parameters:

  • redirect_uri (String)

    the user will be redirected to this URL after the process completes

  • state (String)

    this string will be passed on through the complete synchronization process and to the redirect target at the end. It should be used to validated the authenticity of the call to the redirect URL

  • if_not_synced_since (Integer) (defaults to: 0)

    if this parameter is set, only those accounts will be synchronized, which have not been synchronized within the specified number of minutes.

Returns:

  • (String)

    the URL to be opened by the user.



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)

Parameters:

  • account_id (String) (defaults to: nil)

    ID of the account for which to list the transactions

  • since (String, Date) (defaults to: nil)

    this parameter can either be a transaction ID or a date

  • count (Integer) (defaults to: 1000)

    limit the number of returned transactions

  • offset (Integer) (defaults to: 0)

    which offset into the result set should be used to determin the first transaction to return (useful in combination with count)

  • include_pending (Boolean) (defaults to: false)

    this flag indicates whether pending transactions should be included in the response; pending transactions are always included as a complete set, regardless of the ‘since` parameter

Returns:

  • (Array)

    an array of ‘Transaction` objects, one for each transaction of the user



13
14
15
16
17
18
# File 'lib/transaction/api_call.rb', line 13

def transactions( = 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, (.nil? ? "/rest/transactions?" : "/rest/accounts/#{account_id}/transactions?") + URI.encode_www_form(data), nil, "GET", "transactions"
end

#userUser

Retrieve current User

Returns:

  • (User)

    the current user



6
7
8
# File 'lib/user/api_call.rb', line 6

def user
  query_api_object User, "/rest/user"
end