leetchi-wallet-services 0.0.1 → 1.0.0
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.
- data/Gemfile +9 -7
- data/Gemfile.lock +46 -11
- data/README.md +33 -2
- data/lib/leetchi/ressource.rb +4 -4
- data/lib/leetchi-wallet-services.rb +23 -0
- data/spec/fixtures/leetchi_cassettes/beneficiary.yml +13574 -0
- data/spec/fixtures/leetchi_cassettes/card.yml +5461 -0
- data/spec/fixtures/leetchi_cassettes/contribution.yml +27562 -0
- data/spec/fixtures/leetchi_cassettes/expense.yml +369 -0
- data/spec/fixtures/leetchi_cassettes/operation.yml +369 -0
- data/spec/fixtures/leetchi_cassettes/recurrent_contribution.yml +1496 -0
- data/spec/fixtures/leetchi_cassettes/strong_authentication.yml +369 -0
- data/spec/fixtures/leetchi_cassettes/transfer.yml +25708 -0
- data/spec/fixtures/leetchi_cassettes/user.yml +12580 -0
- data/spec/fixtures/leetchi_cassettes/wallet.yml +7380 -0
- data/spec/fixtures/leetchi_cassettes/withdrawal.yml +8721 -0
- data/spec/lib/leetchi/beneficiary_spec.rb +3 -2
- data/spec/lib/leetchi/card_spec.rb +12 -4
- data/spec/lib/leetchi/contribution_spec.rb +10 -3
- data/spec/lib/leetchi/recurrent_contribution_spec.rb +41 -41
- data/spec/lib/leetchi/transfer_spec.rb +26 -4
- data/spec/lib/leetchi/user_spec.rb +3 -2
- data/spec/lib/leetchi/withdrawal_spec.rb +18 -3
- data/spec/spec_helper.rb +17 -0
- data/spec/support-files/example.pem +49 -0
- metadata +160 -41
data/Gemfile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem
|
3
|
+
gem 'json', '~> 1.7.7'
|
4
4
|
|
5
5
|
group :test do
|
6
|
-
gem 'minitest'
|
7
|
-
gem 'webmock'
|
8
|
-
gem '
|
9
|
-
gem '
|
10
|
-
gem '
|
6
|
+
gem 'minitest', '~> 4.6.1'
|
7
|
+
gem 'webmock', '~> 1.9.3'
|
8
|
+
gem 'capybara', '~> 2.0.2'
|
9
|
+
gem 'poltergeist', '~> 1.1.0'
|
10
|
+
gem 'vcr', '~> 2.4.0'
|
11
|
+
gem 'turn', '~> 0.9.6'
|
12
|
+
gem 'rake', '~> 10.0.3'
|
11
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,61 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.3.
|
4
|
+
addressable (2.3.3)
|
5
5
|
ansi (1.4.3)
|
6
|
+
capybara (2.0.2)
|
7
|
+
mime-types (>= 1.16)
|
8
|
+
nokogiri (>= 1.3.3)
|
9
|
+
rack (>= 1.0.0)
|
10
|
+
rack-test (>= 0.5.4)
|
11
|
+
selenium-webdriver (~> 2.0)
|
12
|
+
xpath (~> 1.0.0)
|
13
|
+
childprocess (0.3.8)
|
14
|
+
ffi (~> 1.0, >= 1.0.11)
|
6
15
|
crack (0.3.2)
|
7
|
-
|
16
|
+
eventmachine (1.0.0)
|
17
|
+
faye-websocket (0.4.7)
|
18
|
+
eventmachine (>= 0.12.0)
|
19
|
+
ffi (1.4.0)
|
20
|
+
http_parser.rb (0.5.3)
|
21
|
+
json (1.7.7)
|
22
|
+
mime-types (1.21)
|
8
23
|
minitest (4.6.1)
|
24
|
+
multi_json (1.6.1)
|
25
|
+
nokogiri (1.5.6)
|
26
|
+
poltergeist (1.1.0)
|
27
|
+
capybara (~> 2.0, >= 2.0.1)
|
28
|
+
faye-websocket (~> 0.4, >= 0.4.4)
|
29
|
+
http_parser.rb (~> 0.5.3)
|
30
|
+
rack (1.5.2)
|
31
|
+
rack-test (0.6.2)
|
32
|
+
rack (>= 1.0)
|
9
33
|
rake (10.0.3)
|
34
|
+
rubyzip (0.9.9)
|
35
|
+
selenium-webdriver (2.30.0)
|
36
|
+
childprocess (>= 0.2.5)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
rubyzip
|
39
|
+
websocket (~> 1.0.4)
|
10
40
|
turn (0.9.6)
|
11
41
|
ansi
|
12
42
|
vcr (2.4.0)
|
13
|
-
webmock (1.9.
|
43
|
+
webmock (1.9.3)
|
14
44
|
addressable (>= 2.2.7)
|
15
|
-
crack (>= 0.
|
45
|
+
crack (>= 0.3.2)
|
46
|
+
websocket (1.0.7)
|
47
|
+
xpath (1.0.0)
|
48
|
+
nokogiri (~> 1.3)
|
16
49
|
|
17
50
|
PLATFORMS
|
18
51
|
ruby
|
19
52
|
|
20
53
|
DEPENDENCIES
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
54
|
+
capybara (~> 2.0.2)
|
55
|
+
json (~> 1.7.7)
|
56
|
+
minitest (~> 4.6.1)
|
57
|
+
poltergeist (~> 1.1.0)
|
58
|
+
rake (~> 10.0.3)
|
59
|
+
turn (~> 0.9.6)
|
60
|
+
vcr (~> 2.4.0)
|
61
|
+
webmock (~> 1.9.3)
|
data/README.md
CHANGED
@@ -5,21 +5,51 @@ See the [API documentation](http://doc.api.leetchi.com/) for more details on the
|
|
5
5
|
|
6
6
|
Tested on the following versions of Ruby: 1.9.2, 1.9.3
|
7
7
|
|
8
|
+
## Code Status
|
9
|
+
[](https://travis-ci.org/Leetchi/leetchi-api-ruby-sdk)
|
10
|
+
[](https://codeclimate.com/github/Leetchi/leetchi-api-ruby-sdk)
|
11
|
+
[](https://gemnasium.com/Leetchi/leetchi-api-ruby-sdk)
|
12
|
+
|
8
13
|
## Requirements
|
9
14
|
|
10
15
|
This gem uses mainly ruby stdlib and the *json* gem.
|
11
16
|
|
12
17
|
## Configuration
|
13
18
|
|
19
|
+
Please note that the gem configuration process change between 0.0.1 and 1.0.0.
|
20
|
+
|
21
|
+
### Version 0.0.1
|
22
|
+
|
14
23
|
Setup the following ENV:
|
15
24
|
|
16
|
-
```
|
25
|
+
```
|
17
26
|
ENV['LEETCHI_API_BASE_URL'] = "https://api-preprod.leetchi.com" # once you've run your test using the preproduction environment use the production one
|
18
27
|
ENV['LEETCHI_KEY_PATH'] = "abcd" # the full path to your leetchi key
|
19
28
|
ENV['LEETCHI_PASSPHRASE'] = "efgh" # you key's passphrase (leave blank if none)
|
20
29
|
ENV['LEETCHI_PARTNER_ID'] = "myID" # your Leetchi API ID
|
21
30
|
```
|
22
31
|
|
32
|
+
### Version 1.0.0
|
33
|
+
|
34
|
+
You can now call the Leetchi.configure method like this:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
Leetchi.configure do |c|
|
38
|
+
c.preproduction = true
|
39
|
+
c.partner_id = 'example'
|
40
|
+
c.key_path = './spec/support-files/example.pem'
|
41
|
+
c.key_password = ''
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
The **preproduction** attribute let you specify if you want to use the preproduction api endpoint.
|
46
|
+
|
47
|
+
The **partner_id** is the id that was issue to you during you registration process.
|
48
|
+
|
49
|
+
The **key_path** and **key_password** arguments are here to let you use the key you've created before the registration process.
|
50
|
+
|
51
|
+
This configure method can of course be use to define a Ruby on Rails initialiser.
|
52
|
+
|
23
53
|
## Usage
|
24
54
|
|
25
55
|
The gem implements the following resources:
|
@@ -35,7 +65,7 @@ The gem implements the following resources:
|
|
35
65
|
- Wallet
|
36
66
|
- Withdrawal
|
37
67
|
|
38
|
-
Each resource has specifics methods such has `create`, `details`, `update`, etc. Those methods must be called with an ID and / or an Object matching the Leetchi API.
|
68
|
+
Each resource has specifics methods such has `create`, `details`, `update`, etc. Those methods must be called with an ID and / or an Object matching the Leetchi API.
|
39
69
|
Calling those methods return the Leetchi API response has an object. Every executions are made synchronously.
|
40
70
|
|
41
71
|
### Example
|
@@ -62,3 +92,4 @@ Leetchi::User.details(123)
|
|
62
92
|
Make sure that you have run: ```bundle install```
|
63
93
|
Then you just have to run the rake task ```rake test``` to run all the test suite.
|
64
94
|
Feel free to report any test failure by creating an issue on the [Gem's Github](https://github.com/Leetchi/leetchi-api-ruby-sdk/issues)
|
95
|
+
|
data/lib/leetchi/ressource.rb
CHANGED
@@ -42,20 +42,20 @@ module Leetchi
|
|
42
42
|
begin
|
43
43
|
JSON.parse(res.body)
|
44
44
|
rescue JSON::ParserError => e
|
45
|
-
{' ErrorCode' => -1 }
|
45
|
+
res.body.is_a?(String) ? res.body : {' ErrorCode' => -1 }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.key
|
50
|
-
OpenSSL::PKey::RSA.new(File.read(
|
50
|
+
OpenSSL::PKey::RSA.new(File.read(Leetchi.configuration.key_path), Leetchi.configuration.key_password)
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.path_for(route, options)
|
54
|
-
File.join('', 'v1', 'partner',
|
54
|
+
File.join('', 'v1', 'partner', Leetchi.configuration.partner_id, route.to_s) + "?ts=#{Time.now.to_i.to_s}" + (options.nil? ? '' : ('&' + options))
|
55
55
|
end
|
56
56
|
|
57
57
|
def self.uri_for(path)
|
58
|
-
URI(File.join(
|
58
|
+
URI(File.join(Leetchi.configuration.base_url, path))
|
59
59
|
end
|
60
60
|
|
61
61
|
def self.sign(data)
|
@@ -18,4 +18,27 @@ module Leetchi
|
|
18
18
|
require 'leetchi/expense'
|
19
19
|
require 'leetchi/recurrent_contribution'
|
20
20
|
|
21
|
+
|
22
|
+
class Configuration
|
23
|
+
attr_accessor :base_url, :partner_id, :key_path, :key_password, :preproduction
|
24
|
+
|
25
|
+
def preproduction
|
26
|
+
@preproduction || false
|
27
|
+
end
|
28
|
+
|
29
|
+
def base_url
|
30
|
+
@base_url || (@preproduction == true ? "https://api-preprod.leetchi.com" : "https://api.leetchi.com")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class << self
|
36
|
+
attr_accessor :configuration
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.configure
|
40
|
+
self.configuration ||= Configuration.new
|
41
|
+
yield configuration
|
42
|
+
end
|
43
|
+
|
21
44
|
end
|