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) ⇒ Object


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

def create(user_id, params)
  type = params.fetch(:Type) { |no_symbol_key| params.fetch('Type') }
  MangoPay.request(:post, "#{url(user_id)}/#{type}", params)
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

.url(user_id, bank_account_id = nil) ⇒ Object


24
25
26
27
28
29
30
# File 'lib/mangopay/bank_account.rb', line 24

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