Class: MangoPay::BankAccount

Inherits:
Resource show all
Includes:
HTTPCalls::Fetch
Defined in:
lib/mangopay/bank_account.rb

Overview

Class Method Summary collapse

Methods included from HTTPCalls::Fetch

included, parse_id_or_filters

Methods inherited from Resource

class_name

Class Method Details

.create(user_id, params, idempotency_key = nil) ⇒ Object



7
8
9
10
# File 'lib/mangopay/bank_account.rb', line 7

def create(user_id, params, idempotency_key = nil)
  type = params.fetch(:Type) { |no_symbol_key| params.fetch('Type') }
  MangoPay.request(:post, "#{url(user_id)}/#{type}", params, {}, idempotency_key)
end

.fetch(user_id, bank_account_id_or_filters = {}) ⇒ Object

Fetches:

  • list of bank accounts belonging to the given user_id

  • or single bank account belonging to the given user_id with the given bank_account_id.

In case of list query, optional filters is a hash accepting pagination and sorting params (page, per_page, sort; see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)



19
20
21
22
# File 'lib/mangopay/bank_account.rb', line 19

def fetch(user_id, ={})
  , filters = HTTPCalls::Fetch.parse_id_or_filters()
  MangoPay.request(:get, url(user_id, ), {}, filters)
end

.transactions(bank_account_id, filters = {}) ⇒ Object

Fetches list of transactions belonging to given bank_account_id.

Optional filters is a hash accepting following keys:

  • page, per_page, sort: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)

  • Status: TransactionStatus SUCCEEDED, FAILED

  • ResultCode: string representing the transaction result



35
36
37
38
# File 'lib/mangopay/bank_account.rb', line 35

def transactions(, filters = {})
  url = "#{MangoPay.api_path}/bankaccounts/#{}/transactions"
  MangoPay.request(:get, url, {}, filters)
end

.update(user_id, bank_account_id, params = {}) ⇒ Object



25
26
27
# File 'lib/mangopay/bank_account.rb', line 25

def update(user_id, , params = {})
  MangoPay.request(:put, url(user_id, ), params)
end

.url(user_id, bank_account_id = nil) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/mangopay/bank_account.rb', line 40

def url(user_id,  = nil)
  if 
    "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts/#{CGI.escape(.to_s)}"
  else
    "#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts"
  end
end