ruby-ecomm-client 1.1.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,42 +1,57 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://bonsai.dev.glbt1.gdg/
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
uri: http://bonsai.dev.glbt1.gdg/Bonsai/BonsaiManager/Service.asmx
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="#Bonsai"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:GetAccountXml><tns:ResourceID>b6be6fd0-c1a5-11e3-8e42-0050569575d8</tns:ResourceID><tns:ResourceType>outright</tns:ResourceType><tns:IDType>ORION</tns:IDType><tns:TreeID>2410</tns:TreeID><tns:PrivateLabelID>1</tns:PrivateLabelID></tns:GetAccountXml></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
soapaction:
|
13
|
+
- ! '"#Bonsai/GetAccountXml"'
|
14
|
+
content-type:
|
10
15
|
- text/xml;charset=UTF-8
|
11
|
-
content-length:
|
12
|
-
-
|
13
|
-
accept:
|
14
|
-
-
|
15
|
-
|
16
|
-
-
|
17
|
-
response:
|
18
|
-
status:
|
16
|
+
content-length:
|
17
|
+
- '515'
|
18
|
+
accept:
|
19
|
+
- ! '*/*'
|
20
|
+
user-agent:
|
21
|
+
- Ruby
|
22
|
+
response:
|
23
|
+
status:
|
19
24
|
code: 200
|
20
25
|
message: OK
|
21
|
-
headers:
|
22
|
-
|
23
|
-
- text/xml; charset=utf-8
|
24
|
-
content-length:
|
25
|
-
- "1626"
|
26
|
-
x-aspnet-version:
|
27
|
-
- 4.0.30319
|
28
|
-
cache-control:
|
26
|
+
headers:
|
27
|
+
cache-control:
|
29
28
|
- private, max-age=0
|
30
|
-
|
29
|
+
content-type:
|
30
|
+
- text/xml; charset=utf-8
|
31
|
+
server:
|
31
32
|
- Microsoft-IIS/7.0
|
32
|
-
|
33
|
-
-
|
34
|
-
|
35
|
-
- close
|
36
|
-
x-powered-by:
|
33
|
+
x-aspnet-version:
|
34
|
+
- 4.0.30319
|
35
|
+
x-powered-by:
|
37
36
|
- ASP.NET
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
date:
|
38
|
+
- Fri, 18 Apr 2014 16:29:10 GMT
|
39
|
+
connection:
|
40
|
+
- close
|
41
|
+
content-length:
|
42
|
+
- '924'
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
46
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse
|
47
|
+
xmlns="#Bonsai"><ResultCode>0</ResultCode><AccountXml><Bonsai><Bonsai PrivateLabelID="1"
|
48
|
+
ResourceID="b6be6fd0-c1a5-11e3-8e42-0050569575d8" IsPastDue="False" IsFree="False"
|
49
|
+
CurrentTreeID="2410" CurrentUnifiedProductID="326365" xmlns=""><Tree TreeID="2410"
|
50
|
+
NodeID="2410" UnifiedProductID="326365" IsFree="False"><Transition NodeName="Starter
|
51
|
+
Outright Get Paid - Monthly" UnifiedProductID="326363" TreeID="2402" IsFree="False"
|
52
|
+
NodeID="2402" /><Transition NodeName="Premium Outright Get Paid - Monthly"
|
53
|
+
UnifiedProductID="326388" TreeID="2418" IsFree="False" NodeID="2418" /><FilteredTransitions
|
54
|
+
/></Tree></Bonsai></Bonsai></AccountXml></GetAccountXmlResponse></soap:Body></soap:Envelope>
|
55
|
+
http_version: '1.1'
|
56
|
+
recorded_at: Fri, 18 Apr 2014 16:30:09 GMT
|
42
57
|
recorded_with: VCR 2.8.0
|
@@ -1,42 +1,57 @@
|
|
1
|
-
---
|
2
|
-
http_interactions:
|
3
|
-
- request:
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
4
|
method: post
|
5
|
-
uri: http://bonsai.dev.glbt1.gdg/
|
6
|
-
body:
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
uri: http://bonsai.dev.glbt1.gdg/Bonsai/BonsaiManager/Service.asmx
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
9
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="#Bonsai"
|
10
|
+
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:GetAccountXml><tns:ResourceID>b6be6fd0-c1a5-11e3-8e42-0050569575d8</tns:ResourceID><tns:ResourceType>outright</tns:ResourceType><tns:IDType>ORION</tns:IDType><tns:TreeID>2402</tns:TreeID><tns:PrivateLabelID>1</tns:PrivateLabelID></tns:GetAccountXml></env:Body></env:Envelope>
|
11
|
+
headers:
|
12
|
+
soapaction:
|
13
|
+
- ! '"#Bonsai/GetAccountXml"'
|
14
|
+
content-type:
|
10
15
|
- text/xml;charset=UTF-8
|
11
|
-
content-length:
|
12
|
-
-
|
13
|
-
accept:
|
14
|
-
-
|
15
|
-
|
16
|
-
-
|
17
|
-
response:
|
18
|
-
status:
|
16
|
+
content-length:
|
17
|
+
- '515'
|
18
|
+
accept:
|
19
|
+
- ! '*/*'
|
20
|
+
user-agent:
|
21
|
+
- Ruby
|
22
|
+
response:
|
23
|
+
status:
|
19
24
|
code: 200
|
20
25
|
message: OK
|
21
|
-
headers:
|
22
|
-
|
23
|
-
- text/xml; charset=utf-8
|
24
|
-
content-length:
|
25
|
-
- "768"
|
26
|
-
x-aspnet-version:
|
27
|
-
- 4.0.30319
|
28
|
-
cache-control:
|
26
|
+
headers:
|
27
|
+
cache-control:
|
29
28
|
- private, max-age=0
|
30
|
-
|
29
|
+
content-type:
|
30
|
+
- text/xml; charset=utf-8
|
31
|
+
server:
|
31
32
|
- Microsoft-IIS/7.0
|
32
|
-
|
33
|
-
-
|
34
|
-
|
35
|
-
- close
|
36
|
-
x-powered-by:
|
33
|
+
x-aspnet-version:
|
34
|
+
- 4.0.30319
|
35
|
+
x-powered-by:
|
37
36
|
- ASP.NET
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
date:
|
38
|
+
- Fri, 18 Apr 2014 16:29:09 GMT
|
39
|
+
connection:
|
40
|
+
- close
|
41
|
+
content-length:
|
42
|
+
- '926'
|
43
|
+
body:
|
44
|
+
encoding: US-ASCII
|
45
|
+
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
46
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse
|
47
|
+
xmlns="#Bonsai"><ResultCode>0</ResultCode><AccountXml><Bonsai><Bonsai PrivateLabelID="1"
|
48
|
+
ResourceID="b6be6fd0-c1a5-11e3-8e42-0050569575d8" IsPastDue="False" IsFree="False"
|
49
|
+
CurrentTreeID="2410" CurrentUnifiedProductID="326365" xmlns=""><Tree TreeID="2402"
|
50
|
+
NodeID="2402" UnifiedProductID="326363" IsFree="False"><Transition NodeName="Essential
|
51
|
+
Outright Get Paid - Monthly" UnifiedProductID="326365" TreeID="2410" IsFree="False"
|
52
|
+
NodeID="2410" /><Transition NodeName="Premium Outright Get Paid - Monthly"
|
53
|
+
UnifiedProductID="326388" TreeID="2418" IsFree="False" NodeID="2418" /><FilteredTransitions
|
54
|
+
/></Tree></Bonsai></Bonsai></AccountXml></GetAccountXmlResponse></soap:Body></soap:Envelope>
|
55
|
+
http_version: '1.1'
|
56
|
+
recorded_at: Fri, 18 Apr 2014 16:30:08 GMT
|
42
57
|
recorded_with: VCR 2.8.0
|
data/lib/ruby-ecomm-client.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
|
+
require 'freddy'
|
1
2
|
require 'savon'
|
2
3
|
|
3
4
|
require 'ruby-ecomm-client/version'
|
4
5
|
require 'ruby-ecomm-client/error'
|
5
|
-
require 'ruby-ecomm-client
|
6
|
+
require 'ruby-ecomm-client'
|
7
|
+
require 'ruby-ecomm-client/util'
|
8
|
+
|
9
|
+
require 'ruby-ecomm-client/service_base'
|
10
|
+
require 'ruby-ecomm-client/service_manager'
|
11
|
+
require 'ruby-ecomm-client/service_profile'
|
12
|
+
require 'ruby-ecomm-client/service_purchase'
|
13
|
+
|
14
|
+
require 'ruby-ecomm-client/config'
|
6
15
|
require 'ruby-ecomm-client/client'
|
7
16
|
|
8
17
|
module RubyEcommClient
|
9
18
|
# Your code goes here...
|
10
19
|
end
|
20
|
+
|
21
|
+
#HACK: Avoid broken adapter ignoring SSL Certs when ExCon installed
|
22
|
+
HTTPI::Adapter.use = :net_http
|
@@ -1,33 +1,6 @@
|
|
1
1
|
module RubyEcommClient
|
2
2
|
class Client
|
3
|
-
include
|
4
|
-
|
5
|
-
ENDPOINTS_MANAGER = {
|
6
|
-
:development => 'http://bonsai.dev.glbt1.gdg/bonsai/bonsaimanager/service.asmx',
|
7
|
-
:test => 'http://bonsai.dev.glbt1.gdg/bonsai/bonsaimanager/service.asmx',
|
8
|
-
:production => 'http://gdbonsaiXv01.prod.mesa1.gdg/bonsai/bonsaimanager/service.asmx',
|
9
|
-
:qa => 'http://bonsai.test.glbt1.gdg/bonsai/bonsaimanager/service.asmx'
|
10
|
-
}
|
11
|
-
ENDPOINTS_PROFILE = {
|
12
|
-
:development => 'http://gdcomm.dev.glbt1.gdg/WSgdInstantPurchasePublic/Service.asmx',
|
13
|
-
:test => 'http://gdcomm.dev.glbt1.gdg/WSgdInstantPurchasePublic/Service.asmx',
|
14
|
-
:production => 'http://gdcomm.godaddy.com/WSgdInstantPurchasePublic/Service.asmx',
|
15
|
-
:qa => 'http://gdcomm.test.glbt1.gdg/WSgdInstantPurchasePublic/Service.asmx'
|
16
|
-
}
|
17
|
-
ENDPOINTS_PURCHASE = {
|
18
|
-
:development => 'https://bonsaipurchase.dev.glbt1.gdg/BonsaiPurchase/Service.asmx',
|
19
|
-
:test => 'https://bonsaipurchase.dev.glbt1.gdg/BonsaiPurchase/Service.asmx',
|
20
|
-
:production => 'https://bonsaipurchase.prod.mesa1.gdg/BonsaiPurchase/Service.asmx',
|
21
|
-
:qa => 'https://bonsaipurchase.test.glbt1.gdg/BonsaiPurchase/Service.asmx'
|
22
|
-
}
|
23
|
-
|
24
|
-
HOST_NAME = `hostname`.chomp
|
25
|
-
|
26
|
-
ID_TYPE = 'ORION'
|
27
|
-
|
28
|
-
WSDL_MANAGER = 'manager.wsdl'
|
29
|
-
WSDL_PROFILE = 'profile.wsdl'
|
30
|
-
WSDL_PURCHASE = 'purchase.wsdl'
|
3
|
+
include Utils
|
31
4
|
|
32
5
|
attr_accessor :shopper_id, :resource_type, :resource_id
|
33
6
|
|
@@ -41,148 +14,46 @@ module RubyEcommClient
|
|
41
14
|
@resource_id = resource_id
|
42
15
|
end
|
43
16
|
|
44
|
-
def self.environment
|
45
|
-
((defined?(Rails) ? Rails.env : ENV['RAILS_ENV']) || 'development').to_sym
|
46
|
-
end
|
47
|
-
|
48
17
|
def express_checkout?
|
49
|
-
|
50
|
-
'sShopperID' => @shopper_id
|
51
|
-
})
|
52
|
-
response = convert_value(result.body[:shopper_has_instant_purchase_payment_response])
|
53
|
-
response[:b_has_instant_purchase_payment]
|
18
|
+
service_profile.express_checkout?
|
54
19
|
end
|
55
20
|
|
56
21
|
def account_info(source_tree_id = 0)
|
57
|
-
|
58
|
-
'ResourceID' => @resource_id,
|
59
|
-
'ResourceType' => @resource_type,
|
60
|
-
'IDType' => ID_TYPE,
|
61
|
-
'TreeID' => source_tree_id,
|
62
|
-
'PrivateLabelID' => 1
|
63
|
-
})
|
64
|
-
response = convert_response(result.body[:get_account_xml_response])
|
65
|
-
if response[:result_code] == 0
|
66
|
-
response[:account_xml][:bonsai][:bonsai]
|
67
|
-
else
|
68
|
-
raise RubyEcommError.new(response[:result_code])
|
69
|
-
end
|
22
|
+
service_manager.account_info(source_tree_id)
|
70
23
|
end
|
71
24
|
|
72
25
|
def transitions(source_tree_id = 0)
|
73
|
-
transitions
|
74
|
-
transitions.is_a?(Array) ? transitions : [transitions]
|
26
|
+
service_manager.transitions(source_tree_id)
|
75
27
|
end
|
76
28
|
|
77
|
-
def
|
78
|
-
|
79
|
-
|
80
|
-
if express_checkout?
|
81
|
-
request_change_via_express(target_tree_id, client_ip)
|
82
|
-
else
|
83
|
-
request_change_via_manager(target_tree_id)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def blank?(value)
|
90
|
-
value.nil? || value.to_s == ''
|
29
|
+
def find_transition(transitions, target_pfid)
|
30
|
+
service_manager.find_transition(transitions, target_pfid)
|
91
31
|
end
|
92
32
|
|
93
|
-
def
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
def shared_globals(globals)
|
98
|
-
globals.convert_response_tags_to TAG_CONVERTER
|
99
|
-
globals.log false
|
100
|
-
globals.logger Rails.logger if defined?(Rails)
|
101
|
-
globals.namespace '#Bonsai'
|
102
|
-
globals.open_timeout 15
|
103
|
-
globals.read_timeout 15
|
33
|
+
def request_change_via_manager(target_tree_id)
|
34
|
+
service_manager.request_change_via_manager(target_tree_id)
|
104
35
|
end
|
105
36
|
|
106
|
-
def
|
107
|
-
|
108
|
-
shared_globals(globals)
|
109
|
-
|
110
|
-
globals.wsdl "#{wsdl_path}#{WSDL_MANAGER}"
|
111
|
-
globals.endpoint ENDPOINTS_MANAGER[Client.environment]
|
112
|
-
end
|
37
|
+
def request_change_via_express(target_tree_id, client_ip = '127.0.0.1')
|
38
|
+
service_purchase.request_change_via_express(target_tree_id, client_ip)
|
113
39
|
end
|
114
40
|
|
115
|
-
def
|
116
|
-
|
117
|
-
shared_globals(globals)
|
118
|
-
|
119
|
-
globals.wsdl "#{wsdl_path}#{WSDL_PROFILE}"
|
120
|
-
globals.endpoint ENDPOINTS_PROFILE[Client.environment]
|
121
|
-
globals.namespace 'http://tempuri.org/'
|
122
|
-
end
|
41
|
+
def request_change(target_tree_id, client_ip = '127.0.0.1')
|
42
|
+
service_purchase.request_change(target_tree_id, client_ip)
|
123
43
|
end
|
124
44
|
|
125
|
-
|
126
|
-
@client_purchase ||= Savon.client do |globals|
|
127
|
-
shared_globals(globals)
|
128
|
-
|
129
|
-
globals.wsdl "#{wsdl_path}#{WSDL_PURCHASE}"
|
130
|
-
globals.endpoint ENDPOINTS_PURCHASE[Client.environment]
|
45
|
+
private
|
131
46
|
|
132
|
-
|
133
|
-
|
134
|
-
globals.ssl_cert_file ssl_cert_file if File.exists?(ssl_cert_file)
|
135
|
-
ssl_cert_key_file = "config/environments/#{Client.environment}/client.key"
|
136
|
-
globals.ssl_cert_key_file ssl_cert_key_file if File.exists?(ssl_cert_key_file)
|
137
|
-
end
|
47
|
+
def service_manager
|
48
|
+
@service_manager ||= ServiceManager.new(self)
|
138
49
|
end
|
139
50
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
result = client_purchase.call(:purchase_change_account_request, :message => {
|
144
|
-
'ResourceID' => @resource_id,
|
145
|
-
'ResourceType' => @resource_type,
|
146
|
-
'IDType' => ID_TYPE,
|
147
|
-
'AccountPurchaseChangeXml' => "<ClientChange TreeID='#{target_tree_id}' ShopperID='#{@shopper_id}' TransactionCurrency='USD' RequestingApp='outright' RequestingAppHost='#{HOST_NAME}' ClientAddr='#{client_ip}' EnteredBy='customer' OrderSource='Online' RedirectToBasket='false' EstimateOnly='false' SendConfirmEmail='false'/>",
|
148
|
-
'RenewalPFID' => 0,
|
149
|
-
'RenewalPeriods' => 0,
|
150
|
-
'ItemRequestXml' => '<itemRequest/>'
|
151
|
-
})
|
152
|
-
response = convert_response(result.body[:purchase_change_account_request_response])
|
153
|
-
if response[:result_code] == 0
|
154
|
-
{
|
155
|
-
:used_express_checkout => true,
|
156
|
-
:request_result => response[:purchase_change_account_request_result],
|
157
|
-
:error => response[:error],
|
158
|
-
:order_xml => response[:order_xml]
|
159
|
-
}
|
160
|
-
else
|
161
|
-
raise RubyEcommError.new(response[:result_code], response[:change_account_request_result])
|
162
|
-
end
|
51
|
+
def service_profile
|
52
|
+
@service_profile ||= ServiceProfile.new(self)
|
163
53
|
end
|
164
54
|
|
165
|
-
def
|
166
|
-
|
167
|
-
|
168
|
-
result = client_manager.call(:change_account_request, :message => {
|
169
|
-
'ResourceID' => @resource_id,
|
170
|
-
'ResourceType' => @resource_type,
|
171
|
-
'IDType' => ID_TYPE,
|
172
|
-
'AccountChangeXml' => "<ClientChange TreeID='#{target_tree_id}' ShopperID='#{@shopper_id}'/>",
|
173
|
-
'RenewalPFID' => 0,
|
174
|
-
'RenewalPeriods' => 0,
|
175
|
-
'ItemRequestXml' => '<itemRequest/>'
|
176
|
-
})
|
177
|
-
response = convert_response(result.body[:change_account_request_response])
|
178
|
-
if response[:result_code] == 0
|
179
|
-
{
|
180
|
-
:used_express_checkout => false,
|
181
|
-
:request_result => response[:change_account_request_result]
|
182
|
-
}
|
183
|
-
else
|
184
|
-
raise RubyEcommError.new(response[:result_code], response[:change_account_request_result])
|
185
|
-
end
|
55
|
+
def service_purchase
|
56
|
+
@service_purchase ||= ServicePurchase.new(self)
|
186
57
|
end
|
187
58
|
end
|
188
59
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RubyEcommClient
|
2
|
+
class Config
|
3
|
+
include Utils
|
4
|
+
|
5
|
+
attr_accessor :requesting_app,
|
6
|
+
:ssl_cert_content,
|
7
|
+
:ssl_cert_file,
|
8
|
+
:ssl_cert_key_content,
|
9
|
+
:ssl_cert_key_file
|
10
|
+
|
11
|
+
def validate
|
12
|
+
raise ArgumentError.new('requesting_app must be specified') if Config.blank?(requesting_app)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
cur_config = config
|
18
|
+
yield cur_config
|
19
|
+
cur_config.validate
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.config
|
23
|
+
@config ||= Config.new
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module RubyEcommClient
|
2
|
+
class ServiceBase
|
3
|
+
include Utils
|
4
|
+
include Freddy::ResponseConverter
|
5
|
+
|
6
|
+
ID_TYPE = 'ORION'
|
7
|
+
|
8
|
+
def initialize(config_client)
|
9
|
+
raise ArgumentError.new('config_client must be specified') if config_client.nil?
|
10
|
+
|
11
|
+
@config_client = config_client
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
attr_reader :config_client
|
17
|
+
|
18
|
+
def config_global
|
19
|
+
RubyEcommClient.config
|
20
|
+
end
|
21
|
+
|
22
|
+
def wsdl_path
|
23
|
+
"#{File.expand_path(File.dirname(__FILE__))}/wsdl/"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_client
|
27
|
+
Savon.client do |globals|
|
28
|
+
globals.convert_response_tags_to TAG_CONVERTER
|
29
|
+
globals.log false
|
30
|
+
globals.logger Rails.logger if defined?(Rails)
|
31
|
+
globals.namespace '#Bonsai'
|
32
|
+
globals.open_timeout 15
|
33
|
+
globals.read_timeout 15
|
34
|
+
|
35
|
+
yield globals
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def generate_request_hash
|
40
|
+
{
|
41
|
+
'ResourceID' => config_client.resource_id,
|
42
|
+
'ResourceType' => config_client.resource_type,
|
43
|
+
'IDType' => ID_TYPE
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_request_change_hash
|
48
|
+
generate_request_hash.merge({
|
49
|
+
'RenewalPFID' => 0,
|
50
|
+
'RenewalPeriods' => 0,
|
51
|
+
'ItemRequestXml' => '<itemRequest/>'
|
52
|
+
})
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|