Module: MangoApi::BankAccounts

Extended by:
UriProvider
Defined in:
lib/mangopay/api/service/bank_accounts.rb

Overview

Provides API method delegates concerning the BankAccount entity

Class Method Summary collapse

Methods included from UriProvider

provide_uri

Class Method Details

.all(user_id) {|filter_request = FilterRequest.new| ... } ⇒ Array

Retrieves pages of a user’s bank accounts. Allows configuration of paging and sorting parameters by yielding a filtering object to a provided block. When no filters are specified, will retrieve the first page of 10 newest results.

Allowed FilterRequest params:

  • page

  • per_page

  • sort_field and sort_direction

Parameters:

  • +user_id+ (String)

    ID of the user whose bank accounts to get

Yields:

Returns:

  • (Array)

    parsed BankAccount entity objects



95
96
97
98
99
100
101
# File 'lib/mangopay/api/service/bank_accounts.rb', line 95

def all(user_id)
  uri = provide_uri(:get_accounts, user_id)
  filter_request = nil
  yield filter_request = FilterRequest.new if block_given?
  results = HttpClient.get(uri, filter_request)
  parse_results results
end

.create(account, id_key = nil) ⇒ BankAccount

Creates a new bank account entity.

BankAccount properties:

  • +IbanBankAccount

    • tag - optional

    • owner_address - required

    • owner_name - required

    • iban - required

    • bic - optional

  • UsBankAccount

    • tag - optional

    • owner_address - required

    • owner_name - required

    • account_number - required

    • aba - required

    • deposit_account_type - optional

  • CaBankAccount

    • tag - optional

    • owner_address - required

    • owner_name - required

    • branch_code - required

    • institution_number - required

    • account_number - required

    • bank_name - required

  • GbBankAccount

    • tag - optional

    • owner_address - required

    • owner_name - required

    • sort_code - required

    • account_number - required

  • OtherBankAccount

    • tag optional

    • owner_address - required

    • owner_name - required

    • country - required

    • bic - required

    • account_number - required

Parameters:

  • +account+ (BankAccount)

    model object of account to be created

  • +id_key+ (String)

    idempotency key for future response replication

Returns:

  • (BankAccount)

    the newly-created BankAccount entity object



53
54
55
56
57
# File 'lib/mangopay/api/service/bank_accounts.rb', line 53

def create(, id_key = nil)
  uri = provide_uri(:create_account, )
  response = HttpClient.post(uri, , id_key)
  parse response
end

.deactivate(user_id, account_id) ⇒ BankAccount

Deactivates a bank account entity.

being deactivated

Parameters:

  • +user_id+ (String)

    ID of the owner of the account

  • +account_id+ (String)

    ID of the bank account being deactivated

Returns:

  • (BankAccount)

    deactivated BankAccount entity object



65
66
67
68
69
# File 'lib/mangopay/api/service/bank_accounts.rb', line 65

def deactivate(user_id, )
  uri = provide_uri(:deactivate_account, user_id, )
  response = HttpClient.put(uri, DeactivationRequest.new)
  parse response
end

.get(user_id, account_id) ⇒ BankAccount

Retrieves a bank account for a user.

Parameters:

  • +user_id+ (String)

    ID of the bank account’s owner

  • +account+id+ (String)

    ID of the bank account

Returns:

  • (BankAccount)

    the corresponding BankAccount object



76
77
78
79
80
# File 'lib/mangopay/api/service/bank_accounts.rb', line 76

def get(user_id, )
  uri = provide_uri(:get_account, user_id, )
  response = HttpClient.get(uri)
  parse response
end