leetchi-wallet-services 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +51 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +26 -0
- data/README.md +64 -0
- data/Rakefile +8 -0
- data/lib/leetchi-wallet-services.rb +21 -0
- data/lib/leetchi/beneficiary.rb +73 -0
- data/lib/leetchi/card.rb +42 -0
- data/lib/leetchi/contribution.rb +61 -0
- data/lib/leetchi/expense.rb +17 -0
- data/lib/leetchi/operation.rb +16 -0
- data/lib/leetchi/recurrent_contribution.rb +38 -0
- data/lib/leetchi/ressource.rb +75 -0
- data/lib/leetchi/strong_authentication.rb +15 -0
- data/lib/leetchi/transfer.rb +58 -0
- data/lib/leetchi/user.rb +148 -0
- data/lib/leetchi/wallet.rb +93 -0
- data/lib/leetchi/withdrawal.rb +41 -0
- data/spec/fixtures/leetchi_cassettes/beneficiary.yml +26926 -0
- data/spec/fixtures/leetchi_cassettes/card.yml +10524 -0
- data/spec/fixtures/leetchi_cassettes/contribution.yml +8175 -0
- data/spec/fixtures/leetchi_cassettes/expense-site.yml +45 -0
- data/spec/fixtures/leetchi_cassettes/expense.yml +126 -0
- data/spec/fixtures/leetchi_cassettes/operation.yml +126 -0
- data/spec/fixtures/leetchi_cassettes/recurrent_contribution.yml +564 -0
- data/spec/fixtures/leetchi_cassettes/strong_authentication.yml +208 -0
- data/spec/fixtures/leetchi_cassettes/transfer.yml +5679 -0
- data/spec/fixtures/leetchi_cassettes/user.yml +31848 -0
- data/spec/fixtures/leetchi_cassettes/wallet.yml +27719 -0
- data/spec/fixtures/leetchi_cassettes/withdrawal.yml +12001 -0
- data/spec/lib/leetchi/beneficiary_spec.rb +129 -0
- data/spec/lib/leetchi/card_spec.rb +50 -0
- data/spec/lib/leetchi/contribution_spec.rb +64 -0
- data/spec/lib/leetchi/expense_spec.rb +17 -0
- data/spec/lib/leetchi/operation_spec.rb +14 -0
- data/spec/lib/leetchi/recurrent_contribution_spec.rb +48 -0
- data/spec/lib/leetchi/ressource_spec.rb +7 -0
- data/spec/lib/leetchi/strong_authentication_spec.rb +17 -0
- data/spec/lib/leetchi/transfer_spec.rb +71 -0
- data/spec/lib/leetchi/user_spec.rb +130 -0
- data/spec/lib/leetchi/wallet_spec.rb +87 -0
- data/spec/lib/leetchi/withdrawal_spec.rb +89 -0
- data/spec/spec_helper.rb +19 -0
- metadata +119 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Leetchi::Wallet do
|
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
|
+
let(:new_wallet) {
|
15
|
+
Leetchi::Wallet.create({
|
16
|
+
'Name' => 'test',
|
17
|
+
'Owners' => [ new_user['ID'] ],
|
18
|
+
'RaisingGoalAmount' => 12000
|
19
|
+
})
|
20
|
+
}
|
21
|
+
before do
|
22
|
+
VCR.insert_cassette 'wallet', :record => :new_episodes
|
23
|
+
end
|
24
|
+
after do
|
25
|
+
VCR.eject_cassette
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "CREATE" do
|
29
|
+
it "should create a new wallet" do
|
30
|
+
new_wallet["ID"].wont_be_nil
|
31
|
+
new_wallet["Name"].must_equal 'test'
|
32
|
+
new_wallet["RaisingGoalAmount"].must_equal 12000
|
33
|
+
new_wallet["CollectedAmount"].must_equal 0
|
34
|
+
new_wallet["SpentAmount"].must_equal 0
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "GET" do
|
39
|
+
it "get the wallet" do
|
40
|
+
wallet = Leetchi::Wallet.details(new_wallet["ID"])
|
41
|
+
wallet['ID'].must_equal new_wallet['ID']
|
42
|
+
wallet['Name'].must_equal new_wallet['Name']
|
43
|
+
wallet['Owners'].must_equal new_wallet['Owners']
|
44
|
+
wallet['RaisingGoalAmount'].must_equal new_wallet['RaisingGoalAmount']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "UPDATE" do
|
49
|
+
it "update the wallet" do
|
50
|
+
wallet = Leetchi::Wallet.update(new_wallet["ID"], {
|
51
|
+
'Name' => 'test_update',
|
52
|
+
'RaisingGoalAmount' => 5000
|
53
|
+
})
|
54
|
+
wallet['ID'].must_equal wallet['ID']
|
55
|
+
wallet['Name'].must_equal 'test_update'
|
56
|
+
wallet['RaisingGoalAmount'].must_equal 5000
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "GET_OWNERS" do
|
61
|
+
it "get the wallet's owners" do
|
62
|
+
wallet = Leetchi::Wallet.get_owners(new_wallet["ID"])
|
63
|
+
wallet[0]['ID'].must_equal new_user['ID']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "GET_CONTRIBUTORS" do
|
68
|
+
it "get the wallet's contributors" do
|
69
|
+
wallet = Leetchi::Wallet.get_contributors(new_wallet["ID"])
|
70
|
+
wallet[0]['ID'].must_equal new_user['ID']
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "GET_REFUNDED" do
|
75
|
+
it "get the wallet's refunded" do
|
76
|
+
wallet = Leetchi::Wallet.get_refunded(new_wallet["ID"])
|
77
|
+
wallet[0]['ID'].must_equal new_user['ID']
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "OPERATIONS" do
|
82
|
+
it "gets the wallet operations" do
|
83
|
+
operations = Leetchi::Wallet.operations(new_wallet['ID'])
|
84
|
+
operations.must_be_kind_of Array
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe Leetchi::Withdrawal do
|
4
|
+
|
5
|
+
before do
|
6
|
+
VCR.insert_cassette 'withdrawal', :record => :new_episodes
|
7
|
+
end
|
8
|
+
after do
|
9
|
+
VCR.eject_cassette
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:new_user) {
|
13
|
+
Leetchi::User.create({
|
14
|
+
'Tag' => 'test',
|
15
|
+
'Email' => 'my@email.com',
|
16
|
+
'FirstName' => 'John',
|
17
|
+
'LastName' => 'Doe',
|
18
|
+
'CanRegisterMeanOfPayment' => true
|
19
|
+
})
|
20
|
+
}
|
21
|
+
|
22
|
+
let(:new_beneficiary) {
|
23
|
+
Leetchi::Beneficiary.create({
|
24
|
+
'Tag' => 'test',
|
25
|
+
'UserID' => new_user['ID'],
|
26
|
+
'BankAccountOwnerName' => new_user['FirstName'],
|
27
|
+
'BankAccountOwnerAddress' => '1 bis cite paradis',
|
28
|
+
'BankAccountIBAN' => 'FR76 1790 6000 3200 0833 5232 973',
|
29
|
+
'BankAccountBIC' => 'AGRIFRPP879'
|
30
|
+
})
|
31
|
+
}
|
32
|
+
|
33
|
+
let(:new_withdrawal) {
|
34
|
+
Leetchi::Withdrawal.create({
|
35
|
+
'Tag' => 'test_withdrawal',
|
36
|
+
'UserID' => new_user['ID'],
|
37
|
+
'WalletID' => 0,
|
38
|
+
'Amount' => 2500,
|
39
|
+
'BeneficiaryID' => new_beneficiary['ID']
|
40
|
+
})
|
41
|
+
}
|
42
|
+
|
43
|
+
describe "CREATE" do
|
44
|
+
it "create a withdrawal" do
|
45
|
+
new_withdrawal['ID'].wont_be_nil
|
46
|
+
new_withdrawal['UserID'].must_equal new_user['ID']
|
47
|
+
new_withdrawal['BeneficiaryID'].must_equal new_beneficiary['ID']
|
48
|
+
end
|
49
|
+
it "fails and return a 2001 error code: Invalid withdrawal amount" do
|
50
|
+
fail_withdrawal = Leetchi::Withdrawal.create({
|
51
|
+
'Tag' => 'test_withdrawal',
|
52
|
+
'UserID' => new_user['ID'],
|
53
|
+
'WalletID' => 0,
|
54
|
+
'Amount' => 250000000000000000,
|
55
|
+
'BeneficiaryID' => new_beneficiary['ID']
|
56
|
+
})
|
57
|
+
fail_withdrawal['ErrorCode'].must_equal 2001
|
58
|
+
end
|
59
|
+
it "fails and return a 2002 error code: Both parameters are specified: Amount and AmountWithoutFees" do
|
60
|
+
fail_withdrawal = Leetchi::Withdrawal.create({
|
61
|
+
'Tag' => 'test_withdrawal',
|
62
|
+
'UserID' => new_user['ID'],
|
63
|
+
'WalletID' => 0,
|
64
|
+
'Amount' => 2500,
|
65
|
+
'AmountWithoutFees' => 2500,
|
66
|
+
'BeneficiaryID' => new_beneficiary['ID']
|
67
|
+
})
|
68
|
+
fail_withdrawal['ErrorCode'].must_equal 2002
|
69
|
+
end
|
70
|
+
it "fails and return a 2003 error code: Invalid withdrawal ClientFeeAmount" do
|
71
|
+
fail_withdrawal = Leetchi::Withdrawal.create({
|
72
|
+
'Tag' => 'test_withdrawal',
|
73
|
+
'UserID' => new_user['ID'],
|
74
|
+
'WalletID' => 0,
|
75
|
+
'Amount' => 2500,
|
76
|
+
'BeneficiaryID' => new_beneficiary['ID'],
|
77
|
+
'ClientFeeAmount' => 3000
|
78
|
+
})
|
79
|
+
fail_withdrawal['ErrorCode'].must_equal 2003
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "GET" do
|
84
|
+
it "get the withdrawal" do
|
85
|
+
withdrawal = Leetchi::Withdrawal.details(new_withdrawal['ID'])
|
86
|
+
withdrawal['ID'].must_equal new_withdrawal['ID']
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../lib/leetchi-wallet-services'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'webmock/minitest'
|
5
|
+
require 'vcr'
|
6
|
+
require 'turn'
|
7
|
+
|
8
|
+
Turn.config do |c|
|
9
|
+
# :outline - turn's original case/test outline mode [default]
|
10
|
+
c.format = :outline
|
11
|
+
# use humanized test names (works only with :outline format)
|
12
|
+
c.natural = true
|
13
|
+
end
|
14
|
+
|
15
|
+
#VCR config
|
16
|
+
VCR.configure do |c|
|
17
|
+
c.cassette_library_dir = 'spec/fixtures/leetchi_cassettes'
|
18
|
+
c.hook_into :webmock
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: leetchi-wallet-services
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Vincent Cogne
|
9
|
+
- Geoffroy Lorieux
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
requirement: &70290655119560 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.7.7
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *70290655119560
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name:
|
28
|
+
- minitest
|
29
|
+
- webmock
|
30
|
+
- vcr
|
31
|
+
- turn
|
32
|
+
- rake
|
33
|
+
requirement: &70290655116160 !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: *70290655116160
|
42
|
+
description: ! " The Leetchi API Gem makes interacting with Leetchi's Wallet Services
|
43
|
+
much easier.\n For any questions regarding the use of Leetchi's Wallet Services
|
44
|
+
feel free to contact us at http://www.leetchi.com/en/contact\n You can find more
|
45
|
+
documentation about Leetchi's Wallet Services at http://doc.api.leetchi.com/\n"
|
46
|
+
email: geoffroy@leetchi.com
|
47
|
+
executables: []
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- lib/leetchi/beneficiary.rb
|
52
|
+
- lib/leetchi/card.rb
|
53
|
+
- lib/leetchi/contribution.rb
|
54
|
+
- lib/leetchi/expense.rb
|
55
|
+
- lib/leetchi/operation.rb
|
56
|
+
- lib/leetchi/recurrent_contribution.rb
|
57
|
+
- lib/leetchi/ressource.rb
|
58
|
+
- lib/leetchi/strong_authentication.rb
|
59
|
+
- lib/leetchi/transfer.rb
|
60
|
+
- lib/leetchi/user.rb
|
61
|
+
- lib/leetchi/wallet.rb
|
62
|
+
- lib/leetchi/withdrawal.rb
|
63
|
+
- lib/leetchi-wallet-services.rb
|
64
|
+
- CONTRIBUTING.md
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- Rakefile
|
68
|
+
- README.md
|
69
|
+
- spec/fixtures/leetchi_cassettes/beneficiary.yml
|
70
|
+
- spec/fixtures/leetchi_cassettes/card.yml
|
71
|
+
- spec/fixtures/leetchi_cassettes/contribution.yml
|
72
|
+
- spec/fixtures/leetchi_cassettes/expense-site.yml
|
73
|
+
- spec/fixtures/leetchi_cassettes/expense.yml
|
74
|
+
- spec/fixtures/leetchi_cassettes/operation.yml
|
75
|
+
- spec/fixtures/leetchi_cassettes/recurrent_contribution.yml
|
76
|
+
- spec/fixtures/leetchi_cassettes/strong_authentication.yml
|
77
|
+
- spec/fixtures/leetchi_cassettes/transfer.yml
|
78
|
+
- spec/fixtures/leetchi_cassettes/user.yml
|
79
|
+
- spec/fixtures/leetchi_cassettes/wallet.yml
|
80
|
+
- spec/fixtures/leetchi_cassettes/withdrawal.yml
|
81
|
+
- spec/lib/leetchi/beneficiary_spec.rb
|
82
|
+
- spec/lib/leetchi/card_spec.rb
|
83
|
+
- spec/lib/leetchi/contribution_spec.rb
|
84
|
+
- spec/lib/leetchi/expense_spec.rb
|
85
|
+
- spec/lib/leetchi/operation_spec.rb
|
86
|
+
- spec/lib/leetchi/recurrent_contribution_spec.rb
|
87
|
+
- spec/lib/leetchi/ressource_spec.rb
|
88
|
+
- spec/lib/leetchi/strong_authentication_spec.rb
|
89
|
+
- spec/lib/leetchi/transfer_spec.rb
|
90
|
+
- spec/lib/leetchi/user_spec.rb
|
91
|
+
- spec/lib/leetchi/wallet_spec.rb
|
92
|
+
- spec/lib/leetchi/withdrawal_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
homepage: http://rubygems.org/gems/leetchi-wallet-services
|
95
|
+
licenses: []
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 1.9.2
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.10
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Gem for interacting with the Leetchi Wallet Services
|
118
|
+
test_files: []
|
119
|
+
has_rdoc:
|