leetchi-wallet-services 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -11
  3. data/Gemfile.lock +27 -18
  4. data/README.md +3 -3
  5. data/Rakefile +3 -6
  6. data/lib/leetchi/beneficiary.rb +0 -1
  7. data/lib/leetchi/expense.rb +2 -2
  8. data/lib/leetchi/recurrent_contribution.rb +24 -0
  9. data/lib/leetchi/ressource.rb +24 -3
  10. data/lib/leetchi/strong_authentication.rb +13 -0
  11. data/lib/leetchi/withdrawal.rb +0 -1
  12. data/lib/leetchi/withdrawal_contribution.rb +32 -0
  13. data/lib/leetchi-wallet-services.rb +2 -2
  14. data/spec/cassettes/card.yml +1381 -0
  15. data/spec/cassettes/contribution.yml +691 -0
  16. data/spec/cassettes/expense.yml +89 -0
  17. data/spec/cassettes/operation.yml +89 -0
  18. data/spec/cassettes/transfer.yml +347 -0
  19. data/spec/cassettes/user.yml +1262 -0
  20. data/spec/cassettes/wallet.yml +863 -0
  21. data/spec/cassettes/withdrawal.yml +433 -0
  22. data/spec/lib/leetchi/beneficiary_spec.rb +26 -32
  23. data/spec/lib/leetchi/card_spec.rb +8 -14
  24. data/spec/lib/leetchi/contribution_spec.rb +11 -17
  25. data/spec/lib/leetchi/expense_spec.rb +0 -7
  26. data/spec/lib/leetchi/operation_spec.rb +0 -6
  27. data/spec/lib/leetchi/recurrent_contribution_spec.rb +48 -41
  28. data/spec/lib/leetchi/ressource_spec.rb +1 -3
  29. data/spec/lib/leetchi/strong_authentication_spec.rb +50 -10
  30. data/spec/lib/leetchi/transfer_spec.rb +9 -14
  31. data/spec/lib/leetchi/user_spec.rb +27 -34
  32. data/spec/lib/leetchi/wallet_spec.rb +16 -22
  33. data/spec/lib/leetchi/withdrawal_contribution_spec.rb +44 -0
  34. data/spec/lib/leetchi/withdrawal_spec.rb +13 -19
  35. data/spec/spec_helper.rb +60 -24
  36. data/spec/support-files/test_upload.gif +0 -0
  37. data/spec/support-files/test_upload.jpg +0 -0
  38. data/spec/support-files/test_upload.pdf +0 -0
  39. data/spec/support-files/test_upload.png +0 -0
  40. metadata +150 -170
  41. data/spec/fixtures/leetchi_cassettes/beneficiary.yml +0 -40500
  42. data/spec/fixtures/leetchi_cassettes/card.yml +0 -15985
  43. data/spec/fixtures/leetchi_cassettes/contribution.yml +0 -35737
  44. data/spec/fixtures/leetchi_cassettes/expense-site.yml +0 -45
  45. data/spec/fixtures/leetchi_cassettes/expense.yml +0 -495
  46. data/spec/fixtures/leetchi_cassettes/operation.yml +0 -495
  47. data/spec/fixtures/leetchi_cassettes/recurrent_contribution.yml +0 -2060
  48. data/spec/fixtures/leetchi_cassettes/strong_authentication.yml +0 -577
  49. data/spec/fixtures/leetchi_cassettes/transfer.yml +0 -31387
  50. data/spec/fixtures/leetchi_cassettes/user.yml +0 -44428
  51. data/spec/fixtures/leetchi_cassettes/wallet.yml +0 -35099
  52. data/spec/fixtures/leetchi_cassettes/withdrawal.yml +0 -20722
@@ -1,8 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
- describe Leetchi::Card do
4
-
5
- include Capybara::DSL
3
+ describe Leetchi::Card, :type => :feature do
6
4
 
7
5
  let(:new_user) {
8
6
  Leetchi::User.create({
@@ -24,34 +22,30 @@ describe Leetchi::Card do
24
22
  fill_in('number', :with => '4970100000000154')
25
23
  fill_in('cvv', :with => '123')
26
24
  click_button('paybutton')
27
- page.driver.render('/Users/glorieux/Desktop/file.png')
25
+ card = Leetchi::Card.details(card['ID'])
26
+ while card["IsSucceeded"] == false do
27
+ card = Leetchi::Card.details(card['ID'])
28
+ end
28
29
  card
29
30
  end
30
31
 
31
- before do
32
- VCR.insert_cassette 'card', :record => :new_episodes
33
- end
34
- after do
35
- VCR.eject_cassette
36
- end
37
-
38
32
  describe "CREATE" do
39
33
  it "create a new card and return a redirect url" do
40
- new_card['RedirectURL'].wont_be_empty
34
+ expect(new_card['RedirectURL']).not_to be_empty
41
35
  end
42
36
  end
43
37
 
44
38
  describe "GET" do
45
39
  it "get the users card" do
46
40
  card = Leetchi::Card.details(new_card["ID"])
47
- card["ID"].must_equal new_card["ID"]
41
+ expect(card["ID"]).to eq(new_card["ID"])
48
42
  end
49
43
  end
50
44
 
51
45
  describe "DELETE" do
52
46
  it "delete the card" do
53
47
  deleted_card = Leetchi::Card.delete(new_card["ID"])
54
- deleted_card.must_equal "\"OK\""
48
+ expect(deleted_card).to eq("\"OK\"")
55
49
  end
56
50
  end
57
51
 
@@ -1,15 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
- describe Leetchi::Contribution do
4
-
5
- include Capybara::DSL
6
-
7
- before do
8
- VCR.insert_cassette 'contribution', :record => :new_episodes
9
- end
10
- after do
11
- VCR.eject_cassette
12
- end
3
+ describe Leetchi::Contribution, :type => :feature do
13
4
 
14
5
  let(:new_user) {
15
6
  Leetchi::User.create({
@@ -27,13 +18,16 @@ describe Leetchi::Contribution do
27
18
  'UserID' => new_user['ID'],
28
19
  'WalletID' => 0,
29
20
  'Amount' => 10000,
30
- 'ReturnURL' => 'https://leetchi.com',
31
- 'BankAccountBIC' => 'AGRIFRPP879'
21
+ 'ReturnURL' => 'https://leetchi.com'
32
22
  })
33
23
  visit(contribution['PaymentURL'])
34
24
  fill_in('number', :with => '4970100000000154')
35
25
  fill_in('cvv', :with => '123')
36
26
  click_button('paybutton')
27
+ contribution = Leetchi::Contribution.details(contribution['ID'])
28
+ while contribution["IsSucceeded"] == false do
29
+ contribution = Leetchi::Contribution.details(contribution['ID'])
30
+ end
37
31
  contribution
38
32
  end
39
33
 
@@ -47,25 +41,25 @@ describe Leetchi::Contribution do
47
41
 
48
42
  describe "CREATE" do
49
43
  it "creates a contribution" do
50
- new_contribution['ID'].wont_be_nil
51
- new_contribution['PaymentURL'].wont_be_nil
44
+ expect(new_contribution['ID']).not_to be_nil
45
+ expect(new_contribution['PaymentURL']).not_to be_nil
52
46
  end
53
47
  end
54
48
 
55
49
  describe "GET" do
56
50
  it "get the contribution" do
57
51
  contribution = Leetchi::Contribution.details(new_contribution['ID'])
58
- contribution['ID'].must_equal new_contribution['ID']
52
+ expect(contribution['ID']).to eq(new_contribution['ID'])
59
53
  end
60
54
  end
61
55
 
62
56
  describe "REFUND" do
63
57
  it "creates a refund request for the contribution" do
64
- new_contribution_refund['ID'].wont_be_nil
58
+ expect(new_contribution_refund['ID']).not_to be_nil
65
59
  end
66
60
  it "gets the refund request" do
67
61
  contribution_refund = Leetchi::Contribution.get_refund(new_contribution_refund['ID'])
68
- contribution_refund['ID'].must_equal new_contribution_refund['ID']
62
+ expect(contribution_refund['ID']).to eq(new_contribution_refund['ID'])
69
63
  end
70
64
  end
71
65
  end
@@ -2,13 +2,6 @@ require_relative '../../spec_helper'
2
2
 
3
3
  describe Leetchi::Expense do
4
4
 
5
- before do
6
- VCR.insert_cassette 'expense', :record => :new_episodes
7
- end
8
- after do
9
- VCR.eject_cassette
10
- end
11
-
12
5
  describe "GET" do
13
6
  it "get the expense" do
14
7
  card = Leetchi::Expense.get(1)
@@ -1,12 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
3
  describe Leetchi::Operation do
4
- before do
5
- VCR.insert_cassette 'operation', :record => :new_episodes
6
- end
7
- after do
8
- VCR.eject_cassette
9
- end
10
4
 
11
5
  it "gets the operation" do
12
6
  operation = Leetchi::Operation.get(1)
@@ -1,48 +1,55 @@
1
- # require_relative '../../spec_helper'
1
+ require_relative '../../spec_helper'
2
2
 
3
- # describe Leetchi::RecurrentContribution do
3
+ describe Leetchi::RecurrentContribution do
4
4
 
5
- # let(:new_user) {
6
- # Leetchi::User.create({
7
- # 'Tag' => 'test',
8
- # 'Email' => 'my@email.com',
9
- # 'FirstName' => 'John',
10
- # 'LastName' => 'Doe',
11
- # 'CanRegisterMeanOfPayment' => true
12
- # })
13
- # }
5
+ let(:new_user) {
6
+ Leetchi::User.create({
7
+ 'Tag' => 'test',
8
+ 'Email' => 'my@email.com',
9
+ 'FirstName' => 'John',
10
+ 'LastName' => 'Doe',
11
+ 'CanRegisterMeanOfPayment' => true
12
+ })
13
+ }
14
14
 
15
- # let(:new_recurrent_contribution) {
16
- # Leetchi::RecurrentContribution.create({
17
- # 'Tag' => 'test-recurrent-contribution',
18
- # 'UserID' => new_user['ID'],
19
- # 'WalletID' => 0,
20
- # 'Amount' => 4200,
21
- # 'StartDate' => '1388534400',
22
- # 'FrequencyCode' => 'TwiceMonthly',
23
- # 'NumberOfExecutions' => 10,
24
- # 'ReturnURL' => 'http://leetchi.com'
25
- # })
26
- # }
15
+ let(:new_recurrent_contribution) {
16
+ Leetchi::RecurrentContribution.create({
17
+ 'Tag' => 'test-recurrent-contribution',
18
+ 'UserID' => new_user['ID'],
19
+ 'WalletID' => 0,
20
+ 'Amount' => 4200,
21
+ 'StartDate' => '1388534400',
22
+ 'FrequencyCode' => 'TwiceMonthly',
23
+ 'NumberOfExecutions' => 10,
24
+ 'ReturnURL' => 'http://leetchi.com'
25
+ })
26
+ }
27
27
 
28
- # before do
29
- # VCR.insert_cassette 'recurrent_contribution', :record => :new_episodes
30
- # end
31
- # after do
32
- # VCR.eject_cassette
33
- # end
28
+ describe "CREATE" do
29
+ it "create a new recurrent contribution and return a PaymentURL" do
30
+ expect(new_recurrent_contribution['PaymentURL']).not_to be_empty
31
+ end
32
+ end
34
33
 
35
- # describe "CREATE" do
36
- # it "create a new recurrent contribution and return a PaymentURL" do
37
- # new_recurrent_contribution['PaymentURL'].wont_be_empty
38
- # end
39
- # end
34
+ describe "GET" do
35
+ it "get a recurrent contribution" do
36
+ recurrent_contribution = Leetchi::RecurrentContribution.get(new_recurrent_contribution["ID"])
37
+ expect(recurrent_contribution["ID"]).to eq(new_recurrent_contribution["ID"])
38
+ end
39
+ end
40
40
 
41
- # describe "GET" do
42
- # it "get a recurrent contribution" do
43
- # recurrent_contribution = Leetchi::RecurrentContribution.get(new_recurrent_contribution["ID"])
44
- # recurrent_contribution["ID"].must_equal new_recurrent_contribution["ID"]
45
- # end
46
- # end
41
+ describe "UPDATE" do
42
+ it "updates a recurrent contribution" do
43
+ recurrent_contribution = Leetchi::RecurrentContribution.update(new_recurrent_contribution["ID"], { :IsEnabled => false })
44
+ expect(recurrent_contribution["IsEnabled"]).to be_false
45
+ end
46
+ end
47
47
 
48
- # end
48
+ describe "GET_EXECUTIONS" do
49
+ it "get a list of the recurrent contribution executions" do
50
+ recurrent_contribution_executions = Leetchi::RecurrentContribution.get_executions(new_recurrent_contribution["ID"])
51
+ expect(recurrent_contribution_executions).to be_a_kind_of(Array)
52
+ expect(recurrent_contribution_executions).to be_empty
53
+ end
54
+ end
55
+ end
@@ -1,7 +1,5 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
3
  describe Leetchi::Ressource do
4
- it "must work" do
5
- "Yay!".must_be_instance_of String
6
- end
4
+ pending "It should test the ressource"
7
5
  end
@@ -1,17 +1,57 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
3
  describe Leetchi::StrongAuthentication do
4
- before do
5
- VCR.insert_cassette 'strong_authentication', :record => :new_episodes
6
- end
7
- after do
8
- VCR.eject_cassette
4
+
5
+ let(:new_user) {
6
+ Leetchi::User.create({
7
+ 'Tag' => 'test',
8
+ 'Email' => 'my@email.com',
9
+ 'FirstName' => 'John',
10
+ 'LastName' => 'Doe',
11
+ 'CanRegisterMeanOfPayment' => true
12
+ })
13
+ }
14
+
15
+ let(:new_beneficiary) {
16
+ Leetchi::Beneficiary.create({
17
+ 'Tag' => 'test',
18
+ 'UserID' => new_user['ID'],
19
+ 'BankAccountOwnerName' => new_user['FirstName'],
20
+ 'BankAccountOwnerAddress' => '1 bis cite paradis',
21
+ 'BankAccountIBAN' => 'FR76 1790 6000 3200 0833 5232 973',
22
+ 'BankAccountBIC' => 'AGRIFRPP879'
23
+ })
24
+ }
25
+
26
+ let(:new_strong_authentication) {
27
+ Leetchi::Beneficiary.create_strong_authentication(new_beneficiary['ID'], {
28
+ 'Tag' => 'test_beneficiary_strong_authentication'
29
+ })
30
+ }
31
+
32
+ describe "GET" do
33
+ it "get the pending strong authentication requests" do
34
+ strong_authentication = Leetchi::StrongAuthentication.get
35
+ expect(strong_authentication).to be_kind_of(Array)
9
36
  end
37
+ end
10
38
 
11
- describe "GET" do
12
- it "get the pending strong authentication requests" do
13
- strong_authentication = Leetchi::StrongAuthentication.get
14
- strong_authentication.must_be_kind_of Array
15
- end
39
+ describe "UPLOAD" do
40
+ it "uploads a PDF file to complete a beneficiary strong authentication request" do
41
+ document_upload = Leetchi::StrongAuthentication.upload(new_strong_authentication['UrlRequest'], 'spec/support-files/test_upload.pdf')
42
+ expect(document_upload).to be_true
43
+ end
44
+ it "uploads a JPG file to complete a beneficiary strong authentication request" do
45
+ document_upload = Leetchi::StrongAuthentication.upload(new_strong_authentication['UrlRequest'], 'spec/support-files/test_upload.jpg')
46
+ expect(document_upload).to be_true
47
+ end
48
+ it "uploads a PNG file to complete a beneficiary strong authentication request" do
49
+ document_upload = Leetchi::StrongAuthentication.upload(new_strong_authentication['UrlRequest'], 'spec/support-files/test_upload.png')
50
+ expect(document_upload).to be_true
51
+ end
52
+ it "uploads a GIF file to complete a beneficiary strong authentication request" do
53
+ document_upload = Leetchi::StrongAuthentication.upload(new_strong_authentication['UrlRequest'], 'spec/support-files/test_upload.gif')
54
+ expect(document_upload).to be_true
16
55
  end
56
+ end
17
57
  end
@@ -1,15 +1,6 @@
1
1
  require_relative '../../spec_helper'
2
2
 
3
- describe Leetchi::Transfer do
4
-
5
- include Capybara::DSL
6
-
7
- before do
8
- VCR.insert_cassette 'transfer', :record => :new_episodes
9
- end
10
- after do
11
- VCR.eject_cassette
12
- end
3
+ describe Leetchi::Transfer, :type => :feature do
13
4
 
14
5
  let(:new_payer) {
15
6
  user = Leetchi::User.create({
@@ -31,6 +22,10 @@ describe Leetchi::Transfer do
31
22
  fill_in('number', :with => '4970100000000154')
32
23
  fill_in('cvv', :with => '123')
33
24
  click_button('paybutton')
25
+ contribution = Leetchi::Contribution.details(contribution['ID'])
26
+ while contribution["IsSucceeded"] == false do
27
+ contribution = Leetchi::Contribution.details(contribution['ID'])
28
+ end
34
29
  user
35
30
  }
36
31
 
@@ -70,24 +65,24 @@ describe Leetchi::Transfer do
70
65
 
71
66
  describe "CREATE" do
72
67
  it "create a transfer" do
73
- new_transfert['ID'].wont_be_nil
68
+ expect(new_transfert['ID']).not_to be_nil
74
69
  end
75
70
  end
76
71
 
77
72
  describe "GET" do
78
73
  it "gets the transfer" do
79
74
  transfert = Leetchi::Transfer.details(new_transfert['ID'])
80
- transfert['ID'].must_equal new_transfert['ID']
75
+ expect(transfert['ID']).to eq(new_transfert['ID'])
81
76
  end
82
77
  end
83
78
 
84
79
  describe "REFUND" do
85
80
  it "create a refund for the transfer" do
86
- new_transfer_refund['ID'].wont_be_nil
81
+ expect(new_transfer_refund['ID']).not_to be_nil
87
82
  end
88
83
  it "gets a the transfer refund" do
89
84
  transfer_refund = Leetchi::Transfer.get_refund(new_transfer_refund['ID'])
90
- transfer_refund['ID'].must_equal new_transfer_refund['ID']
85
+ expect(transfer_refund['ID']).to eq(new_transfer_refund['ID'])
91
86
  end
92
87
  end
93
88
  end
@@ -26,20 +26,13 @@ describe Leetchi::User do
26
26
  })
27
27
  }
28
28
 
29
- before do
30
- VCR.insert_cassette 'user', :record => :new_episodes
31
- end
32
- after do
33
- VCR.eject_cassette
34
- end
35
-
36
29
  describe "CREATE" do
37
30
  it "create a user" do
38
- new_user["FirstName"].must_equal 'John'
39
- new_user["LastName"].must_equal 'Doe'
40
- new_user["Email"].must_equal 'my@email.com'
41
- new_user["CanRegisterMeanOfPayment"].must_equal true
42
- new_user["ID"].wont_be_nil
31
+ expect(new_user["FirstName"]).to eq('John')
32
+ expect(new_user["LastName"]).to eq('Doe')
33
+ expect(new_user["Email"]).to eq('my@email.com')
34
+ expect(new_user["CanRegisterMeanOfPayment"]).to be_true
35
+ expect(new_user["ID"]).not_to be_nil
43
36
  end
44
37
  end
45
38
 
@@ -47,10 +40,10 @@ describe Leetchi::User do
47
40
  it "gets the user infos" do
48
41
  user = Leetchi::User.details(new_user["ID"])
49
42
 
50
- user["FirstName"].must_equal new_user["FirstName"]
51
- user["LastName"].must_equal new_user["LastName"]
52
- user["Email"].must_equal new_user["Email"]
53
- user["ID"].must_equal new_user["ID"]
43
+ expect(user["FirstName"]).to eq(new_user["FirstName"])
44
+ expect(user["LastName"]).to eq(new_user["LastName"])
45
+ expect(user["Email"]).to eq(new_user["Email"])
46
+ expect(user["ID"]).to eq(new_user["ID"])
54
47
  end
55
48
  end
56
49
 
@@ -63,69 +56,69 @@ describe Leetchi::User do
63
56
  'LastName' => 'Black',
64
57
  'CanRegisterMeanOfPayment' => false
65
58
  })
66
- user["FirstName"].must_equal 'Jack'
67
- user["LastName"].must_equal 'Black'
68
- user["Email"].must_equal 'mynew@email.com'
69
- user["CanRegisterMeanOfPayment"].must_equal false
70
- user["ID"].must_equal new_user["ID"]
59
+ expect(user["FirstName"]).to eq('Jack')
60
+ expect(user["LastName"]).to eq('Black')
61
+ expect(user["Email"]).to eq('mynew@email.com')
62
+ expect(user["CanRegisterMeanOfPayment"]).to be_false
63
+ expect(user["ID"]).to eq(new_user["ID"])
71
64
  end
72
65
  end
73
66
 
74
67
  describe "GET_WALLETS" do
75
68
  it "get an empty list of wallets" do
76
69
  wallets = Leetchi::User.get_wallets(new_user["ID"])
77
- wallets.must_be_empty
70
+ expect(wallets).to be_empty
78
71
  end
79
72
  it "gets a new wallet for the user" do
80
73
  new_wallet
81
74
  wallets = Leetchi::User.get_wallets(new_user['ID'])
82
- wallets.wont_be_empty
83
- wallets[0]["Owners"][0].must_equal new_user['ID']
75
+ expect(wallets).not_to be_empty
76
+ expect(wallets[0]["Owners"][0]).to eq(new_user['ID'])
84
77
  end
85
78
  end
86
79
 
87
80
  describe "CARDS" do
88
81
  it "gets the user cards" do
89
82
  cards = Leetchi::User.cards(new_user["ID"])
90
- cards.must_be_empty
83
+ expect(cards).to be_empty
91
84
  end
92
85
  end
93
86
 
94
87
  describe "OPERATIONS" do
95
88
  it "gets all the users operations" do
96
89
  operations = Leetchi::User.operations(new_user['ID'])
97
- operations.must_be_empty
90
+ expect(operations).to be_empty
98
91
  end
99
92
  it "gets all the users personal operation" do
100
93
  personal_operations = Leetchi::User.personal_operations(new_user['ID'])
101
- personal_operations.must_be_empty
94
+ expect(personal_operations).to be_empty
102
95
  end
103
96
  end
104
97
 
105
98
  describe "STRONG_AUTHENTICATION" do
106
99
  it "creates a new strong authentication request" do
107
- new_strong_authentication['ID'].wont_be_nil
100
+ expect(new_strong_authentication['ID']).not_to be_nil
108
101
  end
109
102
  it "gets the user strong authentication request" do
110
103
  strong_authentication = Leetchi::User.get_strong_authentication(new_strong_authentication['UserID'])
111
- strong_authentication['ID'].must_equal new_strong_authentication['ID']
104
+ expect(strong_authentication['ID']).to eq(new_strong_authentication['ID'])
112
105
  end
113
106
  it "updates the user strong authentication request" do
114
107
  strong_authentication = Leetchi::User.update_strong_authentication(new_strong_authentication['UserID'], {
115
108
  'Tag' => 'test_strong_authentication2',
116
109
  'IsDocumentsTransmitted' => true
117
110
  })
118
- strong_authentication['ID'].must_equal new_strong_authentication['ID']
119
- strong_authentication['UserID'].must_equal new_strong_authentication['UserID']
120
- strong_authentication['Tag'].must_equal 'test_strong_authentication2'
121
- strong_authentication['IsDocumentsTransmitted'].must_equal true
111
+ expect(strong_authentication['ID']).to eq(new_strong_authentication['ID'])
112
+ expect(strong_authentication['UserID']).to eq(new_strong_authentication['UserID'])
113
+ expect(strong_authentication['Tag']).to eq('test_strong_authentication2')
114
+ expect(strong_authentication['IsDocumentsTransmitted']).to be_true
122
115
  end
123
116
  end
124
117
 
125
118
  describe "EXPENSE_SITES" do
126
119
  it "get the expense sites for the given user" do
127
120
  expense_sites = Leetchi::User.expense_sites(new_user['ID'], new_wallet['ID'])
128
- expense_sites.must_be_kind_of Array
121
+ expect(expense_sites).to be_kind_of(Array)
129
122
  end
130
123
  end
131
124
  end