Class: MangoPay::Client

Inherits:
Resource show all
Defined in:
lib/mangopay/client.rb

Class Method Summary collapse

Methods inherited from Resource

class_name, url

Class Method Details

.create_bank_account(params) ⇒ Object



80
81
82
# File 'lib/mangopay/client.rb', line 80

def (params)
  MangoPay.request(:post, url() + "/bankaccounts/iban", params)
end

.create_payout(params) {|method, path, params| ... } ⇒ Object

Yields:

  • (method, path, params)


84
85
86
87
88
89
# File 'lib/mangopay/client.rb', line 84

def create_payout(params)
  method = :post
  path = url() + "/payouts"
  yield method, path, params if block_given?
  MangoPay.request(method, path, params)
end

.fetchObject



9
10
11
# File 'lib/mangopay/client.rb', line 9

def fetch()
  MangoPay.request(:get, url())
end

.fetch_wallet(funds_type, currency_iso_code) {|method, path| ... } ⇒ Object

Fetch one of your client wallets (fees or credit) with a particular currency; funds_type may be:

- nil: all wallets
- 'fees': fees wallets
- 'credit': credit wallets

currency_iso_code is currncy ISO code see docs.mangopay.com/api-references/client-wallets/

Yields:

  • (method, path)


49
50
51
52
53
54
# File 'lib/mangopay/client.rb', line 49

def fetch_wallet(funds_type, currency_iso_code)
  method = :get
  path = url() + "/wallets/#{funds_type}/#{currency_iso_code}"
  yield method, path if block_given?
  MangoPay.request(method, path)
end

.fetch_wallet_transactions(funds_type, currency_iso_code, filters = {}) ⇒ Object

Fetch transactions for one of your client wallets (fees or credit) with a particular currency; funds_type may be:

- nil: all wallets
- 'fees': fees wallets
- 'credit': credit wallets

currency_iso_code is currncy ISO code Optional filters hash: see MangoPay::Transaction.fetch See docs.mangopay.com/api-references/client-wallets/



71
72
73
# File 'lib/mangopay/client.rb', line 71

def fetch_wallet_transactions(funds_type, currency_iso_code, filters = {})
  MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}/transactions", {}, filters)
end

.fetch_wallets(funds_type = nil) ⇒ Object

Fetch all your client wallets; funds_type may be:

- nil: all wallets
- 'fees': fees wallets
- 'credit': credit wallets

see docs.mangopay.com/api-references/client-wallets/



38
39
40
# File 'lib/mangopay/client.rb', line 38

def fetch_wallets(funds_type = nil)
  MangoPay.request(:get, url() + "/wallets/#{funds_type}")
end

.fetch_wallets_transactions(filters = {}) ⇒ Object

Fetch transactions for all your client wallets. Optional filters hash: see MangoPay::Transaction.fetch See docs.mangopay.com/api-references/client-wallets/



59
60
61
# File 'lib/mangopay/client.rb', line 59

def fetch_wallets_transactions(filters = {})
  MangoPay.request(:get, url() + "/transactions", {}, filters)
end

.update(params) ⇒ Object



14
15
16
# File 'lib/mangopay/client.rb', line 14

def update(params)
  MangoPay.request(:put, url(), params)
end

.upload_logo(file_content_base64, file_path = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mangopay/client.rb', line 19

def (file_content_base64, file_path = nil)
  if file_content_base64.nil? && !file_path.nil?
    bts = File.open(file_path, 'rb') { |f| f.read }
    file_content_base64 = Base64.encode64(bts)
  end
  # normally it returns 204 HTTP code on success
  begin
    MangoPay.request(:put, url() + '/logo', {'File' => file_content_base64})
  rescue ResponseError => ex
    raise ex unless ex.code == '204'
  end
end

.validate(client_id, card_id) ⇒ Object



75
76
77
78
# File 'lib/mangopay/client.rb', line 75

def validate(client_id, card_id)
  url = "#{MangoPay.api_path}/cards/#{card_id}/validate"
  MangoPay.request(:post, url)
end