mangopay 3.0.25 → 3.0.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +30 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -4
  5. data/Gemfile +2 -2
  6. data/LICENSE +20 -20
  7. data/README.md +126 -126
  8. data/bin/mangopay +9 -9
  9. data/lib/generators/mangopay/install_generator.rb +60 -60
  10. data/lib/generators/templates/mangopay.rb.erb +5 -5
  11. data/lib/mangopay.rb +228 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/bankingaliases.rb +29 -0
  15. data/lib/mangopay/bankingaliases_iban.rb +16 -0
  16. data/lib/mangopay/card.rb +8 -8
  17. data/lib/mangopay/card_registration.rb +9 -9
  18. data/lib/mangopay/client.rb +74 -74
  19. data/lib/mangopay/dispute.rb +130 -130
  20. data/lib/mangopay/errors.rb +61 -61
  21. data/lib/mangopay/event.rb +18 -18
  22. data/lib/mangopay/filter_parameters.rb +46 -46
  23. data/lib/mangopay/hook.rb +9 -9
  24. data/lib/mangopay/http_calls.rb +85 -85
  25. data/lib/mangopay/json.rb +14 -14
  26. data/lib/mangopay/kyc_document.rb +70 -70
  27. data/lib/mangopay/legal_user.rb +15 -15
  28. data/lib/mangopay/mandate.rb +32 -32
  29. data/lib/mangopay/natural_user.rb +14 -14
  30. data/lib/mangopay/pay_in.rb +96 -85
  31. data/lib/mangopay/pay_out.rb +14 -14
  32. data/lib/mangopay/pre_authorization.rb +13 -13
  33. data/lib/mangopay/refund.rb +7 -7
  34. data/lib/mangopay/report.rb +17 -17
  35. data/lib/mangopay/resource.rb +21 -21
  36. data/lib/mangopay/transaction.rb +24 -24
  37. data/lib/mangopay/transfer.rb +9 -9
  38. data/lib/mangopay/user.rb +43 -43
  39. data/lib/mangopay/version.rb +3 -3
  40. data/lib/mangopay/wallet.rb +17 -17
  41. data/mangopay.gemspec +30 -30
  42. data/spec/mangopay/authorization_token_spec.rb +70 -70
  43. data/spec/mangopay/bank_account_spec.rb +97 -97
  44. data/spec/mangopay/bankingaliases_spec.rb +29 -0
  45. data/spec/mangopay/card_registration_spec.rb +73 -73
  46. data/spec/mangopay/client_spec.rb +110 -110
  47. data/spec/mangopay/configuration_spec.rb +95 -95
  48. data/spec/mangopay/dispute_spec.rb +262 -262
  49. data/spec/mangopay/event_spec.rb +31 -31
  50. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  51. data/spec/mangopay/hook_spec.rb +37 -37
  52. data/spec/mangopay/idempotency_spec.rb +41 -41
  53. data/spec/mangopay/kyc_document_spec.rb +103 -103
  54. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  55. data/spec/mangopay/mandate_spec.rb +92 -92
  56. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  57. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  58. data/spec/mangopay/payin_card_web_spec.rb +47 -38
  59. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  60. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  61. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  62. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  63. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  64. data/spec/mangopay/preauthorization_spec.rb +42 -42
  65. data/spec/mangopay/refund_spec.rb +21 -21
  66. data/spec/mangopay/report_spec.rb +39 -39
  67. data/spec/mangopay/shared_resources.rb +397 -381
  68. data/spec/mangopay/transaction_spec.rb +54 -54
  69. data/spec/mangopay/transfer_spec.rb +69 -69
  70. data/spec/mangopay/user_spec.rb +137 -137
  71. data/spec/mangopay/wallet_spec.rb +80 -80
  72. data/spec/spec_helper.rb +31 -31
  73. metadata +7 -6
  74. data/lib/mangopay/temp.rb +0 -74
  75. data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
@@ -1,54 +1,54 @@
1
- describe MangoPay::Transaction do
2
- include_context 'wallets'
3
- include_context 'payins'
4
- include_context 'payouts'
5
-
6
- describe 'FETCH' do
7
-
8
- it 'fetches empty list of transactions if no transactions done' do
9
- transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
10
- expect(transactions).to be_kind_of(Array)
11
- expect(transactions).to be_empty
12
- end
13
-
14
- it 'fetches list with single transaction after payin done' do
15
- payin = new_payin_card_direct
16
- transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
17
- expect(transactions).to be_kind_of(Array)
18
- expect(transactions.count).to eq 1
19
- expect(transactions.first['Id']).to eq payin['Id']
20
- end
21
-
22
- it 'fetches list with two transactions after payin and payout done' do
23
- payin = new_payin_card_direct
24
- payout = create_new_payout_bankwire(payin)
25
- transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
26
-
27
- expect(transactions).to be_kind_of(Array)
28
- expect(transactions.count).to eq 2
29
-
30
- transactions_ids = transactions.map {|t| t['Id']}
31
- expect(transactions_ids).to include payin['Id']
32
- expect(transactions_ids).to include payout['Id']
33
- end
34
-
35
- it 'accepts filtering params' do
36
- payin = new_payin_card_direct
37
- payout = create_new_payout_bankwire(payin)
38
- wallet_id = new_wallet['Id']
39
-
40
- by_nature_reg = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REGULAR'})
41
- by_nature_ref = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REFUND'})
42
- expect(by_nature_reg.count).to eq 2
43
- expect(by_nature_ref.count).to eq 0
44
-
45
- by_type_pyin = MangoPay::Transaction.fetch(wallet_id, {'Type' => 'PAYIN'})
46
- by_type_pyout = MangoPay::Transaction.fetch(wallet_id, {'Type' => 'PAYOUT'})
47
- expect(by_type_pyin.count).to eq 1
48
- expect(by_type_pyout.count).to eq 1
49
- expect(by_type_pyin.first['Id']).to eq payin['Id']
50
- expect(by_type_pyout.first['Id']).to eq payout['Id']
51
- end
52
-
53
- end
54
- end
1
+ describe MangoPay::Transaction do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+ include_context 'payouts'
5
+
6
+ describe 'FETCH' do
7
+
8
+ it 'fetches empty list of transactions if no transactions done' do
9
+ transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
10
+ expect(transactions).to be_kind_of(Array)
11
+ expect(transactions).to be_empty
12
+ end
13
+
14
+ it 'fetches list with single transaction after payin done' do
15
+ payin = new_payin_card_direct
16
+ transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
17
+ expect(transactions).to be_kind_of(Array)
18
+ expect(transactions.count).to eq 1
19
+ expect(transactions.first['Id']).to eq payin['Id']
20
+ end
21
+
22
+ it 'fetches list with two transactions after payin and payout done' do
23
+ payin = new_payin_card_direct
24
+ payout = create_new_payout_bankwire(payin)
25
+ transactions = MangoPay::Transaction.fetch(new_wallet['Id'])
26
+
27
+ expect(transactions).to be_kind_of(Array)
28
+ expect(transactions.count).to eq 2
29
+
30
+ transactions_ids = transactions.map {|t| t['Id']}
31
+ expect(transactions_ids).to include payin['Id']
32
+ expect(transactions_ids).to include payout['Id']
33
+ end
34
+
35
+ it 'accepts filtering params' do
36
+ payin = new_payin_card_direct
37
+ payout = create_new_payout_bankwire(payin)
38
+ wallet_id = new_wallet['Id']
39
+
40
+ by_nature_reg = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REGULAR'})
41
+ by_nature_ref = MangoPay::Transaction.fetch(wallet_id, {'Nature' => 'REFUND'})
42
+ expect(by_nature_reg.count).to eq 2
43
+ expect(by_nature_ref.count).to eq 0
44
+
45
+ by_type_pyin = MangoPay::Transaction.fetch(wallet_id, {'Type' => 'PAYIN'})
46
+ by_type_pyout = MangoPay::Transaction.fetch(wallet_id, {'Type' => 'PAYOUT'})
47
+ expect(by_type_pyin.count).to eq 1
48
+ expect(by_type_pyout.count).to eq 1
49
+ expect(by_type_pyin.first['Id']).to eq payin['Id']
50
+ expect(by_type_pyout.first['Id']).to eq payout['Id']
51
+ end
52
+
53
+ end
54
+ end
@@ -1,69 +1,69 @@
1
- describe MangoPay::Transfer, type: :feature do
2
- include_context 'wallets'
3
- include_context 'payins'
4
- include_context 'transfers'
5
-
6
- def check_type_and_status(trans)
7
- expect(trans['Type']).to eq('TRANSFER')
8
- expect(trans['Nature']).to eq('REGULAR')
9
-
10
- # SUCCEEDED
11
- expect(trans['Status']).to eq('SUCCEEDED')
12
- expect(trans['ResultCode']).to eq('000000')
13
- expect(trans['ResultMessage']).to eq('Success')
14
- expect(trans['ExecutionDate']).to be > 0
15
- end
16
-
17
- describe 'CREATE' do
18
- it 'creates a new Transfer' do
19
- created = new_transfer
20
- expect(created['Id']).not_to be_nil
21
- check_type_and_status(created)
22
- end
23
- end
24
-
25
- describe 'FETCH' do
26
- it 'fetches a Transfer' do
27
- created = new_transfer
28
- fetched = MangoPay::Transfer.fetch(created['Id'])
29
- expect(fetched['Id']).to eq(created['Id'])
30
- check_type_and_status(created)
31
- check_type_and_status(fetched)
32
- end
33
- end
34
-
35
- describe 'REFUND' do
36
- it 'refunds a transfer' do
37
- trans = new_transfer
38
- refund = MangoPay::Transfer.refund(trans['Id'], {AuthorId: trans['AuthorId']})
39
- expect(refund['Id']).not_to be_nil
40
- expect(refund['Status']).to eq('SUCCEEDED')
41
- expect(refund['Type']).to eq('TRANSFER')
42
- expect(refund['Nature']).to eq('REFUND')
43
- expect(refund['InitialTransactionType']).to eq('TRANSFER')
44
- expect(refund['InitialTransactionId']).to eq(trans['Id'])
45
- expect(refund['DebitedWalletId']).to eq(trans['CreditedWalletId'])
46
- expect(refund['CreditedWalletId']).to eq(trans['DebitedWalletId'])
47
- end
48
- end
49
-
50
- describe 'CASH FLOW' do
51
- it 'changes balances correctly' do
52
- wlt1 = new_wallet
53
- wlt2 = new_wallet_legal
54
- wallets_check_amounts(wlt1, 0, wlt2, 0)
55
-
56
- # payin: feed wlt1 with money
57
- create_new_payin_card_direct(wlt1, 1000)
58
- wallets_reload_and_check_amounts(wlt1, 1000, wlt2, 0)
59
-
60
- # trnasfer wlt1 => wlt2
61
- trans = create_new_transfer(wlt1, wlt2, 600)
62
- wallets_reload_and_check_amounts(wlt1, 400, wlt2, 600)
63
-
64
- # refund the trnasfer
65
- refund = MangoPay::Transfer.refund(trans['Id'], {AuthorId: trans['AuthorId']})
66
- wallets_reload_and_check_amounts(wlt1, 1000, wlt2, 0)
67
- end
68
- end
69
- end
1
+ describe MangoPay::Transfer, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+ include_context 'transfers'
5
+
6
+ def check_type_and_status(trans)
7
+ expect(trans['Type']).to eq('TRANSFER')
8
+ expect(trans['Nature']).to eq('REGULAR')
9
+
10
+ # SUCCEEDED
11
+ expect(trans['Status']).to eq('SUCCEEDED')
12
+ expect(trans['ResultCode']).to eq('000000')
13
+ expect(trans['ResultMessage']).to eq('Success')
14
+ expect(trans['ExecutionDate']).to be > 0
15
+ end
16
+
17
+ describe 'CREATE' do
18
+ it 'creates a new Transfer' do
19
+ created = new_transfer
20
+ expect(created['Id']).not_to be_nil
21
+ check_type_and_status(created)
22
+ end
23
+ end
24
+
25
+ describe 'FETCH' do
26
+ it 'fetches a Transfer' do
27
+ created = new_transfer
28
+ fetched = MangoPay::Transfer.fetch(created['Id'])
29
+ expect(fetched['Id']).to eq(created['Id'])
30
+ check_type_and_status(created)
31
+ check_type_and_status(fetched)
32
+ end
33
+ end
34
+
35
+ describe 'REFUND' do
36
+ it 'refunds a transfer' do
37
+ trans = new_transfer
38
+ refund = MangoPay::Transfer.refund(trans['Id'], {AuthorId: trans['AuthorId']})
39
+ expect(refund['Id']).not_to be_nil
40
+ expect(refund['Status']).to eq('SUCCEEDED')
41
+ expect(refund['Type']).to eq('TRANSFER')
42
+ expect(refund['Nature']).to eq('REFUND')
43
+ expect(refund['InitialTransactionType']).to eq('TRANSFER')
44
+ expect(refund['InitialTransactionId']).to eq(trans['Id'])
45
+ expect(refund['DebitedWalletId']).to eq(trans['CreditedWalletId'])
46
+ expect(refund['CreditedWalletId']).to eq(trans['DebitedWalletId'])
47
+ end
48
+ end
49
+
50
+ describe 'CASH FLOW' do
51
+ it 'changes balances correctly' do
52
+ wlt1 = new_wallet
53
+ wlt2 = new_wallet_legal
54
+ wallets_check_amounts(wlt1, 0, wlt2, 0)
55
+
56
+ # payin: feed wlt1 with money
57
+ create_new_payin_card_direct(wlt1, 1000)
58
+ wallets_reload_and_check_amounts(wlt1, 1000, wlt2, 0)
59
+
60
+ # trnasfer wlt1 => wlt2
61
+ trans = create_new_transfer(wlt1, wlt2, 600)
62
+ wallets_reload_and_check_amounts(wlt1, 400, wlt2, 600)
63
+
64
+ # refund the trnasfer
65
+ refund = MangoPay::Transfer.refund(trans['Id'], {AuthorId: trans['AuthorId']})
66
+ wallets_reload_and_check_amounts(wlt1, 1000, wlt2, 0)
67
+ end
68
+ end
69
+ end
@@ -1,137 +1,137 @@
1
- describe MangoPay::User do
2
- include_context 'users'
3
- include_context 'payins'
4
- include_context 'payouts'
5
- include_context 'wallets'
6
-
7
- describe 'CREATE' do
8
- it 'creates a new natural user' do
9
- expect(new_natural_user["FirstName"]).to eq('John')
10
- end
11
-
12
- it 'creates a new legal user' do
13
- expect(new_legal_user["LegalRepresentativeFirstName"]).to eq('John')
14
- end
15
- end
16
-
17
- describe 'UPDATE' do
18
- it 'updates a natural user' do
19
- updated_user = MangoPay::NaturalUser.update(new_natural_user['Id'] ,{
20
- FirstName: 'Jack'
21
- })
22
- expect(updated_user['FirstName']).to eq('Jack')
23
- end
24
-
25
- it 'updates a legal user' do
26
- updated_user = MangoPay::LegalUser.update(new_legal_user['Id'], {
27
- LegalRepresentativeFirstName: 'Jack'
28
- })
29
- expect(updated_user['LegalRepresentativeFirstName']).to eq('Jack')
30
- end
31
- end
32
-
33
- describe 'FETCH' do
34
- it 'fetches all the users' do
35
- users = MangoPay::User.fetch()
36
- expect(users).to be_kind_of(Array)
37
- expect(users).not_to be_empty
38
- end
39
-
40
- it 'fetches a legal user using the User module' do
41
- legal_user = MangoPay::User.fetch(new_legal_user['Id'])
42
- expect(legal_user['Id']).to eq(new_legal_user['Id'])
43
- end
44
-
45
- it 'fetches a natural user using the User module' do
46
- natural_user = MangoPay::User.fetch(new_natural_user['Id'])
47
- expect(natural_user['Id']).to eq(new_natural_user['Id'])
48
- end
49
-
50
- it 'fetches a legal user' do
51
- user = MangoPay::LegalUser.fetch(new_legal_user['Id'])
52
- expect(user['Id']).to eq(new_legal_user['Id'])
53
- end
54
-
55
- it 'fetches a natural user' do
56
- user = MangoPay::NaturalUser.fetch(new_natural_user['Id'])
57
- expect(user['Id']).to eq(new_natural_user['Id'])
58
- end
59
- end
60
-
61
- describe 'FETCH TRANSACTIONS' do
62
- it 'fetches empty list of transactions if no transactions done' do
63
- transactions = MangoPay::User.transactions(new_natural_user['Id'])
64
- expect(transactions).to be_kind_of(Array)
65
- expect(transactions).to be_empty
66
- end
67
-
68
- it 'fetches list with single transaction after payin done' do
69
- payin = new_payin_card_direct
70
- transactions = MangoPay::User.transactions(new_natural_user['Id'])
71
- expect(transactions).to be_kind_of(Array)
72
- expect(transactions.count).to eq 1
73
- expect(transactions.first['Id']).to eq payin['Id']
74
- end
75
-
76
- it 'fetches list with two transactions after payin and payout done' do
77
- payin = new_payin_card_direct
78
- payout = create_new_payout_bankwire(payin)
79
- transactions = MangoPay::User.transactions(new_natural_user['Id'])
80
-
81
- expect(transactions).to be_kind_of(Array)
82
- expect(transactions.count).to eq 2
83
-
84
- transactions_ids = transactions.map {|t| t['Id']}
85
- expect(transactions_ids).to include payin['Id']
86
- expect(transactions_ids).to include payout['Id']
87
- end
88
- end
89
-
90
- describe 'FETCH WALLETS' do
91
- it 'fetches empty list of wallets if no wallets created' do
92
- wallets = MangoPay::User.wallets(new_natural_user['Id'])
93
- expect(wallets).to be_kind_of(Array)
94
- expect(wallets).to be_empty
95
- end
96
-
97
- it 'fetches list with single wallet after created' do
98
- wallet = new_wallet
99
- wallets = MangoPay::User.wallets(new_natural_user['Id'])
100
- expect(wallets).to be_kind_of(Array)
101
- expect(wallets.count).to eq 1
102
- expect(wallets.first['Id']).to eq wallet['Id']
103
- end
104
- end
105
-
106
- describe 'FETCH CARDS' do
107
- it 'fetches empty list of cards if no cards created' do
108
- cards = MangoPay::User.cards(new_natural_user['Id'])
109
- expect(cards).to be_kind_of(Array)
110
- expect(cards).to be_empty
111
- end
112
-
113
- it 'fetches list with single card after created' do
114
- card = new_card_registration_completed
115
- cards = MangoPay::User.cards(new_natural_user['Id'])
116
- expect(cards).to be_kind_of(Array)
117
- expect(cards.count).to eq 1
118
- expect(cards.first['Id']).to eq card['CardId']
119
- end
120
- end
121
-
122
- describe 'FETCH BANK ACCOUNTS' do
123
- it 'fetches empty list of bank accounts if no bank_accounts created' do
124
- bank_accounts = MangoPay::User.bank_accounts(new_natural_user['Id'])
125
- expect(bank_accounts).to be_kind_of(Array)
126
- expect(bank_accounts).to be_empty
127
- end
128
-
129
- it 'fetches list with single bank_account after created' do
130
- bank_account = new_bank_account
131
- bank_accounts = MangoPay::User.bank_accounts(new_natural_user['Id'])
132
- expect(bank_accounts).to be_kind_of(Array)
133
- expect(bank_accounts.count).to eq 1
134
- expect(bank_accounts.first['Id']).to eq bank_account['Id']
135
- end
136
- end
137
- end
1
+ describe MangoPay::User do
2
+ include_context 'users'
3
+ include_context 'payins'
4
+ include_context 'payouts'
5
+ include_context 'wallets'
6
+
7
+ describe 'CREATE' do
8
+ it 'creates a new natural user' do
9
+ expect(new_natural_user["FirstName"]).to eq('John')
10
+ end
11
+
12
+ it 'creates a new legal user' do
13
+ expect(new_legal_user["LegalRepresentativeFirstName"]).to eq('John')
14
+ end
15
+ end
16
+
17
+ describe 'UPDATE' do
18
+ it 'updates a natural user' do
19
+ updated_user = MangoPay::NaturalUser.update(new_natural_user['Id'] ,{
20
+ FirstName: 'Jack'
21
+ })
22
+ expect(updated_user['FirstName']).to eq('Jack')
23
+ end
24
+
25
+ it 'updates a legal user' do
26
+ updated_user = MangoPay::LegalUser.update(new_legal_user['Id'], {
27
+ LegalRepresentativeFirstName: 'Jack'
28
+ })
29
+ expect(updated_user['LegalRepresentativeFirstName']).to eq('Jack')
30
+ end
31
+ end
32
+
33
+ describe 'FETCH' do
34
+ it 'fetches all the users' do
35
+ users = MangoPay::User.fetch()
36
+ expect(users).to be_kind_of(Array)
37
+ expect(users).not_to be_empty
38
+ end
39
+
40
+ it 'fetches a legal user using the User module' do
41
+ legal_user = MangoPay::User.fetch(new_legal_user['Id'])
42
+ expect(legal_user['Id']).to eq(new_legal_user['Id'])
43
+ end
44
+
45
+ it 'fetches a natural user using the User module' do
46
+ natural_user = MangoPay::User.fetch(new_natural_user['Id'])
47
+ expect(natural_user['Id']).to eq(new_natural_user['Id'])
48
+ end
49
+
50
+ it 'fetches a legal user' do
51
+ user = MangoPay::LegalUser.fetch(new_legal_user['Id'])
52
+ expect(user['Id']).to eq(new_legal_user['Id'])
53
+ end
54
+
55
+ it 'fetches a natural user' do
56
+ user = MangoPay::NaturalUser.fetch(new_natural_user['Id'])
57
+ expect(user['Id']).to eq(new_natural_user['Id'])
58
+ end
59
+ end
60
+
61
+ describe 'FETCH TRANSACTIONS' do
62
+ it 'fetches empty list of transactions if no transactions done' do
63
+ transactions = MangoPay::User.transactions(new_natural_user['Id'])
64
+ expect(transactions).to be_kind_of(Array)
65
+ expect(transactions).to be_empty
66
+ end
67
+
68
+ it 'fetches list with single transaction after payin done' do
69
+ payin = new_payin_card_direct
70
+ transactions = MangoPay::User.transactions(new_natural_user['Id'])
71
+ expect(transactions).to be_kind_of(Array)
72
+ expect(transactions.count).to eq 1
73
+ expect(transactions.first['Id']).to eq payin['Id']
74
+ end
75
+
76
+ it 'fetches list with two transactions after payin and payout done' do
77
+ payin = new_payin_card_direct
78
+ payout = create_new_payout_bankwire(payin)
79
+ transactions = MangoPay::User.transactions(new_natural_user['Id'])
80
+
81
+ expect(transactions).to be_kind_of(Array)
82
+ expect(transactions.count).to eq 2
83
+
84
+ transactions_ids = transactions.map {|t| t['Id']}
85
+ expect(transactions_ids).to include payin['Id']
86
+ expect(transactions_ids).to include payout['Id']
87
+ end
88
+ end
89
+
90
+ describe 'FETCH WALLETS' do
91
+ it 'fetches empty list of wallets if no wallets created' do
92
+ wallets = MangoPay::User.wallets(new_natural_user['Id'])
93
+ expect(wallets).to be_kind_of(Array)
94
+ expect(wallets).to be_empty
95
+ end
96
+
97
+ it 'fetches list with single wallet after created' do
98
+ wallet = new_wallet
99
+ wallets = MangoPay::User.wallets(new_natural_user['Id'])
100
+ expect(wallets).to be_kind_of(Array)
101
+ expect(wallets.count).to eq 1
102
+ expect(wallets.first['Id']).to eq wallet['Id']
103
+ end
104
+ end
105
+
106
+ describe 'FETCH CARDS' do
107
+ it 'fetches empty list of cards if no cards created' do
108
+ cards = MangoPay::User.cards(new_natural_user['Id'])
109
+ expect(cards).to be_kind_of(Array)
110
+ expect(cards).to be_empty
111
+ end
112
+
113
+ it 'fetches list with single card after created' do
114
+ card = new_card_registration_completed
115
+ cards = MangoPay::User.cards(new_natural_user['Id'])
116
+ expect(cards).to be_kind_of(Array)
117
+ expect(cards.count).to eq 1
118
+ expect(cards.first['Id']).to eq card['CardId']
119
+ end
120
+ end
121
+
122
+ describe 'FETCH BANK ACCOUNTS' do
123
+ it 'fetches empty list of bank accounts if no bank_accounts created' do
124
+ bank_accounts = MangoPay::User.bank_accounts(new_natural_user['Id'])
125
+ expect(bank_accounts).to be_kind_of(Array)
126
+ expect(bank_accounts).to be_empty
127
+ end
128
+
129
+ it 'fetches list with single bank_account after created' do
130
+ bank_account = new_bank_account
131
+ bank_accounts = MangoPay::User.bank_accounts(new_natural_user['Id'])
132
+ expect(bank_accounts).to be_kind_of(Array)
133
+ expect(bank_accounts.count).to eq 1
134
+ expect(bank_accounts.first['Id']).to eq bank_account['Id']
135
+ end
136
+ end
137
+ end