mangopay 3.0.25 → 3.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +30 -28
- data/.rspec +2 -2
- data/.travis.yml +13 -4
- data/Gemfile +2 -2
- data/LICENSE +20 -20
- data/README.md +126 -126
- data/bin/mangopay +9 -9
- data/lib/generators/mangopay/install_generator.rb +60 -60
- data/lib/generators/templates/mangopay.rb.erb +5 -5
- data/lib/mangopay.rb +228 -225
- data/lib/mangopay/authorization_token.rb +88 -88
- data/lib/mangopay/bank_account.rb +38 -38
- data/lib/mangopay/bankingaliases.rb +29 -0
- data/lib/mangopay/bankingaliases_iban.rb +16 -0
- data/lib/mangopay/card.rb +8 -8
- data/lib/mangopay/card_registration.rb +9 -9
- data/lib/mangopay/client.rb +74 -74
- data/lib/mangopay/dispute.rb +130 -130
- data/lib/mangopay/errors.rb +61 -61
- data/lib/mangopay/event.rb +18 -18
- data/lib/mangopay/filter_parameters.rb +46 -46
- data/lib/mangopay/hook.rb +9 -9
- data/lib/mangopay/http_calls.rb +85 -85
- data/lib/mangopay/json.rb +14 -14
- data/lib/mangopay/kyc_document.rb +70 -70
- data/lib/mangopay/legal_user.rb +15 -15
- data/lib/mangopay/mandate.rb +32 -32
- data/lib/mangopay/natural_user.rb +14 -14
- data/lib/mangopay/pay_in.rb +96 -85
- data/lib/mangopay/pay_out.rb +14 -14
- data/lib/mangopay/pre_authorization.rb +13 -13
- data/lib/mangopay/refund.rb +7 -7
- data/lib/mangopay/report.rb +17 -17
- data/lib/mangopay/resource.rb +21 -21
- data/lib/mangopay/transaction.rb +24 -24
- data/lib/mangopay/transfer.rb +9 -9
- data/lib/mangopay/user.rb +43 -43
- data/lib/mangopay/version.rb +3 -3
- data/lib/mangopay/wallet.rb +17 -17
- data/mangopay.gemspec +30 -30
- data/spec/mangopay/authorization_token_spec.rb +70 -70
- data/spec/mangopay/bank_account_spec.rb +97 -97
- data/spec/mangopay/bankingaliases_spec.rb +29 -0
- data/spec/mangopay/card_registration_spec.rb +73 -73
- data/spec/mangopay/client_spec.rb +110 -110
- data/spec/mangopay/configuration_spec.rb +95 -95
- data/spec/mangopay/dispute_spec.rb +262 -262
- data/spec/mangopay/event_spec.rb +31 -31
- data/spec/mangopay/fetch_filters_spec.rb +63 -63
- data/spec/mangopay/hook_spec.rb +37 -37
- data/spec/mangopay/idempotency_spec.rb +41 -41
- data/spec/mangopay/kyc_document_spec.rb +103 -103
- data/spec/mangopay/log_requests_filter_spec.rb +25 -25
- data/spec/mangopay/mandate_spec.rb +92 -92
- data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
- data/spec/mangopay/payin_card_direct_spec.rb +68 -68
- data/spec/mangopay/payin_card_web_spec.rb +47 -38
- data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
- data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
- data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
- data/spec/mangopay/payout_bankwire_spec.rb +54 -54
- data/spec/mangopay/preauthorization_spec.rb +42 -42
- data/spec/mangopay/refund_spec.rb +21 -21
- data/spec/mangopay/report_spec.rb +39 -39
- data/spec/mangopay/shared_resources.rb +397 -381
- data/spec/mangopay/transaction_spec.rb +54 -54
- data/spec/mangopay/transfer_spec.rb +69 -69
- data/spec/mangopay/user_spec.rb +137 -137
- data/spec/mangopay/wallet_spec.rb +80 -80
- data/spec/spec_helper.rb +31 -31
- metadata +7 -6
- data/lib/mangopay/temp.rb +0 -74
- data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
@@ -1,88 +1,88 @@
|
|
1
|
-
module MangoPay
|
2
|
-
module AuthorizationToken
|
3
|
-
|
4
|
-
# See http://docs.mangopay.com/api-references/authenticating/
|
5
|
-
class Manager
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def storage
|
9
|
-
@@storage ||= StaticStorage.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def storage= (storage)
|
13
|
-
@@storage = storage
|
14
|
-
end
|
15
|
-
|
16
|
-
def get_token
|
17
|
-
token = storage.get
|
18
|
-
env_key = get_environment_key_for_token
|
19
|
-
if token.nil? || token['timestamp'].nil? || token['timestamp'] <= Time.now || token['environment_key'] != env_key
|
20
|
-
token = MangoPay.request(:post, "/#{MangoPay.version_code}/oauth/token", {}, {}, {}, Proc.new do |req|
|
21
|
-
cfg = MangoPay.configuration
|
22
|
-
req.basic_auth cfg.client_id, cfg.client_passphrase
|
23
|
-
req.body = 'grant_type=client_credentials'
|
24
|
-
end)
|
25
|
-
token['timestamp'] = Time.now + (token['expires_in'].to_i - 10)
|
26
|
-
token['environment_key'] = env_key
|
27
|
-
storage.store token
|
28
|
-
end
|
29
|
-
token
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_environment_key_for_token
|
33
|
-
cfg = MangoPay.configuration
|
34
|
-
key = "#{cfg.root_url}|#{cfg.client_id}|#{cfg.client_passphrase}"
|
35
|
-
key = Digest::MD5.hexdigest(key)
|
36
|
-
key
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class StaticStorage
|
42
|
-
def get
|
43
|
-
@@token ||= nil
|
44
|
-
end
|
45
|
-
|
46
|
-
def store(token)
|
47
|
-
@@token = token
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
class FileStorage
|
52
|
-
require 'yaml'
|
53
|
-
@temp_dir
|
54
|
-
|
55
|
-
def initialize(temp_dir = nil)
|
56
|
-
@temp_dir = temp_dir || MangoPay.configuration.temp_dir
|
57
|
-
if !@temp_dir
|
58
|
-
raise "Path to temporary folder is not defined"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def get
|
63
|
-
begin
|
64
|
-
f = File.open(file_path, File::RDONLY)
|
65
|
-
f.flock(File::LOCK_SH)
|
66
|
-
txt = f.read
|
67
|
-
f.close
|
68
|
-
YAML.load(txt) || nil
|
69
|
-
rescue Errno::ENOENT
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def store(token)
|
75
|
-
File.open(file_path, File::RDWR|File::CREAT, 0644) do |f|
|
76
|
-
f.flock(File::LOCK_EX)
|
77
|
-
f.truncate(0)
|
78
|
-
f.rewind
|
79
|
-
f.puts(YAML.dump(token))
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def file_path
|
84
|
-
File.join(@temp_dir, "MangoPay.AuthorizationToken.FileStore.tmp")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
module AuthorizationToken
|
3
|
+
|
4
|
+
# See http://docs.mangopay.com/api-references/authenticating/
|
5
|
+
class Manager
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def storage
|
9
|
+
@@storage ||= StaticStorage.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def storage= (storage)
|
13
|
+
@@storage = storage
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_token
|
17
|
+
token = storage.get
|
18
|
+
env_key = get_environment_key_for_token
|
19
|
+
if token.nil? || token['timestamp'].nil? || token['timestamp'] <= Time.now || token['environment_key'] != env_key
|
20
|
+
token = MangoPay.request(:post, "/#{MangoPay.version_code}/oauth/token", {}, {}, {}, Proc.new do |req|
|
21
|
+
cfg = MangoPay.configuration
|
22
|
+
req.basic_auth cfg.client_id, cfg.client_passphrase
|
23
|
+
req.body = 'grant_type=client_credentials'
|
24
|
+
end)
|
25
|
+
token['timestamp'] = Time.now + (token['expires_in'].to_i - 10)
|
26
|
+
token['environment_key'] = env_key
|
27
|
+
storage.store token
|
28
|
+
end
|
29
|
+
token
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_environment_key_for_token
|
33
|
+
cfg = MangoPay.configuration
|
34
|
+
key = "#{cfg.root_url}|#{cfg.client_id}|#{cfg.client_passphrase}"
|
35
|
+
key = Digest::MD5.hexdigest(key)
|
36
|
+
key
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class StaticStorage
|
42
|
+
def get
|
43
|
+
@@token ||= nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def store(token)
|
47
|
+
@@token = token
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class FileStorage
|
52
|
+
require 'yaml'
|
53
|
+
@temp_dir
|
54
|
+
|
55
|
+
def initialize(temp_dir = nil)
|
56
|
+
@temp_dir = temp_dir || MangoPay.configuration.temp_dir
|
57
|
+
if !@temp_dir
|
58
|
+
raise "Path to temporary folder is not defined"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def get
|
63
|
+
begin
|
64
|
+
f = File.open(file_path, File::RDONLY)
|
65
|
+
f.flock(File::LOCK_SH)
|
66
|
+
txt = f.read
|
67
|
+
f.close
|
68
|
+
YAML.load(txt) || nil
|
69
|
+
rescue Errno::ENOENT
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def store(token)
|
75
|
+
File.open(file_path, File::RDWR|File::CREAT, 0644) do |f|
|
76
|
+
f.flock(File::LOCK_EX)
|
77
|
+
f.truncate(0)
|
78
|
+
f.rewind
|
79
|
+
f.puts(YAML.dump(token))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def file_path
|
84
|
+
File.join(@temp_dir, "MangoPay.AuthorizationToken.FileStore.tmp")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
module MangoPay
|
2
|
-
|
3
|
-
# See http://docs.mangopay.com/api-references/bank-accounts/
|
4
|
-
class BankAccount < Resource
|
5
|
-
include HTTPCalls::Fetch
|
6
|
-
class << self
|
7
|
-
def create(user_id, params, idempotency_key = nil)
|
8
|
-
type = params.fetch(:Type) { |no_symbol_key| params.fetch('Type') }
|
9
|
-
MangoPay.request(:post, "#{url(user_id)}/#{type}", params, {}, idempotency_key)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Fetches:
|
13
|
-
# - list of bank accounts belonging to the given +user_id+
|
14
|
-
# - or single bank account belonging to the given +user_id+ with the given +bank_account_id+.
|
15
|
-
#
|
16
|
-
# In case of list query, optional +filters+ is a hash accepting pagination and sorting params
|
17
|
-
# (+page+, +per_page+, +sort+; see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
18
|
-
#
|
19
|
-
def fetch(user_id, bank_account_id_or_filters={})
|
20
|
-
bank_account_id, filters = HTTPCalls::Fetch.parse_id_or_filters(bank_account_id_or_filters)
|
21
|
-
MangoPay.request(:get, url(user_id, bank_account_id), {}, filters)
|
22
|
-
end
|
23
|
-
|
24
|
-
# see https://docs.mangopay.com/endpoints/v2.01/bank-accounts#e306_disactivate-a-bank-account
|
25
|
-
def update(user_id, bank_account_id, params = {})
|
26
|
-
MangoPay.request(:put, url(user_id, bank_account_id), params)
|
27
|
-
end
|
28
|
-
|
29
|
-
def url(user_id, bank_account_id = nil)
|
30
|
-
if bank_account_id
|
31
|
-
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts/#{CGI.escape(bank_account_id.to_s)}"
|
32
|
-
else
|
33
|
-
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See http://docs.mangopay.com/api-references/bank-accounts/
|
4
|
+
class BankAccount < Resource
|
5
|
+
include HTTPCalls::Fetch
|
6
|
+
class << self
|
7
|
+
def create(user_id, params, idempotency_key = nil)
|
8
|
+
type = params.fetch(:Type) { |no_symbol_key| params.fetch('Type') }
|
9
|
+
MangoPay.request(:post, "#{url(user_id)}/#{type}", params, {}, idempotency_key)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Fetches:
|
13
|
+
# - list of bank accounts belonging to the given +user_id+
|
14
|
+
# - or single bank account belonging to the given +user_id+ with the given +bank_account_id+.
|
15
|
+
#
|
16
|
+
# In case of list query, optional +filters+ is a hash accepting pagination and sorting params
|
17
|
+
# (+page+, +per_page+, +sort+; see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
18
|
+
#
|
19
|
+
def fetch(user_id, bank_account_id_or_filters={})
|
20
|
+
bank_account_id, filters = HTTPCalls::Fetch.parse_id_or_filters(bank_account_id_or_filters)
|
21
|
+
MangoPay.request(:get, url(user_id, bank_account_id), {}, filters)
|
22
|
+
end
|
23
|
+
|
24
|
+
# see https://docs.mangopay.com/endpoints/v2.01/bank-accounts#e306_disactivate-a-bank-account
|
25
|
+
def update(user_id, bank_account_id, params = {})
|
26
|
+
MangoPay.request(:put, url(user_id, bank_account_id), params)
|
27
|
+
end
|
28
|
+
|
29
|
+
def url(user_id, bank_account_id = nil)
|
30
|
+
if bank_account_id
|
31
|
+
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts/#{CGI.escape(bank_account_id.to_s)}"
|
32
|
+
else
|
33
|
+
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/bankaccounts"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See children class:
|
4
|
+
# - MangoPay::BankingAliasesIBAN
|
5
|
+
class BankingAliases < Resource
|
6
|
+
include HTTPCalls::Create
|
7
|
+
include HTTPCalls::Update
|
8
|
+
include HTTPCalls::Fetch
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def create
|
12
|
+
raise 'Cannot create a MangoPay::BankingAlias. See MangoPay::BankingAliasesIBAN'
|
13
|
+
end
|
14
|
+
|
15
|
+
def url(id = nil)
|
16
|
+
if id
|
17
|
+
"#{MangoPay.api_path}/bankingaliases/#{CGI.escape(id)}"
|
18
|
+
else
|
19
|
+
"#{MangoPay.api_path}/bankingaliases"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def fetch_for_wallet(wallet_id, filters = {})
|
24
|
+
url = "#{MangoPay.api_path}/wallets/#{wallet_id}/bankingaliases"
|
25
|
+
MangoPay.request(:get, url, {}, filters)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See parent class MangoPay::BankingAliases
|
4
|
+
class BankingAliasesIBAN < BankingAliases
|
5
|
+
|
6
|
+
def self.create(params, wallet_id)
|
7
|
+
url = "#{MangoPay.api_path}/wallets/#{wallet_id}/bankingaliases/iban"
|
8
|
+
MangoPay.request(:post, url, params, {})
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.url(id = nil)
|
12
|
+
"#{super.url(id)}"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/mangopay/card.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
module MangoPay
|
2
|
-
|
3
|
-
# See http://docs.mangopay.com/api-references/card/
|
4
|
-
class Card < Resource
|
5
|
-
include HTTPCalls::Fetch
|
6
|
-
include HTTPCalls::Update
|
7
|
-
end
|
8
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See http://docs.mangopay.com/api-references/card/
|
4
|
+
class Card < Resource
|
5
|
+
include HTTPCalls::Fetch
|
6
|
+
include HTTPCalls::Update
|
7
|
+
end
|
8
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module MangoPay
|
2
|
-
|
3
|
-
# See http://docs.mangopay.com/api-references/card-registration/
|
4
|
-
class CardRegistration < Resource
|
5
|
-
include HTTPCalls::Create
|
6
|
-
include HTTPCalls::Update
|
7
|
-
include HTTPCalls::Fetch
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See http://docs.mangopay.com/api-references/card-registration/
|
4
|
+
class CardRegistration < Resource
|
5
|
+
include HTTPCalls::Create
|
6
|
+
include HTTPCalls::Update
|
7
|
+
include HTTPCalls::Fetch
|
8
|
+
end
|
9
|
+
end
|
data/lib/mangopay/client.rb
CHANGED
@@ -1,74 +1,74 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module MangoPay
|
4
|
-
class Client < Resource
|
5
|
-
|
6
|
-
class << self
|
7
|
-
|
8
|
-
# see https://docs.mangopay.com/api-references/client-details/
|
9
|
-
def fetch()
|
10
|
-
MangoPay.request(:get, url())
|
11
|
-
end
|
12
|
-
|
13
|
-
# see https://docs.mangopay.com/api-references/client-details/
|
14
|
-
def update(params)
|
15
|
-
MangoPay.request(:put, url(), params)
|
16
|
-
end
|
17
|
-
|
18
|
-
# see https://docs.mangopay.com/api-references/client-details/
|
19
|
-
def upload_logo(file_content_base64, file_path = nil)
|
20
|
-
if file_content_base64.nil? && !file_path.nil?
|
21
|
-
bts = File.open(file_path, 'rb') { |f| f.read }
|
22
|
-
file_content_base64 = Base64.encode64(bts)
|
23
|
-
end
|
24
|
-
# normally it returns 204 HTTP code on success
|
25
|
-
begin
|
26
|
-
MangoPay.request(:put, url() + '/logo', {'File' => file_content_base64})
|
27
|
-
rescue ResponseError => ex
|
28
|
-
raise ex unless ex.code == '204'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Fetch all your client wallets;
|
33
|
-
# +funds_type+ may be:
|
34
|
-
# - nil: all wallets
|
35
|
-
# - 'fees': fees wallets
|
36
|
-
# - 'credit': credit wallets
|
37
|
-
# see https://docs.mangopay.com/api-references/client-wallets/
|
38
|
-
def fetch_wallets(funds_type = nil)
|
39
|
-
MangoPay.request(:get, url() + "/wallets/#{funds_type}")
|
40
|
-
end
|
41
|
-
|
42
|
-
# Fetch one of your client wallets (fees or credit) with a particular currency;
|
43
|
-
# +funds_type+ may be:
|
44
|
-
# - nil: all wallets
|
45
|
-
# - 'fees': fees wallets
|
46
|
-
# - 'credit': credit wallets
|
47
|
-
# +currency_iso_code+ is currncy ISO code
|
48
|
-
# see https://docs.mangopay.com/api-references/client-wallets/
|
49
|
-
def fetch_wallet(funds_type, currency_iso_code)
|
50
|
-
MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}")
|
51
|
-
end
|
52
|
-
|
53
|
-
# Fetch transactions for all your client wallets.
|
54
|
-
# Optional +filters+ hash: see MangoPay::Transaction.fetch
|
55
|
-
# See https://docs.mangopay.com/api-references/client-wallets/
|
56
|
-
def fetch_wallets_transactions(filters = {})
|
57
|
-
MangoPay.request(:get, url() + "/transactions", {}, filters)
|
58
|
-
end
|
59
|
-
|
60
|
-
# Fetch transactions for one of your client wallets (fees or credit) with a particular currency;
|
61
|
-
# +funds_type+ may be:
|
62
|
-
# - nil: all wallets
|
63
|
-
# - 'fees': fees wallets
|
64
|
-
# - 'credit': credit wallets
|
65
|
-
# +currency_iso_code+ is currncy ISO code
|
66
|
-
# Optional +filters+ hash: see MangoPay::Transaction.fetch
|
67
|
-
# See https://docs.mangopay.com/api-references/client-wallets/
|
68
|
-
def fetch_wallet_transactions(funds_type, currency_iso_code, filters = {})
|
69
|
-
MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}/transactions", {}, filters)
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module MangoPay
|
4
|
+
class Client < Resource
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
# see https://docs.mangopay.com/api-references/client-details/
|
9
|
+
def fetch()
|
10
|
+
MangoPay.request(:get, url())
|
11
|
+
end
|
12
|
+
|
13
|
+
# see https://docs.mangopay.com/api-references/client-details/
|
14
|
+
def update(params)
|
15
|
+
MangoPay.request(:put, url(), params)
|
16
|
+
end
|
17
|
+
|
18
|
+
# see https://docs.mangopay.com/api-references/client-details/
|
19
|
+
def upload_logo(file_content_base64, file_path = nil)
|
20
|
+
if file_content_base64.nil? && !file_path.nil?
|
21
|
+
bts = File.open(file_path, 'rb') { |f| f.read }
|
22
|
+
file_content_base64 = Base64.encode64(bts)
|
23
|
+
end
|
24
|
+
# normally it returns 204 HTTP code on success
|
25
|
+
begin
|
26
|
+
MangoPay.request(:put, url() + '/logo', {'File' => file_content_base64})
|
27
|
+
rescue ResponseError => ex
|
28
|
+
raise ex unless ex.code == '204'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Fetch all your client wallets;
|
33
|
+
# +funds_type+ may be:
|
34
|
+
# - nil: all wallets
|
35
|
+
# - 'fees': fees wallets
|
36
|
+
# - 'credit': credit wallets
|
37
|
+
# see https://docs.mangopay.com/api-references/client-wallets/
|
38
|
+
def fetch_wallets(funds_type = nil)
|
39
|
+
MangoPay.request(:get, url() + "/wallets/#{funds_type}")
|
40
|
+
end
|
41
|
+
|
42
|
+
# Fetch one of your client wallets (fees or credit) with a particular currency;
|
43
|
+
# +funds_type+ may be:
|
44
|
+
# - nil: all wallets
|
45
|
+
# - 'fees': fees wallets
|
46
|
+
# - 'credit': credit wallets
|
47
|
+
# +currency_iso_code+ is currncy ISO code
|
48
|
+
# see https://docs.mangopay.com/api-references/client-wallets/
|
49
|
+
def fetch_wallet(funds_type, currency_iso_code)
|
50
|
+
MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}")
|
51
|
+
end
|
52
|
+
|
53
|
+
# Fetch transactions for all your client wallets.
|
54
|
+
# Optional +filters+ hash: see MangoPay::Transaction.fetch
|
55
|
+
# See https://docs.mangopay.com/api-references/client-wallets/
|
56
|
+
def fetch_wallets_transactions(filters = {})
|
57
|
+
MangoPay.request(:get, url() + "/transactions", {}, filters)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Fetch transactions for one of your client wallets (fees or credit) with a particular currency;
|
61
|
+
# +funds_type+ may be:
|
62
|
+
# - nil: all wallets
|
63
|
+
# - 'fees': fees wallets
|
64
|
+
# - 'credit': credit wallets
|
65
|
+
# +currency_iso_code+ is currncy ISO code
|
66
|
+
# Optional +filters+ hash: see MangoPay::Transaction.fetch
|
67
|
+
# See https://docs.mangopay.com/api-references/client-wallets/
|
68
|
+
def fetch_wallet_transactions(funds_type, currency_iso_code, filters = {})
|
69
|
+
MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}/transactions", {}, filters)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|