lemon_way 0.0.2
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +1 -0
- data/lemon_way.gemspec +30 -0
- data/lib/lemon_way/client.rb +128 -0
- data/lib/lemon_way/hash.rb +50 -0
- data/lib/lemon_way/version.rb +3 -0
- data/lib/lemon_way.rb +7 -0
- data/spec/client_spec.rb +172 -0
- data/spec/fixtures/responses/register_wallet_failure.xml +6 -0
- data/spec/fixtures/responses/register_wallet_success.xml +4 -0
- data/spec/hash_spec.rb +52 -0
- data/spec/spec_helper.rb +21 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26f57e6ab1723fd047289f7181f3d3a369c187ce
|
4
|
+
data.tar.gz: 54b1ab51bfb201f5c569d9c0bed54d7e364135ff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8f0d7932ad7d65f395c232fb3c1e3f5eb877f78236e5e713d000b855b7ecabb8cb65909102e66bdbaf9ad49cc225e1e4ddb889b6d147eae921e7e32c7d117434
|
7
|
+
data.tar.gz: e709ac50c9a32ca3bb861a22e39047235136c5882e4a90663aa342224fadf8673e62fed592a815870c46607cf548b9927e2a115a03a51dd11f9501a27d50b276
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.idea
|
4
|
+
.rvmrc
|
5
|
+
.bundle
|
6
|
+
.config
|
7
|
+
.yardoc
|
8
|
+
Gemfile.lock
|
9
|
+
InstalledFiles
|
10
|
+
_yardoc
|
11
|
+
coverage
|
12
|
+
doc/
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
.rvmrc
|
21
|
+
.pryrc
|
22
|
+
config.yml
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation --color --fail-fast
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Itkin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
__Caution : Still under developpement and subject to changes__
|
2
|
+
# LemonWay
|
3
|
+
|
4
|
+
Ruby API client to query LemonWay
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'lemon_way'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install lemon_way
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
1. Initialize a client instance (URI is mandatory, all the params passed are later overridable in method calls)
|
23
|
+
2. Query the API : the params as the query name may be underscored, they will be handled appropriately
|
24
|
+
3. API response will always be a HashWithIndifferentAccess with underscored keys. Retrieve it as a result or pass a block to the API point method
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
client = LemonWay::Client.new wl_login: "test",
|
28
|
+
wl_pass: "test",
|
29
|
+
wl_PDV: "test",
|
30
|
+
language: "fr",
|
31
|
+
version: "1.1",
|
32
|
+
uri: "https://ws.lemonway.fr/mb/your_merchant_name/dev/directkit/service.asmx"
|
33
|
+
|
34
|
+
response = client.register_wallet my_hash
|
35
|
+
|
36
|
+
client.register_wallet my_hash do |response|
|
37
|
+
response.class
|
38
|
+
end
|
39
|
+
=> HashWithIndifferentAccess
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
## Todo
|
46
|
+
|
47
|
+
1. Complete the doc
|
48
|
+
2. Test with VCR
|
49
|
+
3. Build WebMerchant client
|
50
|
+
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lemon_way.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lemon_way/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lemon_way"
|
8
|
+
spec.version = LemonWay::VERSION
|
9
|
+
spec.authors = ["Itkin"]
|
10
|
+
spec.email = ["nicolas.papon@webflows.fr"]
|
11
|
+
spec.description = "Describe me"
|
12
|
+
spec.summary = "Describe me"
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_development_dependency "pry-rails"
|
25
|
+
spec.add_development_dependency "yard"
|
26
|
+
|
27
|
+
spec.add_dependency "activesupport"
|
28
|
+
spec.add_dependency "builder"
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require "active_support/core_ext/hash"
|
2
|
+
require 'active_support/builder'
|
3
|
+
require "net/http"
|
4
|
+
require "uri"
|
5
|
+
require "rexml/document"
|
6
|
+
|
7
|
+
module LemonWay
|
8
|
+
class Client
|
9
|
+
|
10
|
+
@@api_method_calls = %w(
|
11
|
+
FastPay
|
12
|
+
GetBalances
|
13
|
+
GetKycStatus
|
14
|
+
GetMoneyInIBANDetails
|
15
|
+
GetMoneyInTransDetails
|
16
|
+
GetMoneyOutTransDetails
|
17
|
+
GetPaymentDetails
|
18
|
+
GetWalletDetails
|
19
|
+
MoneyIn
|
20
|
+
MoneyIn3DConfirm
|
21
|
+
MoneyIn3DInit
|
22
|
+
MoneyInWebInit
|
23
|
+
MoneyInWithCardId
|
24
|
+
MoneyOut
|
25
|
+
RefundMoneyIn
|
26
|
+
RegisterCard
|
27
|
+
RegisterIBAN
|
28
|
+
RegisterWallet
|
29
|
+
SendPayment
|
30
|
+
UnregisterCard
|
31
|
+
UpdateWalletDetails
|
32
|
+
UploadFile
|
33
|
+
)
|
34
|
+
|
35
|
+
attr_reader :uri, :xml_mini_backend, :entity_expansion_text_limit, :options
|
36
|
+
|
37
|
+
def initialize opts = {}
|
38
|
+
@options = opts.symbolize_keys!.except(:uri, :xml_mini_backend).camelize_keys
|
39
|
+
@uri = URI.parse opts[:uri]
|
40
|
+
@xml_mini_backend = opts[:xml_mini_backend] || ActiveSupport::XmlMini_REXML
|
41
|
+
@entity_expansion_text_limit = opts[:entity_expansion_text_limit] || 10**20
|
42
|
+
end
|
43
|
+
|
44
|
+
def method_missing *args, &block
|
45
|
+
camelized_method_name = args.first.to_s.camelize
|
46
|
+
if @@api_method_calls.include? camelized_method_name
|
47
|
+
attrs = attrs_from_options args.extract_options!
|
48
|
+
query camelized_method_name, attrs, &block
|
49
|
+
else
|
50
|
+
super
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def make_body(method_name, attrs={})
|
57
|
+
options = {}
|
58
|
+
options[:builder] = Builder::XmlMarkup.new(:indent => 2)
|
59
|
+
options[:builder].instruct!
|
60
|
+
options[:builder].tag! "soap12:Envelope",
|
61
|
+
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
62
|
+
"xmlns:xsd"=>"http://www.w3.org/2001/XMLSchema",
|
63
|
+
"xmlns:soap12"=>"http://www.w3.org/2003/05/soap-envelope" do
|
64
|
+
options[:builder].tag! "soap12:Body" do
|
65
|
+
options[:builder].__send__(:method_missing, method_name.to_s.camelize, xmlns: "Service_mb") do
|
66
|
+
@options.merge(attrs).each do |key, value|
|
67
|
+
ActiveSupport::XmlMini.to_tag(key, value, options)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def query(method, attrs={})
|
75
|
+
http = Net::HTTP.new(@uri.host, @uri.port)
|
76
|
+
http.use_ssl = true if @uri.port == 443
|
77
|
+
|
78
|
+
req = Net::HTTP::Post.new(@uri.request_uri)
|
79
|
+
req.body = make_body(method, attrs)
|
80
|
+
req.add_field 'Content-type', 'text/xml; charset=utf-8'
|
81
|
+
|
82
|
+
response = http.request(req).read_body
|
83
|
+
|
84
|
+
with_custom_parser_options do
|
85
|
+
response = Hash.from_xml(response)["Envelope"]['Body']["#{method}Response"]["#{method}Result"]
|
86
|
+
response = Hash.from_xml(response).with_indifferent_access.underscore_keys(true)
|
87
|
+
end
|
88
|
+
|
89
|
+
if response.has_key?("e")
|
90
|
+
raise Error, [response["e"]["code"], response["e"]["msg"]].join(' : ')
|
91
|
+
elsif block_given?
|
92
|
+
yield(response)
|
93
|
+
else
|
94
|
+
response
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# quickly retreat date and big decimal potential attributes
|
99
|
+
def attrs_from_options attrs
|
100
|
+
attrs.symbolize_keys!.camelize_keys!
|
101
|
+
[:amount, :amountTot, :amountCom].each do |key|
|
102
|
+
attrs[key] = sprintf("%.2f",attrs[key]) if attrs.key?(key) and attrs[key].is_a?(Number)
|
103
|
+
end
|
104
|
+
[:updateDate].each do |key|
|
105
|
+
attrs[key] = attrs[key].utc.to_i.to_s if attrs.key?(key) and attrs[key].is_a?(Time)
|
106
|
+
end
|
107
|
+
attrs
|
108
|
+
end
|
109
|
+
|
110
|
+
# work around for
|
111
|
+
# - Nokogiri::XML::SyntaxError: xmlns: URI Service_mb is not absolute
|
112
|
+
# - RuntimeError: entity expansion has grown too large
|
113
|
+
def with_custom_parser_options &block
|
114
|
+
backend = ActiveSupport::XmlMini.backend
|
115
|
+
ActiveSupport::XmlMini.backend= @xml_mini_backend
|
116
|
+
text_limit = REXML::Document.entity_expansion_text_limit
|
117
|
+
REXML::Document.entity_expansion_text_limit = @entity_expansion_text_limit
|
118
|
+
yield
|
119
|
+
ensure
|
120
|
+
ActiveSupport::XmlMini.backend = backend
|
121
|
+
REXML::Document.entity_expansion_text_limit = text_limit
|
122
|
+
end
|
123
|
+
|
124
|
+
class Error < Exception; end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "active_support/core_ext/hash"
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
# Return a new hash with all keys camelized.
|
5
|
+
#
|
6
|
+
# { :first_name => 'Rob', :years_old => '28' }.camelize_keys
|
7
|
+
# #=> { :firstName => "Rob", :yearsOld => "28" }
|
8
|
+
def camelize_keys(first_letter = :lower)
|
9
|
+
dup.camelize_keys!(first_letter)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Destructively camelize all keys. Same as
|
13
|
+
# +camelize_keys+, but modifies +self+.
|
14
|
+
def camelize_keys!(first_letter = :lower)
|
15
|
+
keys.each do |key|
|
16
|
+
new_key = key.to_s.camelize(first_letter)
|
17
|
+
self[key.is_a?(Symbol) ? new_key.to_sym : new_key] = delete(key)
|
18
|
+
end
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
# Return a new hash with all keys underscored.
|
23
|
+
#
|
24
|
+
# { :firstName => "Rob", :yearsOld => "28" }.underscore_keys
|
25
|
+
# #=> { :first_name => 'Rob', :years_old => '28' }
|
26
|
+
def underscore_keys(recursive=false)
|
27
|
+
dup.underscore_keys!(recursive)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Destructively underscore all keys. Same as
|
31
|
+
# +underscore_keys+, but modifies +self+.
|
32
|
+
def underscore_keys!(recursive=false)
|
33
|
+
keys.each do |key|
|
34
|
+
new_key = key.to_s.underscore
|
35
|
+
new_value = delete(key)
|
36
|
+
new_value.underscore_keys!(recursive) if recursive and new_value.is_a? Hash
|
37
|
+
new_value.map{|v| v.underscore_keys!(recursive) if v.is_a? Hash } if recursive and new_value.is_a? Array
|
38
|
+
self[key.is_a?(Symbol) ? new_key.to_sym : new_key] = new_value
|
39
|
+
end
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def ensure_keys(required_keys=[], optional_keys=[])
|
44
|
+
assert_valid_keys(required_keys + optional_keys)
|
45
|
+
required_keys.each do |k|
|
46
|
+
raise(ArgumentError, "Required key not found: #{k}") unless has_key?(k)
|
47
|
+
end
|
48
|
+
self
|
49
|
+
end
|
50
|
+
end
|
data/lib/lemon_way.rb
ADDED
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LemonWay::Client::WhiteLabel do
|
4
|
+
before do
|
5
|
+
@base_uri = "http://api.lemonway.com"
|
6
|
+
|
7
|
+
@default_params = {
|
8
|
+
wlLogin: "test",
|
9
|
+
wlPass: "test",
|
10
|
+
wlPDV: "test",
|
11
|
+
language: "fr",
|
12
|
+
version: "1.0",
|
13
|
+
channel: "W",
|
14
|
+
walletIp: "91.222.286.32"
|
15
|
+
}
|
16
|
+
|
17
|
+
subject.init @default_params.merge(:base_uri => @base_uri)
|
18
|
+
subject.rspec_reset
|
19
|
+
#subject.unstub!
|
20
|
+
WebMock.reset!
|
21
|
+
end
|
22
|
+
context "init" do
|
23
|
+
it "should accept underscored keys" do
|
24
|
+
params = @default_params.dup
|
25
|
+
params.delete(:wlLogin)
|
26
|
+
params[:wl_login] = "test"
|
27
|
+
subject.init params.merge(:base_uri => @base_uri)
|
28
|
+
subject.default_attributes.should have_key(:wlLogin)
|
29
|
+
end
|
30
|
+
it "should accept string keys" do
|
31
|
+
subject.init @default_params.stringify_keys.merge(:base_uri => @base_uri)
|
32
|
+
subject.default_attributes.should have_key(:wlLogin)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "LemonWay::Client::Base methods" do
|
37
|
+
|
38
|
+
context "make_body" do
|
39
|
+
before do
|
40
|
+
@params = { wallet: 1 }
|
41
|
+
@method_name = "tEst"
|
42
|
+
@xml = subject.make_body(@method_name, @params)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should return an instructed xml string" do
|
46
|
+
@xml.should be_a(String)
|
47
|
+
@xml.should include("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should wrap attrs into a a tag method_name" do
|
51
|
+
attrs = Hash.from_xml(@xml)
|
52
|
+
attrs.should have_key(@method_name)
|
53
|
+
|
54
|
+
@params.each do |k,v|
|
55
|
+
attrs[@method_name].should have_key(k.to_s)
|
56
|
+
attrs[@method_name][k.to_s].should eq(v)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
context "define_query_method" do
|
61
|
+
it "should add default_attributes to attrs arguments" do
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
context "query" do
|
66
|
+
it "should call method name and build body make_body" do
|
67
|
+
method_name = "io"
|
68
|
+
opts = {:a => 1}
|
69
|
+
type = :post
|
70
|
+
|
71
|
+
subject.should_receive(type).with( "/", :body => "xml").and_return({})
|
72
|
+
subject.should_receive(:make_body).with(method_name, opts).and_return("xml")
|
73
|
+
|
74
|
+
subject.query(type, method_name, opts)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should raise custom exception on error" do
|
78
|
+
stub_request(:post, subject.base_uri).to_return :status => 400, :body => fixture_file("register_wallet_failure.xml")
|
79
|
+
proc{
|
80
|
+
subject.query(:post, "io")
|
81
|
+
}.should raise_error(subject::Error)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should yield block if no exception" do
|
85
|
+
stub_request(:post, subject.base_uri).to_return :status => 200, :body => fixture_file("register_wallet_success.xml")
|
86
|
+
proc{
|
87
|
+
subject.query(:post, "io") do |response|
|
88
|
+
response.should be_a(ActiveSupport::HashWithIndifferentAccess)
|
89
|
+
end
|
90
|
+
}.should_not raise_error
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
context "camelize_and_ensure_keys!" do
|
95
|
+
def camelize_and_ensure_keys!(attrs, required_attrs=[], optional_attrs=[])
|
96
|
+
subject.camelize_and_ensure_keys! attrs.update(@default_params), required_attrs, optional_attrs
|
97
|
+
end
|
98
|
+
it "should raise error" do
|
99
|
+
proc{
|
100
|
+
camelize_and_ensure_keys!({:id => 1}, %i(id wallet))
|
101
|
+
#subject.camelize_and_ensure_keys!()
|
102
|
+
}.should raise_error(ArgumentError)
|
103
|
+
end
|
104
|
+
it "should raise error if an attribute has not a valid key" do
|
105
|
+
proc{
|
106
|
+
camelize_and_ensure_keys!({:id => 1, :walet => 2}, %i(id wallet))
|
107
|
+
#subject.camelize_and_ensure_keys!(@default_params.merge(:id => 1, :walet => 2), %i(id wallet))
|
108
|
+
}.should raise_error(ArgumentError)
|
109
|
+
end
|
110
|
+
it "should not raise error if all required attributes are present" do
|
111
|
+
proc{
|
112
|
+
camelize_and_ensure_keys!({:id => 1, :wallet => 2}, %i(id wallet))
|
113
|
+
}.should_not raise_error
|
114
|
+
end
|
115
|
+
it "should raise error if an additional attribute is passed" do
|
116
|
+
proc{
|
117
|
+
camelize_and_ensure_keys!({:id => 1, :wallet => 2, :wid => 2}, %i(id wallet))
|
118
|
+
}.should raise_error(ArgumentError)
|
119
|
+
end
|
120
|
+
it "should camelize_keys" do
|
121
|
+
attrs = {:id => 1, :first_name => 2}
|
122
|
+
proc{
|
123
|
+
camelize_and_ensure_keys!(attrs, %i(id firstName))
|
124
|
+
attrs.should have_key(:firstName)
|
125
|
+
}.should_not raise_error
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "methods" do
|
131
|
+
context "integration" do
|
132
|
+
it "register_wallet" do
|
133
|
+
params = {
|
134
|
+
wallet: 1,
|
135
|
+
client_mail: "nicolas.papon@paymium.com",
|
136
|
+
client_title: "M",
|
137
|
+
client_first_name: "nicolas",
|
138
|
+
client_last_name: "papon"
|
139
|
+
}
|
140
|
+
|
141
|
+
stub_request(:post, subject.base_uri).with do |request|
|
142
|
+
attrs = Hash.from_xml(request.body)
|
143
|
+
attrs.should have_key("RegisterWallet")
|
144
|
+
params.merge(subject.default_attributes).each do |k,v|
|
145
|
+
attrs["RegisterWallet"].should have_key(k.to_s)
|
146
|
+
attrs["RegisterWallet"][k.to_s].should eq(v)
|
147
|
+
end
|
148
|
+
end.to_return :status => 200, :body => fixture_file("register_wallet_success.xml")
|
149
|
+
wallet_id = subject.register_wallet params
|
150
|
+
wallet_id.should == "12345"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should respond to register_wallet" do
|
155
|
+
subject.respond_to? :register_wallet
|
156
|
+
end
|
157
|
+
it "should respond to get_wallet_details" do
|
158
|
+
subject.respond_to? :register_wallet
|
159
|
+
end
|
160
|
+
it "should respond to money_in" do
|
161
|
+
subject.respond_to? :money_in
|
162
|
+
end
|
163
|
+
it "should respond to get_wallet_details" do
|
164
|
+
subject.respond_to? :register_wallet
|
165
|
+
end
|
166
|
+
it "should respond to get_wallet_details" do
|
167
|
+
subject.respond_to? :register_wallet
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
data/spec/hash_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
context "camelize_keys" do
|
5
|
+
before do
|
6
|
+
@hash = {:first_name => "nicolas"}
|
7
|
+
@result_hash = @hash.camelize_keys
|
8
|
+
end
|
9
|
+
it "should camelize keys" do
|
10
|
+
@result_hash.should == {:firstName => "nicolas"}
|
11
|
+
end
|
12
|
+
it "should not destruct original hash" do
|
13
|
+
@hash.should == {:first_name => "nicolas"}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
context "camelize_keys!" do
|
17
|
+
before do
|
18
|
+
@hash = {:first_name => "nicolas"}
|
19
|
+
@result_hash = @hash.camelize_keys!
|
20
|
+
end
|
21
|
+
it "should camelize keys" do
|
22
|
+
@result_hash.should == {:firstName => "nicolas"}
|
23
|
+
end
|
24
|
+
it "should destruct original hash" do
|
25
|
+
@hash.should == {:firstName => "nicolas"}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
context "underscore_keys" do
|
29
|
+
before do
|
30
|
+
@hash = {:firstName => "nicolas"}
|
31
|
+
@result_hash = @hash.underscore_keys
|
32
|
+
end
|
33
|
+
it "should underscore keys" do
|
34
|
+
@result_hash.should == {:first_name => "nicolas"}
|
35
|
+
end
|
36
|
+
it "should not destruct original hash" do
|
37
|
+
@hash.should == {:firstName => "nicolas"}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
context "underscore_keys!" do
|
41
|
+
before do
|
42
|
+
@hash = {:firstName => "nicolas"}
|
43
|
+
@result_hash = @hash.underscore_keys!
|
44
|
+
end
|
45
|
+
it "should underscore keys" do
|
46
|
+
@result_hash.should == {:first_name => "nicolas"}
|
47
|
+
end
|
48
|
+
it "should destruct original hash" do
|
49
|
+
@hash.should == {:first_name => "nicolas"}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'pry'
|
5
|
+
require "lemon_way"
|
6
|
+
require 'webmock/rspec'
|
7
|
+
|
8
|
+
|
9
|
+
module Helpers
|
10
|
+
def fixture_file(name, dir_name="responses")
|
11
|
+
File.read File.join(File.expand_path(File.dirname(__FILE__)), "fixtures", dir_name, name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
17
|
+
config.filter_run :focus => true
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
config.include Helpers
|
20
|
+
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lemon_way
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Itkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: builder
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Describe me
|
98
|
+
email:
|
99
|
+
- nicolas.papon@webflows.fr
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- .rspec
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lemon_way.gemspec
|
111
|
+
- lib/lemon_way.rb
|
112
|
+
- lib/lemon_way/client.rb
|
113
|
+
- lib/lemon_way/hash.rb
|
114
|
+
- lib/lemon_way/version.rb
|
115
|
+
- spec/client_spec.rb
|
116
|
+
- spec/fixtures/responses/register_wallet_failure.xml
|
117
|
+
- spec/fixtures/responses/register_wallet_success.xml
|
118
|
+
- spec/hash_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
homepage: ''
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.1.11
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Describe me
|
144
|
+
test_files:
|
145
|
+
- spec/client_spec.rb
|
146
|
+
- spec/fixtures/responses/register_wallet_failure.xml
|
147
|
+
- spec/fixtures/responses/register_wallet_success.xml
|
148
|
+
- spec/hash_spec.rb
|
149
|
+
- spec/spec_helper.rb
|
150
|
+
has_rdoc:
|