mangopay 3.0.25.pre.alpha.pre.20 → 3.0.25

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -28
  3. data/.rspec +2 -2
  4. data/.travis.yml +4 -13
  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 +225 -225
  12. data/lib/mangopay/authorization_token.rb +88 -88
  13. data/lib/mangopay/bank_account.rb +38 -38
  14. data/lib/mangopay/card.rb +8 -8
  15. data/lib/mangopay/card_registration.rb +9 -9
  16. data/lib/mangopay/client.rb +74 -74
  17. data/lib/mangopay/dispute.rb +130 -130
  18. data/lib/mangopay/errors.rb +61 -61
  19. data/lib/mangopay/event.rb +18 -18
  20. data/lib/mangopay/filter_parameters.rb +46 -46
  21. data/lib/mangopay/hook.rb +9 -9
  22. data/lib/mangopay/http_calls.rb +85 -85
  23. data/lib/mangopay/json.rb +14 -14
  24. data/lib/mangopay/kyc_document.rb +70 -70
  25. data/lib/mangopay/legal_user.rb +15 -15
  26. data/lib/mangopay/mandate.rb +32 -32
  27. data/lib/mangopay/natural_user.rb +14 -14
  28. data/lib/mangopay/pay_in.rb +85 -85
  29. data/lib/mangopay/pay_out.rb +14 -14
  30. data/lib/mangopay/pre_authorization.rb +13 -13
  31. data/lib/mangopay/refund.rb +7 -7
  32. data/lib/mangopay/report.rb +17 -17
  33. data/lib/mangopay/resource.rb +21 -21
  34. data/lib/mangopay/temp.rb +74 -74
  35. data/lib/mangopay/transaction.rb +24 -24
  36. data/lib/mangopay/transfer.rb +9 -9
  37. data/lib/mangopay/user.rb +43 -43
  38. data/lib/mangopay/version.rb +3 -3
  39. data/lib/mangopay/wallet.rb +17 -17
  40. data/mangopay.gemspec +30 -31
  41. data/spec/mangopay/authorization_token_spec.rb +70 -70
  42. data/spec/mangopay/bank_account_spec.rb +97 -97
  43. data/spec/mangopay/card_registration_spec.rb +73 -73
  44. data/spec/mangopay/client_spec.rb +110 -110
  45. data/spec/mangopay/configuration_spec.rb +95 -95
  46. data/spec/mangopay/dispute_spec.rb +262 -262
  47. data/spec/mangopay/event_spec.rb +31 -31
  48. data/spec/mangopay/fetch_filters_spec.rb +63 -63
  49. data/spec/mangopay/hook_spec.rb +37 -37
  50. data/spec/mangopay/idempotency_spec.rb +41 -41
  51. data/spec/mangopay/kyc_document_spec.rb +103 -103
  52. data/spec/mangopay/log_requests_filter_spec.rb +25 -25
  53. data/spec/mangopay/mandate_spec.rb +92 -92
  54. data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
  55. data/spec/mangopay/payin_card_direct_spec.rb +68 -68
  56. data/spec/mangopay/payin_card_web_spec.rb +38 -38
  57. data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
  58. data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
  59. data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
  60. data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
  61. data/spec/mangopay/payout_bankwire_spec.rb +54 -54
  62. data/spec/mangopay/preauthorization_spec.rb +42 -42
  63. data/spec/mangopay/refund_spec.rb +21 -21
  64. data/spec/mangopay/report_spec.rb +39 -39
  65. data/spec/mangopay/shared_resources.rb +381 -381
  66. data/spec/mangopay/temp_paymentcard_spec.rb +31 -31
  67. data/spec/mangopay/transaction_spec.rb +54 -54
  68. data/spec/mangopay/transfer_spec.rb +69 -69
  69. data/spec/mangopay/user_spec.rb +137 -137
  70. data/spec/mangopay/wallet_spec.rb +80 -80
  71. data/spec/spec_helper.rb +31 -31
  72. metadata +5 -5
@@ -1,31 +1,31 @@
1
- describe MangoPay::Temp::PaymentCard do
2
- include_context 'users'
3
-
4
- def new_temp_paymentcard
5
- MangoPay::Temp::PaymentCard.create({
6
- Tag: 'Test temp payment card',
7
- UserId: new_natural_user['Id'],
8
- Culture: 'FR',
9
- ReturnURL: 'https://mysite.com/return',
10
- TemplateURL: 'https://mysite.com/template'
11
- })
12
- end
13
-
14
- describe 'CREATE' do
15
- it 'creates a temp payment card' do
16
- created = new_temp_paymentcard
17
- expect(created['Id']).to_not be_nil
18
- expect(created['UserId']).to eq(new_natural_user['Id'])
19
- end
20
- end
21
-
22
- describe 'FETCH' do
23
- it 'fetches a temp payment card' do
24
- created = new_temp_paymentcard
25
- fetched = MangoPay::Temp::PaymentCard.fetch(created['Id'])
26
- expect(fetched['Id']).to eq(created['Id'])
27
- expect(fetched['UserId']).to eq(created['UserId'])
28
- end
29
- end
30
-
31
- end
1
+ describe MangoPay::Temp::PaymentCard do
2
+ include_context 'users'
3
+
4
+ def new_temp_paymentcard
5
+ MangoPay::Temp::PaymentCard.create({
6
+ Tag: 'Test temp payment card',
7
+ UserId: new_natural_user['Id'],
8
+ Culture: 'FR',
9
+ ReturnURL: 'https://mysite.com/return',
10
+ TemplateURL: 'https://mysite.com/template'
11
+ })
12
+ end
13
+
14
+ describe 'CREATE' do
15
+ it 'creates a temp payment card' do
16
+ created = new_temp_paymentcard
17
+ expect(created['Id']).to_not be_nil
18
+ expect(created['UserId']).to eq(new_natural_user['Id'])
19
+ end
20
+ end
21
+
22
+ describe 'FETCH' do
23
+ it 'fetches a temp payment card' do
24
+ created = new_temp_paymentcard
25
+ fetched = MangoPay::Temp::PaymentCard.fetch(created['Id'])
26
+ expect(fetched['Id']).to eq(created['Id'])
27
+ expect(fetched['UserId']).to eq(created['UserId'])
28
+ end
29
+ end
30
+
31
+ end
@@ -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