Sha256: 92c7fbb28ca239a98b1a58877296f5f9180cced594e36f002e673d5f23e80e33

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module MangoPay
  class BankAccount < Resource
    include MangoPay::HTTPCalls::Create
    include MangoPay::HTTPCalls::Fetch

    # 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 params
    # (+page+, +per_page+; see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
    #
    def self.fetch(user_id, bank_account_id_or_filters={})
      bank_account_id, filters = MangoPay::HTTPCalls::Fetch.parse_id_or_filters(bank_account_id_or_filters)
      MangoPay.request(:get, url(user_id, bank_account_id), {}, filters)
    end

    private

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mangopay-3.0.8 lib/mangopay/bank_account.rb
mangopay-3.0.7 lib/mangopay/bank_account.rb
mangopay-3.0.6 lib/mangopay/bank_account.rb
mangopay-3.0.5 lib/mangopay/bank_account.rb
mangopay-3.0.4 lib/mangopay/bank_account.rb
mangopay-3.0.3 lib/mangopay/bank_account.rb
mangopay-3.0.2 lib/mangopay/bank_account.rb