lemonway_ruby 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +8 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +118 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/circle.yml +4 -0
- data/lemon_way.gemspec +34 -0
- data/lib/lemon_way/client.rb +72 -0
- data/lib/lemon_way/error.rb +31 -0
- data/lib/lemon_way/form.rb +24 -0
- data/lib/lemon_way/generators/id.rb +13 -0
- data/lib/lemon_way/helpers/forms.rb +17 -0
- data/lib/lemon_way/middleware.rb +22 -0
- data/lib/lemon_way/money_in.rb +19 -0
- data/lib/lemon_way/money_out.rb +23 -0
- data/lib/lemon_way/railtie.rb +13 -0
- data/lib/lemon_way/response_adapter.rb +26 -0
- data/lib/lemon_way/version.rb +5 -0
- data/lib/lemon_way/wallet.rb +40 -0
- data/lib/lemonway_ruby.rb +36 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70a792ecb396068252188fb589ad90d8025face2
|
4
|
+
data.tar.gz: 4d033dbe75086a7a7f6eca9c18703fd6276db7a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d5edd46c53e4ed3cbbb96cb5cbf28268056150151c040358395738fee045b5cd5603b23459fdd4cd30aec9c3a94803ebbd29caeefcfd73a6bbc9d7955439a9f
|
7
|
+
data.tar.gz: 702d63a41f4ead4191b091e7586fc833203450c89b2f4821011afa7231aea0c9bf15a9932e3ae3e2b71ac5e606a071b23e06edbcd7ff48d22d666132222e84a5
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at alexandre.ktifa@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Alexandre Ktifa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# LemonWay
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/MesPetitsArtistes/lemon_way)
|
4
|
+
|
5
|
+
[![CircleCI](https://circleci.com/gh/MesPetitsArtistes/lemon_way/tree/master.svg?style=svg)](https://circleci.com/gh/MesPetitsArtistes/lemon_way/tree/master)
|
6
|
+
|
7
|
+
This gem is a client for the LemonWay API.
|
8
|
+
|
9
|
+
IMPORTANT : This gem is still in development and cannot be used in production at the moment.
|
10
|
+
|
11
|
+
First, you need to sign up and own a Lemonway account.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'lemonway_ruby'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install lemonway_ruby
|
28
|
+
|
29
|
+
## Configuration:
|
30
|
+
|
31
|
+
There are **3 required** paremeters => login / password / company
|
32
|
+
|
33
|
+
There are 2 optionals parameters => sandbox / language
|
34
|
+
|
35
|
+
If you work with **Rails** :
|
36
|
+
```ruby
|
37
|
+
# config/initializers/lemonway_ruby.rb
|
38
|
+
lemon_way_configuration = {
|
39
|
+
login: ENV['LEMONWAY_LOGIN'],
|
40
|
+
password: ENV['LEMONWAY_PASSWORD'],
|
41
|
+
company: ENV['LEMONWAY_COMPANY']
|
42
|
+
}
|
43
|
+
lemon_way_configuration.merge!(sandbox: true) unless Rails.env.production?
|
44
|
+
|
45
|
+
LemonWay.configuration = lemon_way_configuration
|
46
|
+
```
|
47
|
+
|
48
|
+
## Middleware
|
49
|
+
|
50
|
+
Lemonway needs to know the IP and User-Agent of the request.
|
51
|
+
|
52
|
+
This gem provides a middleware: `LemonWay::Middleware` which add this informations for each requests.
|
53
|
+
|
54
|
+
If you work with **Rails**, this middleware is already added and you have nothing to do.
|
55
|
+
|
56
|
+
Otherwise, you will have to add this middleware by yourself.
|
57
|
+
|
58
|
+
|
59
|
+
## Usage
|
60
|
+
|
61
|
+
For information, every request with the gem will trigger a `LemonWay::LemonWayError` if the request is not satisfied.
|
62
|
+
|
63
|
+
You can rescue it like that :
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
def get_lemon_way_wallet
|
67
|
+
LemonWay::Wallet.get(id: 'UnknownId')
|
68
|
+
rescue LemonWay::LemonWayError => e
|
69
|
+
# Do what you want
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
### Wallet
|
74
|
+
|
75
|
+
This module allows you to manage all your wallets:
|
76
|
+
|
77
|
+
* Wallet creation
|
78
|
+
* Wallet details modification
|
79
|
+
* Send KYC documents to Lemon Way
|
80
|
+
* Check wallet and KYC document status that have changed since a given date
|
81
|
+
* Check wallet details and balance
|
82
|
+
* Check balances that have changed since a given date
|
83
|
+
* Get the list of all transactions made on a wallet
|
84
|
+
|
85
|
+
Details of the [Wallet module](https://github.com/MesPetitsArtistes/lemon_way/wiki/Wallet).
|
86
|
+
|
87
|
+
### MoneyIn
|
88
|
+
|
89
|
+
This module allows you credit a wallet with the following means of payment:
|
90
|
+
|
91
|
+
* By card
|
92
|
+
|
93
|
+
Details of the [MoneyIn module](https://github.com/MesPetitsArtistes/lemon_way/wiki/MoneyIn).
|
94
|
+
|
95
|
+
### Form
|
96
|
+
|
97
|
+
This module allows you to manage form payment:
|
98
|
+
|
99
|
+
* Create a payment form
|
100
|
+
* Retrieve a payment form
|
101
|
+
* Disable a payment form
|
102
|
+
|
103
|
+
Details of the [Form module](https://github.com/MesPetitsArtistes/lemon_way/wiki/Form).
|
104
|
+
|
105
|
+
### MoneyOut
|
106
|
+
|
107
|
+
This module allows you to prepare/debit a wallet to credit a bank account:
|
108
|
+
|
109
|
+
* Register an IBAN
|
110
|
+
* Transfer fund
|
111
|
+
* Get details on a transfer
|
112
|
+
|
113
|
+
Details of the [MoneyOut module](https://github.com/MesPetitsArtistes/lemon_way/wiki/MoneyOut).
|
114
|
+
|
115
|
+
## License
|
116
|
+
|
117
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
118
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'lemon_way'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require 'pry'
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
data/lemon_way.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'lemon_way/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'lemonway_ruby'
|
10
|
+
spec.version = LemonWay::VERSION
|
11
|
+
spec.authors = ['Alexandre Ktifa', 'Julien Lerpscher']
|
12
|
+
spec.email = ['contact@mespetitsartistes.fr']
|
13
|
+
spec.summary = 'Client for LemonWay Directkit API in JSON'
|
14
|
+
spec.description = 'Client for LemonWay Directkit API in JSON'
|
15
|
+
spec.homepage = 'https://github.com/MesPetitsArtistes/lemon_way'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'webmock', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rubocop', '0.48.1'
|
28
|
+
spec.add_development_dependency 'rails'
|
29
|
+
|
30
|
+
spec.add_runtime_dependency 'request_store', '~> 1.1'
|
31
|
+
|
32
|
+
spec.add_dependency 'httparty'
|
33
|
+
spec.add_dependency 'activesupport'
|
34
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/error'
|
4
|
+
require 'lemon_way/response_adapter'
|
5
|
+
require 'json'
|
6
|
+
require 'httparty'
|
7
|
+
|
8
|
+
module LemonWay
|
9
|
+
class Client
|
10
|
+
include HTTParty
|
11
|
+
|
12
|
+
attr_reader :login, :password, :company, :env, :options
|
13
|
+
|
14
|
+
DIRECTKIT_URL = \
|
15
|
+
'https://sandbox-api.lemonway.fr/mb/{company_name}/{env}/directkitjson2/Service.asmx'.freeze
|
16
|
+
|
17
|
+
REQUIRED_CONFIGURATION = %i[login password company].freeze
|
18
|
+
DEFAULT_LANGUAGE = 'fr'.freeze
|
19
|
+
DEFAULT_HEADERS = {
|
20
|
+
'Content-Type' => 'application/json; charset=utf-8',
|
21
|
+
'Accept' => 'application/json',
|
22
|
+
'Cache-Control' => 'no-cache',
|
23
|
+
'Pragma' => 'no-cache'
|
24
|
+
}.freeze
|
25
|
+
|
26
|
+
base_uri DIRECTKIT_URL
|
27
|
+
debug_output $stdout
|
28
|
+
|
29
|
+
def initialize(options = {})
|
30
|
+
if (options.keys & REQUIRED_CONFIGURATION).size != REQUIRED_CONFIGURATION.size
|
31
|
+
raise MissingConfigurationError.new
|
32
|
+
end
|
33
|
+
|
34
|
+
@login = options[:login]
|
35
|
+
@password = options[:password]
|
36
|
+
@company = options[:company]
|
37
|
+
@env = options[:sandbox] ? 'dev' : 'prod'
|
38
|
+
@options = options.delete_if { |k, _v| REQUIRED_CONFIGURATION.include?(k) }
|
39
|
+
end
|
40
|
+
|
41
|
+
def send_request(lw_method, version, params = {})
|
42
|
+
response = perform_request(lw_method, version, params)
|
43
|
+
|
44
|
+
ResponseAdapter.new(response)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def perform_request(lw_method, version, params)
|
50
|
+
self.class.post([directkit_url, lw_method].join('/'),
|
51
|
+
headers: DEFAULT_HEADERS,
|
52
|
+
body: { p: request_body(version, params) }.to_json)
|
53
|
+
end
|
54
|
+
|
55
|
+
def directkit_url
|
56
|
+
DIRECTKIT_URL
|
57
|
+
.sub('{company_name}', @company)
|
58
|
+
.sub('{env}', @env)
|
59
|
+
end
|
60
|
+
|
61
|
+
def request_body(version, params)
|
62
|
+
{
|
63
|
+
wlLogin: @login,
|
64
|
+
wlPass: @password,
|
65
|
+
language: @options[:language] || DEFAULT_LANGUAGE,
|
66
|
+
version: version,
|
67
|
+
walletIp: @options[:sandbox] ? '127.0.0.1' : RequestStore[:lemon_way][:ip],
|
68
|
+
walletUa: @options[:sandbox] ? 'User-agent' : RequestStore[:lemon_way][:user_agent]
|
69
|
+
}.merge(params)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LemonWay
|
4
|
+
class MissingConfigurationError < StandardError
|
5
|
+
def initialize
|
6
|
+
super(%(Your LemonWay configuration is missing.
|
7
|
+
Try:
|
8
|
+
|
9
|
+
LemonWay.configuration = {
|
10
|
+
login: 'YOUR_LOGIN',
|
11
|
+
password: 'YOUR_PASSWORD',
|
12
|
+
company: 'YOUR_COMPANY'
|
13
|
+
}
|
14
|
+
|
15
|
+
These are the optional options: { sandbox:, language: }
|
16
|
+
))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class LemonWayError < StandardError
|
21
|
+
DIRECKIT_DOCUMENTATION_URL = 'http://documentation.lemonway.fr/api-en/directkit'.freeze
|
22
|
+
|
23
|
+
def initialize(error = {})
|
24
|
+
super(%(
|
25
|
+
Code: #{error.try(:[], :code)}
|
26
|
+
Message: #{error.try(:[], :msg)}
|
27
|
+
Documentation: #{DIRECKIT_DOCUMENTATION_URL}
|
28
|
+
))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/error'
|
4
|
+
|
5
|
+
module LemonWay
|
6
|
+
class Form
|
7
|
+
class << self
|
8
|
+
def create(params = {})
|
9
|
+
params[:optId] = params.delete(:id) || LemonWay::Generators::Id.generate(length: 60)
|
10
|
+
LemonWay.client.send_request('CreatePaymentForm', '1.0', params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get(params = {})
|
14
|
+
params[:formId] = params.delete(:id)
|
15
|
+
LemonWay.client.send_request('GetCompletedPaymentForm', '1.0', params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def disable(params = {})
|
19
|
+
params[:formId] = params.delete(:id)
|
20
|
+
LemonWay.client.send_request('DisablePaymentForm', '1.0', params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LemonWay
|
4
|
+
module Helpers
|
5
|
+
module Forms
|
6
|
+
DIRECTKIT_FORM_URL = \
|
7
|
+
'https://webkit.lemonway.fr/mb/{company_name}/{env}/payment-page/?fId={id}'.freeze
|
8
|
+
|
9
|
+
def lemon_way_form_url(form_id)
|
10
|
+
DIRECTKIT_FORM_URL
|
11
|
+
.sub('{company_name}', LemonWay.client.company)
|
12
|
+
.sub('{env}', LemonWay.client.env)
|
13
|
+
.sub('{id}', form_id)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'request_store'
|
4
|
+
|
5
|
+
module LemonWay
|
6
|
+
class Middleware
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
request = Rack::Request.new(env)
|
13
|
+
|
14
|
+
::RequestStore.store[:lemon_way] = {
|
15
|
+
ip: request.ip,
|
16
|
+
user_agent: request.user_agent
|
17
|
+
}
|
18
|
+
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/error'
|
4
|
+
|
5
|
+
module LemonWay
|
6
|
+
class MoneyIn
|
7
|
+
class << self
|
8
|
+
def init(params = {})
|
9
|
+
params[:wallet] = params.delete(:id)
|
10
|
+
LemonWay.client.send_request('MoneyInWebInit', '1.3', params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate(params = {})
|
14
|
+
params[:transactionId] = params.delete(:id)
|
15
|
+
LemonWay.client.send_request('MoneyInValidate', '1.0', params)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/error'
|
4
|
+
|
5
|
+
module LemonWay
|
6
|
+
class MoneyOut
|
7
|
+
class << self
|
8
|
+
def register_iban(params = {})
|
9
|
+
params[:wallet] = params.delete(:id)
|
10
|
+
LemonWay.client.send_request('RegisterIBAN', '1.1', params)
|
11
|
+
end
|
12
|
+
|
13
|
+
def transfer(params = {})
|
14
|
+
params[:wallet] = params.delete(:id)
|
15
|
+
LemonWay.client.send_request('MoneyOut', '1.3', params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def transfer_details(params = {})
|
19
|
+
LemonWay.client.send_request('GetMoneyOutTransDetails', '1.4', params)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/middleware'
|
4
|
+
require 'lemon_way/helpers/forms'
|
5
|
+
|
6
|
+
module LemonWay
|
7
|
+
class Railtie < ::Rails::Railtie
|
8
|
+
initializer 'lemon_way.configure_rails_initialization' do |app|
|
9
|
+
app.middleware.use LemonWay::Middleware
|
10
|
+
ActionView::Base.send(:include, LemonWay::Helpers::Forms)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ostruct'
|
4
|
+
require 'active_support/all'
|
5
|
+
|
6
|
+
module LemonWay
|
7
|
+
class ResponseAdapter < OpenStruct
|
8
|
+
def initialize(response)
|
9
|
+
response = JSON.parse(response.body)['d'].deep_transform_keys { |key| key.underscore.to_sym }
|
10
|
+
|
11
|
+
raise LemonWay::LemonWayError.new(response[:e]) if response[:e].present?
|
12
|
+
|
13
|
+
super(values_for(response))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def values_for(response)
|
19
|
+
response.detect { |k, _v| k.in?(response_keys) }.last
|
20
|
+
end
|
21
|
+
|
22
|
+
def response_keys
|
23
|
+
%i[wallet moneyinweb trans form iban_register]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/error'
|
4
|
+
require 'lemon_way/generators/id'
|
5
|
+
|
6
|
+
module LemonWay
|
7
|
+
class Wallet
|
8
|
+
class << self
|
9
|
+
def get(params = {})
|
10
|
+
params[:wallet] = params.delete(:id)
|
11
|
+
LemonWay.client.send_request('GetWalletDetails', '2.0', params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def register(params = {})
|
15
|
+
params[:wallet] = params.delete(:id) || LemonWay::Generators::Id.generate
|
16
|
+
LemonWay.client.send_request('RegisterWallet', '1.1', params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(params = {})
|
20
|
+
params[:wallet] = params.delete(:id)
|
21
|
+
LemonWay.client.send_request('UpdateWalletDetails', '1.0', params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_status(params = {})
|
25
|
+
params[:wallet] = params.delete(:id)
|
26
|
+
LemonWay.client.send_request('UpdateWalletStatus', '1.0', params)
|
27
|
+
end
|
28
|
+
|
29
|
+
def upload_file(params = {})
|
30
|
+
params[:wallet] = params.delete(:id)
|
31
|
+
LemonWay.client.send_request('UploadFile', '1.1', params)
|
32
|
+
end
|
33
|
+
|
34
|
+
def transactions_history(params = {})
|
35
|
+
params[:wallet] = params.delete(:id)
|
36
|
+
LemonWay.client.send_request('GetWalletTransHistory', '2.1', params)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lemon_way/version'
|
4
|
+
require 'lemon_way/client'
|
5
|
+
require 'lemon_way/wallet'
|
6
|
+
require 'lemon_way/money_in'
|
7
|
+
require 'lemon_way/money_out'
|
8
|
+
require 'lemon_way/form'
|
9
|
+
require 'lemon_way/middleware'
|
10
|
+
require 'lemon_way/helpers/forms'
|
11
|
+
require 'lemon_way/generators/id'
|
12
|
+
require 'lemon_way/railtie' if defined?(Rails)
|
13
|
+
|
14
|
+
module LemonWay
|
15
|
+
@@client = nil
|
16
|
+
@@configuration = {}
|
17
|
+
|
18
|
+
def self.init
|
19
|
+
@@client = Client.new(@@configuration)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.reset
|
23
|
+
@@client = nil
|
24
|
+
@@configuration = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.configuration=(configuration)
|
28
|
+
@@configuration = configuration
|
29
|
+
|
30
|
+
LemonWay.init
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.client
|
34
|
+
@@client || LemonWay.init
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lemonway_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexandre Ktifa
|
8
|
+
- Julien Lerpscher
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-07-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.12'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.12'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '3.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: webmock
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.48.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.48.1
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rails
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: request_store
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.1'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1.1'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: httparty
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: activesupport
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
description: Client for LemonWay Directkit API in JSON
|
141
|
+
email:
|
142
|
+
- contact@mespetitsartistes.fr
|
143
|
+
executables: []
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".codeclimate.yml"
|
148
|
+
- ".gitignore"
|
149
|
+
- ".rspec"
|
150
|
+
- ".rubocop.yml"
|
151
|
+
- ".travis.yml"
|
152
|
+
- CODE_OF_CONDUCT.md
|
153
|
+
- Gemfile
|
154
|
+
- LICENSE.txt
|
155
|
+
- README.md
|
156
|
+
- Rakefile
|
157
|
+
- bin/console
|
158
|
+
- bin/setup
|
159
|
+
- circle.yml
|
160
|
+
- lemon_way.gemspec
|
161
|
+
- lib/lemon_way/client.rb
|
162
|
+
- lib/lemon_way/error.rb
|
163
|
+
- lib/lemon_way/form.rb
|
164
|
+
- lib/lemon_way/generators/id.rb
|
165
|
+
- lib/lemon_way/helpers/forms.rb
|
166
|
+
- lib/lemon_way/middleware.rb
|
167
|
+
- lib/lemon_way/money_in.rb
|
168
|
+
- lib/lemon_way/money_out.rb
|
169
|
+
- lib/lemon_way/railtie.rb
|
170
|
+
- lib/lemon_way/response_adapter.rb
|
171
|
+
- lib/lemon_way/version.rb
|
172
|
+
- lib/lemon_way/wallet.rb
|
173
|
+
- lib/lemonway_ruby.rb
|
174
|
+
homepage: https://github.com/MesPetitsArtistes/lemon_way
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
metadata: {}
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.5.1
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: Client for LemonWay Directkit API in JSON
|
198
|
+
test_files: []
|