ruby-ecomm-client 1.1.0 → 1.7.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.
- checksums.yaml +15 -0
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/README.md +10 -0
- data/fixtures/vcr_cassettes/account_info/default.yml +49 -34
- data/fixtures/vcr_cassettes/account_info/unknown/resource_id.yml +42 -34
- data/fixtures/vcr_cassettes/account_info/unknown/resource_type.yml +42 -34
- data/fixtures/vcr_cassettes/account_info/unknown/source_tree_id.yml +42 -34
- data/fixtures/vcr_cassettes/express_checkout/configured.yml +39 -31
- data/fixtures/vcr_cassettes/express_checkout/unknown.yml +39 -31
- data/fixtures/vcr_cassettes/request_change/express/downgrade/default.yml +46 -36
- data/fixtures/vcr_cassettes/request_change/express/downgrade/noop.yml +55 -34
- data/fixtures/vcr_cassettes/request_change/express/downgrade/unknown/resource_id.yml +46 -34
- data/fixtures/vcr_cassettes/request_change/express/downgrade/unknown/resource_type.yml +47 -34
- data/fixtures/vcr_cassettes/request_change/express/downgrade/unknown/target_tree_id.yml +46 -34
- data/fixtures/vcr_cassettes/request_change/express/relay/default.yml +48 -0
- data/fixtures/vcr_cassettes/request_change/express/upgrade/default.yml +55 -36
- data/fixtures/vcr_cassettes/request_change/express/upgrade/noop.yml +46 -34
- data/fixtures/vcr_cassettes/request_change/express/upgrade/unknown/resource_id.yml +46 -34
- data/fixtures/vcr_cassettes/request_change/express/upgrade/unknown/resource_type.yml +47 -34
- data/fixtures/vcr_cassettes/request_change/express/upgrade/unknown/target_tree_id.yml +46 -34
- data/fixtures/vcr_cassettes/request_change/manager/downgrade/default.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/downgrade/noop.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/downgrade/unknown/resource_id.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/downgrade/unknown/resource_type.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/downgrade/unknown/target_tree_id.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/relay/default.yml +100 -0
- data/fixtures/vcr_cassettes/request_change/manager/upgrade/default.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/upgrade/noop.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/upgrade/unknown/resource_id.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/upgrade/unknown/resource_type.yml +43 -34
- data/fixtures/vcr_cassettes/request_change/manager/upgrade/unknown/target_tree_id.yml +43 -34
- data/fixtures/vcr_cassettes/transitions/default/unknown/source_tree_id.yml +42 -34
- data/fixtures/vcr_cassettes/transitions/many.yml +49 -34
- data/fixtures/vcr_cassettes/transitions/one.yml +49 -34
- data/lib/ruby-ecomm-client.rb +13 -1
- data/lib/ruby-ecomm-client/client.rb +19 -148
- data/lib/ruby-ecomm-client/config.rb +25 -0
- data/lib/ruby-ecomm-client/service_base.rb +55 -0
- data/lib/ruby-ecomm-client/service_manager.rb +75 -0
- data/lib/ruby-ecomm-client/service_profile.rb +30 -0
- data/lib/ruby-ecomm-client/service_purchase.rb +79 -0
- data/lib/ruby-ecomm-client/util.rb +16 -0
- data/lib/ruby-ecomm-client/version.rb +1 -1
- data/ruby-ecomm-client.gemspec +2 -1
- data/script/bootstrap +68 -0
- data/script/cibuild +4 -5
- data/spec/ruby-ecomm-client/client_spec.rb +32 -339
- data/spec/ruby-ecomm-client/config_spec.rb +56 -0
- data/spec/ruby-ecomm-client/service_base_spec.rb +119 -0
- data/spec/ruby-ecomm-client/service_manager_spec.rb +285 -0
- data/spec/ruby-ecomm-client/service_profile_spec.rb +33 -0
- data/spec/ruby-ecomm-client/service_purchase_spec.rb +160 -0
- data/spec/ruby-ecomm-client/util_spec.rb +66 -0
- data/spec/spec_helper.rb +10 -0
- metadata +160 -152
- data/lib/ruby-ecomm-client/converter.rb +0 -45
- data/spec/ruby-ecomm-client/converter_spec.rb +0 -96
@@ -1,45 +0,0 @@
|
|
1
|
-
module ResponseConverter
|
2
|
-
TAG_CONVERTER = lambda do |tag|
|
3
|
-
tag.snakecase.gsub(/@/, '').gsub(/unified_/, '').gsub(/current_/, '').to_sym
|
4
|
-
end
|
5
|
-
|
6
|
-
def convert_value(input)
|
7
|
-
if input == 'True' || input == 'true' || input == 'TRUE'
|
8
|
-
return true
|
9
|
-
elsif input == 'False' || input == 'false' || input == 'FALSE'
|
10
|
-
return false
|
11
|
-
else
|
12
|
-
begin
|
13
|
-
return Integer(input)
|
14
|
-
rescue StandardError => e
|
15
|
-
begin
|
16
|
-
return Float(input)
|
17
|
-
rescue StandardError => e
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
input
|
22
|
-
end
|
23
|
-
|
24
|
-
def convert_response(input)
|
25
|
-
if input.is_a?(Hash)
|
26
|
-
input.each do |key, value|
|
27
|
-
if value.is_a?(Hash) || value.is_a?(Array)
|
28
|
-
convert_response(value)
|
29
|
-
else
|
30
|
-
input[key] = convert_value(value)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
elsif input.is_a?(Array)
|
34
|
-
input.each_with_index do |value, index|
|
35
|
-
if value.is_a?(Hash) || value.is_a?(Array)
|
36
|
-
convert_response(value)
|
37
|
-
else
|
38
|
-
input[index] = convert_value(value)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
else
|
42
|
-
input
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class TestResponder
|
4
|
-
include ::ResponseConverter
|
5
|
-
end
|
6
|
-
|
7
|
-
describe ResponseConverter do
|
8
|
-
before do
|
9
|
-
@responder = TestResponder.new
|
10
|
-
end
|
11
|
-
|
12
|
-
context "#CONVERTER" do
|
13
|
-
it "snakecase" do
|
14
|
-
ResponseConverter::TAG_CONVERTER.call('TestSnake').should eq(:test_snake)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "remove @" do
|
18
|
-
ResponseConverter::TAG_CONVERTER.call('@test').should eq(:test)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "remove unified_" do
|
22
|
-
ResponseConverter::TAG_CONVERTER.call('unified_test').should eq(:test)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "remove current_" do
|
26
|
-
ResponseConverter::TAG_CONVERTER.call('current_test').should eq(:test)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "all together" do
|
30
|
-
ResponseConverter::TAG_CONVERTER.call('@CurrentUnifiedTest').should eq(:test)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "#convert_value" do
|
35
|
-
it "convert lower boolean string" do
|
36
|
-
@responder.convert_value('true').should eq(true)
|
37
|
-
@responder.convert_value('false').should eq(false)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "convert title boolean string" do
|
41
|
-
@responder.convert_value('True').should eq(true)
|
42
|
-
@responder.convert_value('false').should eq(false)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "convert upper boolean string" do
|
46
|
-
@responder.convert_value('TRUE').should eq(true)
|
47
|
-
@responder.convert_value('FALSE').should eq(false)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "convert float string" do
|
51
|
-
value = @responder.convert_value('-1.0')
|
52
|
-
value.class.should eq(Float)
|
53
|
-
value.should eq(-1.0)
|
54
|
-
|
55
|
-
value = @responder.convert_value('9.09')
|
56
|
-
value.class.should eq(Float)
|
57
|
-
value.should eq(9.09)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "convert integer string" do
|
61
|
-
value = @responder.convert_value('-324')
|
62
|
-
value.class.should eq(Fixnum)
|
63
|
-
value.should eq(-324)
|
64
|
-
|
65
|
-
value = @responder.convert_value('537')
|
66
|
-
value.class.should eq(Fixnum)
|
67
|
-
value.should eq(537)
|
68
|
-
end
|
69
|
-
|
70
|
-
it "otherwise return same" do
|
71
|
-
@responder.convert_value('unknown').should eq('unknown')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "#convert_response" do
|
76
|
-
it "convert each Hash value" do
|
77
|
-
@responder.convert_response({ :a => '-1', :b => '2.0', :c => 'True', :d => 'other' }).should eq({ :a => -1, :b => 2.0, :c => true, :d => 'other' })
|
78
|
-
end
|
79
|
-
|
80
|
-
it "convert each nested Array value" do
|
81
|
-
@responder.convert_response({ :a => '-1', :b => ['2.0', 'True', 'other'] }).should eq({ :a => -1, :b => [2.0, true, 'other' ] })
|
82
|
-
end
|
83
|
-
|
84
|
-
it "convert each nested Hash value" do
|
85
|
-
@responder.convert_response({ :a => '-1', :b => { :aa => '2.0', :bb => 'True', :cc => 'other' } }).should eq({ :a => -1, :b => { :aa => 2.0, :bb => true, :cc => 'other' } })
|
86
|
-
end
|
87
|
-
|
88
|
-
it "convert each Hash value in each Array entry" do
|
89
|
-
@responder.convert_response([{ :a => '-1', :b => '2.0', :c => 'True' }, { :a => 'False', :b => '5.4', :c => '-332.78' }]).should eq([{ :a => -1, :b => 2.0, :c => true }, { :a => false, :b => 5.4, :c => -332.78 }])
|
90
|
-
end
|
91
|
-
|
92
|
-
it "otherwise return same" do
|
93
|
-
@responder.convert_response('unknown').should eq('unknown')
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|