mangopay 3.0.8 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mangopay.rb +1 -0
- data/lib/mangopay/bank_account.rb +5 -1
- data/lib/mangopay/hook.rb +7 -0
- data/lib/mangopay/version.rb +1 -1
- data/spec/lib/mangopay/bank_account_spec.rb +62 -1
- data/spec/lib/mangopay/hook_spec.rb +39 -0
- data/spec/lib/mangopay/shared_resources.rb +17 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c3155df7c8b7d8eb28c67cd17e290b0b3494c87
|
4
|
+
data.tar.gz: fdbea6236e07982dc34c46b2fe34a6c3873b2a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9961531e7b10868ef7d1e1a343fb1a1dd9928cfa9c7489fcc5b42444e7062068545486716a4876d7d67bb0d8af6a9e7ece7a0b9208e099bfb1de36618e02c6cd
|
7
|
+
data.tar.gz: d29da37c98376db5bdca15321f0d21386f8fc06a76e2acf68d5b277f9e1f2aac78845dea2c0276ae5b657e93e516e5d082d223c01db361aca3edb453d13b3a4c
|
data/lib/mangopay.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
module MangoPay
|
2
2
|
class BankAccount < Resource
|
3
|
-
include MangoPay::HTTPCalls::Create
|
4
3
|
include MangoPay::HTTPCalls::Fetch
|
5
4
|
|
5
|
+
def self.create(user_id, params)
|
6
|
+
type = params.fetch(:Type) { |no_symbol_key| params.fetch('Type') }
|
7
|
+
MangoPay.request(:post, "#{url(user_id)}/#{type}", params)
|
8
|
+
end
|
9
|
+
|
6
10
|
# Fetches:
|
7
11
|
# - list of bank accounts belonging to the given +user_id+
|
8
12
|
# - or single bank account belonging to the given +user_id+ with the given +bank_account_id+.
|
data/lib/mangopay/version.rb
CHANGED
@@ -2,11 +2,72 @@ require_relative '../../spec_helper'
|
|
2
2
|
|
3
3
|
describe MangoPay::BankAccount do
|
4
4
|
include_context 'bank_accounts'
|
5
|
+
|
6
|
+
def create(params)
|
7
|
+
params_fixed = { OwnerName: 'John', OwnerAddress: 'Here' }.merge(params)
|
8
|
+
MangoPay::BankAccount.create(new_natural_user['Id'], params_fixed)
|
9
|
+
end
|
5
10
|
|
6
11
|
describe 'CREATE' do
|
7
|
-
|
12
|
+
|
13
|
+
it 'creates a new IBAN bank detail' do
|
8
14
|
expect(new_bank_account['Id']).not_to be_nil
|
9
15
|
end
|
16
|
+
|
17
|
+
it 'creates a new GB bank detail' do
|
18
|
+
created = create({
|
19
|
+
Type: 'GB',
|
20
|
+
AccountNumber: '234234234234',
|
21
|
+
SortCode: '234334',
|
22
|
+
})
|
23
|
+
expect(created['Id']).not_to be_nil
|
24
|
+
expect(created['Type']).to eq('GB')
|
25
|
+
expect(created['AccountNumber']).to eq('234234234234')
|
26
|
+
expect(created['SortCode']).to eq('234334')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'creates a new US bank detail' do
|
30
|
+
created = create({
|
31
|
+
Type: 'US',
|
32
|
+
AccountNumber: '234234234234',
|
33
|
+
ABA: '234334789',
|
34
|
+
})
|
35
|
+
expect(created['Id']).not_to be_nil
|
36
|
+
expect(created['Type']).to eq('US')
|
37
|
+
expect(created['AccountNumber']).to eq('234234234234')
|
38
|
+
expect(created['ABA']).to eq('234334789')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'creates a new CA bank detail' do
|
42
|
+
created = create({
|
43
|
+
Type: 'CA',
|
44
|
+
BankName: 'TestBankName',
|
45
|
+
BranchCode: '12345',
|
46
|
+
AccountNumber: '234234234234',
|
47
|
+
InstitutionNumber: '123',
|
48
|
+
})
|
49
|
+
expect(created['Id']).not_to be_nil
|
50
|
+
expect(created['Type']).to eq('CA')
|
51
|
+
expect(created['BankName']).to eq('TestBankName')
|
52
|
+
expect(created['BranchCode']).to eq('12345')
|
53
|
+
expect(created['AccountNumber']).to eq('234234234234')
|
54
|
+
expect(created['InstitutionNumber']).to eq('123')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'creates a new OTHER bank detail' do
|
58
|
+
created = create({
|
59
|
+
Type: 'OTHER',
|
60
|
+
Country: 'FR',
|
61
|
+
AccountNumber: '234234234234',
|
62
|
+
BIC: 'BINAADADXXX',
|
63
|
+
})
|
64
|
+
expect(created['Id']).not_to be_nil
|
65
|
+
expect(created['Type']).to eq('OTHER')
|
66
|
+
expect(created['Country']).to eq('FR')
|
67
|
+
expect(created['AccountNumber']).to eq('234234234234')
|
68
|
+
expect(created['BIC']).to eq('BINAADADXXX')
|
69
|
+
end
|
70
|
+
|
10
71
|
end
|
11
72
|
|
12
73
|
describe 'FETCH' do
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe MangoPay::Hook do
|
4
|
+
include_context 'hooks'
|
5
|
+
|
6
|
+
describe 'CREATE' do
|
7
|
+
it 'creates a hook' do
|
8
|
+
expect(new_hook['Id']).to_not be_nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'UPDATE' do
|
13
|
+
it 'updates a hook' do
|
14
|
+
new_url = new_hook['Url'] + '.com'
|
15
|
+
updated_hook = MangoPay::Hook.update(new_hook['Id'], {
|
16
|
+
Url: new_url,
|
17
|
+
Tag: 'Updated Tag'
|
18
|
+
})
|
19
|
+
expect(updated_hook['Url']).to eq(new_url)
|
20
|
+
expect(updated_hook['Tag']).to eq('Updated Tag')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'FETCH' do
|
25
|
+
|
26
|
+
it 'fetches a hook' do
|
27
|
+
hook = MangoPay::Hook.fetch(new_hook['Id'])
|
28
|
+
expect(hook['Id']).to eq(new_hook['Id'])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'fetches all the hooks' do
|
32
|
+
hooks = MangoPay::Hook.fetch()
|
33
|
+
expect(hooks).to be_kind_of(Array)
|
34
|
+
expect(hooks).not_to be_empty
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -296,3 +296,20 @@ shared_context 'transfers' do
|
|
296
296
|
})
|
297
297
|
end
|
298
298
|
end
|
299
|
+
|
300
|
+
###############################################
|
301
|
+
shared_context 'hooks' do
|
302
|
+
###############################################
|
303
|
+
let(:new_hook) {
|
304
|
+
hooks = MangoPay::Hook.fetch({'page' => 1, 'per_page' => 1})
|
305
|
+
if hooks.length == 0
|
306
|
+
MangoPay::Hook.create({
|
307
|
+
EventType: 'PAYIN_NORMAL_CREATED',
|
308
|
+
Url: 'http://test.com',
|
309
|
+
Tag: 'Test hook'
|
310
|
+
})
|
311
|
+
else
|
312
|
+
hooks[0]
|
313
|
+
end
|
314
|
+
}
|
315
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mangopay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffroy Lorieux
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/mangopay/client.rb
|
122
122
|
- lib/mangopay/errors.rb
|
123
123
|
- lib/mangopay/event.rb
|
124
|
+
- lib/mangopay/hook.rb
|
124
125
|
- lib/mangopay/http_calls.rb
|
125
126
|
- lib/mangopay/json.rb
|
126
127
|
- lib/mangopay/kyc_document.rb
|
@@ -143,6 +144,7 @@ files:
|
|
143
144
|
- spec/lib/mangopay/configuration_spec.rb
|
144
145
|
- spec/lib/mangopay/event_spec.rb
|
145
146
|
- spec/lib/mangopay/fetch_filters_spec.rb
|
147
|
+
- spec/lib/mangopay/hook_spec.rb
|
146
148
|
- spec/lib/mangopay/kyc_document_spec.rb
|
147
149
|
- spec/lib/mangopay/payin_bankwire_direct_spec.rb
|
148
150
|
- spec/lib/mangopay/payin_card_direct_spec.rb
|
@@ -189,6 +191,7 @@ test_files:
|
|
189
191
|
- spec/lib/mangopay/configuration_spec.rb
|
190
192
|
- spec/lib/mangopay/event_spec.rb
|
191
193
|
- spec/lib/mangopay/fetch_filters_spec.rb
|
194
|
+
- spec/lib/mangopay/hook_spec.rb
|
192
195
|
- spec/lib/mangopay/kyc_document_spec.rb
|
193
196
|
- spec/lib/mangopay/payin_bankwire_direct_spec.rb
|
194
197
|
- spec/lib/mangopay/payin_card_direct_spec.rb
|