ruby-ecomm-client 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -2
- data/README.md +3 -7
- data/fixtures/vcr_cassettes/account_info/default.yml +22 -22
- data/fixtures/vcr_cassettes/account_info/unknown/resource_id.yml +21 -21
- data/fixtures/vcr_cassettes/account_info/unknown/resource_type.yml +21 -21
- data/fixtures/vcr_cassettes/account_info/unknown/source_tree_id.yml +21 -21
- data/fixtures/vcr_cassettes/express_checkout/configured.yml +17 -17
- data/fixtures/vcr_cassettes/express_checkout/unknown.yml +17 -17
- data/fixtures/vcr_cassettes/request_change/express/downgrade/default.yml +44 -0
- data/fixtures/vcr_cassettes/request_change/express/downgrade/noop.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/downgrade/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/downgrade/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/downgrade/unknown/target_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/upgrade/default.yml +44 -0
- data/fixtures/vcr_cassettes/request_change/express/upgrade/noop.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/upgrade/unknown/resource_id.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/upgrade/unknown/resource_type.yml +42 -0
- data/fixtures/vcr_cassettes/request_change/express/upgrade/unknown/target_tree_id.yml +42 -0
- data/fixtures/vcr_cassettes/{downgrade → request_change/manager/downgrade}/default.yml +18 -18
- data/fixtures/vcr_cassettes/{downgrade → request_change/manager/downgrade}/noop.yml +17 -17
- data/fixtures/vcr_cassettes/{downgrade → request_change/manager/downgrade}/unknown/resource_id.yml +17 -17
- data/fixtures/vcr_cassettes/{upgrade → request_change/manager/downgrade}/unknown/resource_type.yml +17 -17
- data/fixtures/vcr_cassettes/{downgrade → request_change/manager/downgrade}/unknown/target_tree_id.yml +17 -17
- data/fixtures/vcr_cassettes/{upgrade → request_change/manager/upgrade}/default.yml +18 -18
- data/fixtures/vcr_cassettes/{upgrade → request_change/manager/upgrade}/noop.yml +17 -17
- data/fixtures/vcr_cassettes/{upgrade → request_change/manager/upgrade}/unknown/resource_id.yml +17 -17
- data/fixtures/vcr_cassettes/{downgrade → request_change/manager/upgrade}/unknown/resource_type.yml +17 -17
- data/fixtures/vcr_cassettes/{upgrade → request_change/manager/upgrade}/unknown/target_tree_id.yml +17 -17
- data/fixtures/vcr_cassettes/transitions/default/unknown/source_tree_id.yml +13 -13
- data/fixtures/vcr_cassettes/transitions/many.yml +14 -14
- data/fixtures/vcr_cassettes/transitions/one.yml +14 -14
- data/lib/ruby-ecomm-client/client.rb +61 -21
- data/lib/ruby-ecomm-client/version.rb +1 -1
- data/spec/ruby-ecomm-client/client_spec.rb +203 -82
- data/spec/spec_helper.rb +2 -0
- metadata +24 -15
- data/fixtures/vcr_cassettes/transitions/unknown/source_tree_id.yml +0 -42
data/fixtures/vcr_cassettes/{upgrade → request_change/manager/upgrade}/unknown/target_tree_id.yml
RENAMED
@@ -1,42 +1,42 @@
|
|
1
1
|
---
|
2
|
-
recorded_with: VCR 2.8.0
|
3
2
|
http_interactions:
|
4
3
|
- request:
|
5
4
|
method: post
|
6
5
|
uri: http://bonsai.dev.glbt1.gdg/bonsai/bonsaimanager/service.asmx
|
7
6
|
body:
|
8
|
-
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:
|
7
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:tns="#Bonsai" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:ChangeAccountRequest><tns:ItemRequestXml><itemRequest/></tns:ItemRequestXml><tns:AccountChangeXml><ClientChange TreeID='73223' ShopperID='922411'/></tns:AccountChangeXml><tns:RenewalPFID>0</tns:RenewalPFID><tns:IDType>ORION</tns:IDType><tns:ResourceType>outright</tns:ResourceType><tns:RenewalPeriods>0</tns:RenewalPeriods><tns:ResourceID>10e16f14-b606-11e3-a45e-0050569575d8</tns:ResourceID></tns:ChangeAccountRequest></env:Body></env:Envelope>
|
9
8
|
headers:
|
10
|
-
soapaction:
|
11
|
-
- "\"#Bonsai/ChangeAccountRequest\""
|
12
|
-
accept:
|
13
|
-
- "*/*"
|
14
|
-
content-length:
|
15
|
-
- "697"
|
16
9
|
content-type:
|
17
10
|
- text/xml;charset=UTF-8
|
11
|
+
content-length:
|
12
|
+
- "697"
|
13
|
+
accept:
|
14
|
+
- "*/*"
|
15
|
+
soapaction:
|
16
|
+
- "\"#Bonsai/ChangeAccountRequest\""
|
18
17
|
response:
|
19
18
|
status:
|
20
19
|
code: 200
|
21
20
|
message: OK
|
22
21
|
headers:
|
22
|
+
content-type:
|
23
|
+
- text/xml; charset=utf-8
|
24
|
+
content-length:
|
25
|
+
- "411"
|
23
26
|
x-aspnet-version:
|
24
27
|
- 4.0.30319
|
28
|
+
cache-control:
|
29
|
+
- private, max-age=0
|
25
30
|
server:
|
26
31
|
- Microsoft-IIS/7.0
|
32
|
+
date:
|
33
|
+
- Fri, 28 Mar 2014 00:22:36 GMT
|
27
34
|
connection:
|
28
35
|
- close
|
29
|
-
date:
|
30
|
-
- Wed, 26 Mar 2014 03:26:23 GMT
|
31
|
-
cache-control:
|
32
|
-
- private, max-age=0
|
33
|
-
content-length:
|
34
|
-
- "411"
|
35
36
|
x-powered-by:
|
36
37
|
- ASP.NET
|
37
|
-
content-type:
|
38
|
-
- text/xml; charset=utf-8
|
39
38
|
body:
|
40
39
|
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ChangeAccountRequestResponse xmlns="#Bonsai"><ChangeAccountRequestResult>-1</ChangeAccountRequestResult><ResultCode>-999</ResultCode></ChangeAccountRequestResponse></soap:Body></soap:Envelope>
|
41
40
|
http_version: "1.1"
|
42
|
-
recorded_at:
|
41
|
+
recorded_at: Fri, 28 Mar 2014 00:22:39 GMT
|
42
|
+
recorded_with: VCR 2.8.0
|
@@ -4,14 +4,14 @@ http_interactions:
|
|
4
4
|
method: post
|
5
5
|
uri: http://bonsai.dev.glbt1.gdg/bonsai/bonsaimanager/service.asmx
|
6
6
|
body:
|
7
|
-
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
|
7
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:tns="#Bonsai" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:GetAccountXml><tns:IDType>ORION</tns:IDType><tns:PrivateLabelID>1</tns:PrivateLabelID><tns:ResourceType>outright</tns:ResourceType><tns:TreeID>87563</tns:TreeID><tns:ResourceID>10e16f14-b606-11e3-a45e-0050569575d8</tns:ResourceID></tns:GetAccountXml></env:Body></env:Envelope>
|
8
8
|
headers:
|
9
|
-
accept:
|
10
|
-
- "*/*"
|
11
|
-
content-length:
|
12
|
-
- "516"
|
13
9
|
content-type:
|
14
10
|
- text/xml;charset=UTF-8
|
11
|
+
content-length:
|
12
|
+
- "516"
|
13
|
+
accept:
|
14
|
+
- "*/*"
|
15
15
|
soapaction:
|
16
16
|
- "\"#Bonsai/GetAccountXml\""
|
17
17
|
response:
|
@@ -19,24 +19,24 @@ http_interactions:
|
|
19
19
|
code: 200
|
20
20
|
message: OK
|
21
21
|
headers:
|
22
|
-
|
23
|
-
-
|
22
|
+
content-type:
|
23
|
+
- text/xml; charset=utf-8
|
24
|
+
content-length:
|
25
|
+
- "338"
|
24
26
|
x-aspnet-version:
|
25
27
|
- 4.0.30319
|
26
28
|
cache-control:
|
27
29
|
- private, max-age=0
|
28
|
-
content-length:
|
29
|
-
- "338"
|
30
30
|
server:
|
31
31
|
- Microsoft-IIS/7.0
|
32
32
|
date:
|
33
|
-
-
|
34
|
-
|
35
|
-
-
|
33
|
+
- Fri, 28 Mar 2014 00:22:32 GMT
|
34
|
+
connection:
|
35
|
+
- close
|
36
36
|
x-powered-by:
|
37
37
|
- ASP.NET
|
38
38
|
body:
|
39
39
|
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse xmlns="#Bonsai"><ResultCode>-999</ResultCode></GetAccountXmlResponse></soap:Body></soap:Envelope>
|
40
40
|
http_version: "1.1"
|
41
|
-
recorded_at:
|
41
|
+
recorded_at: Fri, 28 Mar 2014 00:22:35 GMT
|
42
42
|
recorded_with: VCR 2.8.0
|
@@ -4,14 +4,14 @@ http_interactions:
|
|
4
4
|
method: post
|
5
5
|
uri: http://bonsai.dev.glbt1.gdg/bonsai/bonsaimanager/service.asmx
|
6
6
|
body:
|
7
|
-
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
|
7
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:tns="#Bonsai" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:GetAccountXml><tns:IDType>ORION</tns:IDType><tns:PrivateLabelID>1</tns:PrivateLabelID><tns:ResourceType>outright</tns:ResourceType><tns:TreeID>1735</tns:TreeID><tns:ResourceID>10e16f14-b606-11e3-a45e-0050569575d8</tns:ResourceID></tns:GetAccountXml></env:Body></env:Envelope>
|
8
8
|
headers:
|
9
|
-
accept:
|
10
|
-
- "*/*"
|
11
|
-
content-length:
|
12
|
-
- "515"
|
13
9
|
content-type:
|
14
10
|
- text/xml;charset=UTF-8
|
11
|
+
content-length:
|
12
|
+
- "515"
|
13
|
+
accept:
|
14
|
+
- "*/*"
|
15
15
|
soapaction:
|
16
16
|
- "\"#Bonsai/GetAccountXml\""
|
17
17
|
response:
|
@@ -19,24 +19,24 @@ http_interactions:
|
|
19
19
|
code: 200
|
20
20
|
message: OK
|
21
21
|
headers:
|
22
|
-
|
23
|
-
-
|
22
|
+
content-type:
|
23
|
+
- text/xml; charset=utf-8
|
24
|
+
content-length:
|
25
|
+
- "1626"
|
24
26
|
x-aspnet-version:
|
25
27
|
- 4.0.30319
|
26
28
|
cache-control:
|
27
29
|
- private, max-age=0
|
28
|
-
content-length:
|
29
|
-
- "1626"
|
30
30
|
server:
|
31
31
|
- Microsoft-IIS/7.0
|
32
32
|
date:
|
33
|
-
-
|
34
|
-
|
35
|
-
-
|
33
|
+
- Fri, 28 Mar 2014 00:22:33 GMT
|
34
|
+
connection:
|
35
|
+
- close
|
36
36
|
x-powered-by:
|
37
37
|
- ASP.NET
|
38
38
|
body:
|
39
|
-
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse xmlns="#Bonsai"><ResultCode>0</ResultCode><AccountXml><Bonsai><Bonsai PrivateLabelID="1" ResourceID="
|
39
|
+
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse xmlns="#Bonsai"><ResultCode>0</ResultCode><AccountXml><Bonsai><Bonsai PrivateLabelID="1" ResourceID="10e16f14-b606-11e3-a45e-0050569575d8" IsPastDue="False" IsFree="False" CurrentTreeID="1735" CurrentUnifiedProductID="2701" xmlns=""><Tree TreeID="1735" NodeID="1735" UnifiedProductID="2701" IsFree="False"><Transition NodeName="Outright - Monthly Plus" UnifiedProductID="2697" TreeID="1734" IsFree="False" NodeID="1734" /><Transition NodeName="Outright - Annual Plus 1 year" UnifiedProductID="2699" TreeID="1736" IsFree="False" NodeID="1736" /><Transition NodeName="Outright - Annual Plus 2 years" UnifiedProductID="2703" TreeID="1737" IsFree="False" NodeID="1737" /><Transition NodeName="Outright - Annual Plus 3 years" UnifiedProductID="2705" TreeID="1738" IsFree="False" NodeID="1738" /><Transition NodeName="Outright - Annual Plus 4 years" UnifiedProductID="2707" TreeID="1739" IsFree="False" NodeID="1739" /><Transition NodeName="Outright - Annual Plus 5 years" UnifiedProductID="2709" TreeID="1740" IsFree="False" NodeID="1740" /><FilteredTransitions /><Prepaid><Item Name="Prepaid Previous Tax - Outright" CategoryName="Prepaid Previous Tax" CategoryID="49" MinQty="1" MaxQty="-1" MinDuration="1" MaxDuration="-1" IsQuantityBased="False" Increment="1" UnifiedProductID="2711" /></Prepaid></Tree></Bonsai></Bonsai></AccountXml></GetAccountXmlResponse></soap:Body></soap:Envelope>
|
40
40
|
http_version: "1.1"
|
41
|
-
recorded_at:
|
41
|
+
recorded_at: Fri, 28 Mar 2014 00:22:36 GMT
|
42
42
|
recorded_with: VCR 2.8.0
|
@@ -4,14 +4,14 @@ http_interactions:
|
|
4
4
|
method: post
|
5
5
|
uri: http://bonsai.dev.glbt1.gdg/bonsai/bonsaimanager/service.asmx
|
6
6
|
body:
|
7
|
-
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
|
7
|
+
string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:tns="#Bonsai" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Body><tns:GetAccountXml><tns:IDType>ORION</tns:IDType><tns:PrivateLabelID>1</tns:PrivateLabelID><tns:ResourceType>outright</tns:ResourceType><tns:TreeID>1734</tns:TreeID><tns:ResourceID>10e16f14-b606-11e3-a45e-0050569575d8</tns:ResourceID></tns:GetAccountXml></env:Body></env:Envelope>
|
8
8
|
headers:
|
9
|
-
accept:
|
10
|
-
- "*/*"
|
11
|
-
content-length:
|
12
|
-
- "515"
|
13
9
|
content-type:
|
14
10
|
- text/xml;charset=UTF-8
|
11
|
+
content-length:
|
12
|
+
- "515"
|
13
|
+
accept:
|
14
|
+
- "*/*"
|
15
15
|
soapaction:
|
16
16
|
- "\"#Bonsai/GetAccountXml\""
|
17
17
|
response:
|
@@ -19,24 +19,24 @@ http_interactions:
|
|
19
19
|
code: 200
|
20
20
|
message: OK
|
21
21
|
headers:
|
22
|
-
|
23
|
-
-
|
22
|
+
content-type:
|
23
|
+
- text/xml; charset=utf-8
|
24
|
+
content-length:
|
25
|
+
- "768"
|
24
26
|
x-aspnet-version:
|
25
27
|
- 4.0.30319
|
26
28
|
cache-control:
|
27
29
|
- private, max-age=0
|
28
|
-
content-length:
|
29
|
-
- "768"
|
30
30
|
server:
|
31
31
|
- Microsoft-IIS/7.0
|
32
32
|
date:
|
33
|
-
-
|
34
|
-
|
35
|
-
-
|
33
|
+
- Fri, 28 Mar 2014 00:22:33 GMT
|
34
|
+
connection:
|
35
|
+
- close
|
36
36
|
x-powered-by:
|
37
37
|
- ASP.NET
|
38
38
|
body:
|
39
|
-
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse xmlns="#Bonsai"><ResultCode>0</ResultCode><AccountXml><Bonsai><Bonsai PrivateLabelID="1" ResourceID="
|
39
|
+
string: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAccountXmlResponse xmlns="#Bonsai"><ResultCode>0</ResultCode><AccountXml><Bonsai><Bonsai PrivateLabelID="1" ResourceID="10e16f14-b606-11e3-a45e-0050569575d8" IsPastDue="False" IsFree="False" CurrentTreeID="1735" CurrentUnifiedProductID="2701" xmlns=""><Tree TreeID="1734" NodeID="1734" UnifiedProductID="2697" IsFree="False"><Transition NodeName="Outright - Free" UnifiedProductID="2701" TreeID="1735" IsFree="False" NodeID="1735" /><FilteredTransitions /></Tree></Bonsai></Bonsai></AccountXml></GetAccountXmlResponse></soap:Body></soap:Envelope>
|
40
40
|
http_version: "1.1"
|
41
|
-
recorded_at:
|
41
|
+
recorded_at: Fri, 28 Mar 2014 00:22:36 GMT
|
42
42
|
recorded_with: VCR 2.8.0
|
@@ -21,6 +21,8 @@ module RubyEcommClient
|
|
21
21
|
:qa => 'https://bonsaipurchase.test.glbt1.gdg/BonsaiPurchase/Service.asmx'
|
22
22
|
}
|
23
23
|
|
24
|
+
HOST_NAME = `hostname`.chomp
|
25
|
+
|
24
26
|
ID_TYPE = 'ORION'
|
25
27
|
|
26
28
|
WSDL_MANAGER = 'manager.wsdl'
|
@@ -72,30 +74,16 @@ module RubyEcommClient
|
|
72
74
|
transitions.is_a?(Array) ? transitions : [transitions]
|
73
75
|
end
|
74
76
|
|
75
|
-
def
|
77
|
+
def request_change(target_tree_id, client_ip = '127.0.0.1')
|
76
78
|
raise ArgumentError.new('target_tree_id must be specified') if blank?(target_tree_id)
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
'ResourceType' => @resource_type,
|
81
|
-
'IDType' => ID_TYPE,
|
82
|
-
'AccountChangeXml' => "<ClientChange TreeID='#{target_tree_id}' ShopperID='#{@shopper_id}'/>",
|
83
|
-
'RenewalPFID' => 0,
|
84
|
-
'RenewalPeriods' => 0,
|
85
|
-
'ItemRequestXml' => '<itemRequest/>'
|
86
|
-
})
|
87
|
-
response = convert_response(result.body[:change_account_request_response])
|
88
|
-
if response[:result_code] == 0
|
89
|
-
response[:change_account_request_result]
|
80
|
+
if express_checkout?
|
81
|
+
request_change_via_express(target_tree_id, client_ip)
|
90
82
|
else
|
91
|
-
|
83
|
+
request_change_via_manager(target_tree_id)
|
92
84
|
end
|
93
85
|
end
|
94
86
|
|
95
|
-
def downgrade(target_tree_id = 0)
|
96
|
-
upgrade(target_tree_id)
|
97
|
-
end
|
98
|
-
|
99
87
|
private
|
100
88
|
|
101
89
|
def blank?(value)
|
@@ -111,6 +99,8 @@ module RubyEcommClient
|
|
111
99
|
globals.log false
|
112
100
|
globals.logger Rails.logger if defined?(Rails)
|
113
101
|
globals.namespace '#Bonsai'
|
102
|
+
globals.open_timeout 15
|
103
|
+
globals.read_timeout 15
|
114
104
|
end
|
115
105
|
|
116
106
|
def client_manager
|
@@ -139,9 +129,59 @@ module RubyEcommClient
|
|
139
129
|
globals.wsdl "#{wsdl_path}#{WSDL_PURCHASE}"
|
140
130
|
globals.endpoint ENDPOINTS_PURCHASE[Client.environment]
|
141
131
|
|
142
|
-
globals.ssl_verify_mode
|
143
|
-
|
144
|
-
globals.
|
132
|
+
globals.ssl_verify_mode :none
|
133
|
+
ssl_cert_file = "config/environments/#{Client.environment}/client.crt"
|
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
|
138
|
+
end
|
139
|
+
|
140
|
+
def request_change_via_express(target_tree_id, client_ip = '127.0.0.1')
|
141
|
+
raise ArgumentError.new('target_tree_id must be specified') if blank?(target_tree_id)
|
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
|
163
|
+
end
|
164
|
+
|
165
|
+
def request_change_via_manager(target_tree_id)
|
166
|
+
raise ArgumentError.new('target_tree_id must be specified') if blank?(target_tree_id)
|
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])
|
145
185
|
end
|
146
186
|
end
|
147
187
|
end
|
@@ -2,12 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe RubyEcommClient::Client do
|
4
4
|
before do
|
5
|
-
|
6
|
-
|
5
|
+
use_test = [:qa, :production].include?(RubyEcommClient::Client.environment)
|
6
|
+
|
7
|
+
@shopper_id = use_test ? '255528' : '922411'
|
8
|
+
@low_tree_id = '1734'
|
9
|
+
@downgrade_tree_id = '1736'
|
7
10
|
@current_tree_id = '1735'
|
8
|
-
@upgrade_tree_id = '
|
11
|
+
@upgrade_tree_id = '1737'
|
9
12
|
@resource_type = 'outright'
|
10
|
-
@resource_id = 'e1dd6ab9-b072-11e3-9aad-005056953ce3'
|
13
|
+
@resource_id = use_test ? 'e1dd6ab9-b072-11e3-9aad-005056953ce3' : '10e16f14-b606-11e3-a45e-0050569575d8'
|
11
14
|
|
12
15
|
@client = RubyEcommClient::Client.new(@shopper_id, @resource_type, @resource_id)
|
13
16
|
end
|
@@ -142,7 +145,7 @@ describe RubyEcommClient::Client do
|
|
142
145
|
context '#transitions for one' do
|
143
146
|
before do
|
144
147
|
VCR.use_cassette('transitions/one') do
|
145
|
-
@transitions = @client.transitions(@
|
148
|
+
@transitions = @client.transitions(@low_tree_id)
|
146
149
|
end
|
147
150
|
end
|
148
151
|
|
@@ -203,95 +206,213 @@ describe RubyEcommClient::Client do
|
|
203
206
|
end
|
204
207
|
end
|
205
208
|
|
206
|
-
context '#
|
207
|
-
|
208
|
-
|
209
|
-
@
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
it 'require target_tree_id non-nil' do
|
214
|
-
expect { @client.upgrade(nil) }.to raise_error(ArgumentError)
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'require target_tree_id non-blank' do
|
218
|
-
expect { @client.upgrade('') }.to raise_error(ArgumentError)
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'raise RubyEcommError for unknown resource_type' do
|
222
|
-
VCR.use_cassette('upgrade/unknown/resource_type') do
|
223
|
-
@client.resource_type = 'flugel'
|
224
|
-
expect { @client.upgrade(@upgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-100) }
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'raise RubyEcommError for unknown resource_id' do
|
229
|
-
VCR.use_cassette('upgrade/unknown/resource_id') do
|
230
|
-
@client.resource_id = 'unknown'
|
231
|
-
expect { @client.upgrade(@upgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-304) }
|
232
|
-
end
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'raise RubyEcommError for unknown target_tree_id' do
|
236
|
-
VCR.use_cassette('upgrade/unknown/target_tree_id') do
|
237
|
-
expect { @client.upgrade(73223) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-999) }
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
it "return no-op request_result for transition to same" do
|
242
|
-
VCR.use_cassette('upgrade/noop') do
|
243
|
-
@client.upgrade(@current_tree_id).should eq(1)
|
209
|
+
context '#request_change' do
|
210
|
+
context 'via express_checkout' do
|
211
|
+
before do
|
212
|
+
@client.stub(:express_checkout?).and_return(true)
|
244
213
|
end
|
245
|
-
end
|
246
|
-
|
247
|
-
it "return success request_result for valid transition" do
|
248
|
-
@result.should eq(2)
|
249
|
-
end
|
250
|
-
end
|
251
214
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
215
|
+
context 'upgrade' do
|
216
|
+
before do
|
217
|
+
VCR.use_cassette('request_change/express/upgrade/default') do
|
218
|
+
@result = @client.request_change(@upgrade_tree_id)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'require target_tree_id non-nil' do
|
223
|
+
expect { @client.request_change(nil) }.to raise_error(ArgumentError)
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'require target_tree_id non-blank' do
|
227
|
+
expect { @client.request_change('') }.to raise_error(ArgumentError)
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
231
|
+
VCR.use_cassette('request_change/express/upgrade/unknown/resource_type') do
|
232
|
+
@client.resource_type = 'flugel'
|
233
|
+
expect { @client.request_change(@upgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-100) }
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
238
|
+
VCR.use_cassette('request_change/express/upgrade/unknown/resource_id') do
|
239
|
+
@client.resource_id = 'unknown'
|
240
|
+
expect { @client.request_change(@upgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-304) }
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'raise RubyEcommError for unknown target_tree_id' do
|
245
|
+
VCR.use_cassette('request_change/express/upgrade/unknown/target_tree_id') do
|
246
|
+
expect { @client.request_change(73223) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-999) }
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
it "return no-op request_result for transition to same" do
|
251
|
+
VCR.use_cassette('request_change/express/upgrade/noop') do
|
252
|
+
result = @client.request_change(@current_tree_id)
|
253
|
+
result[:request_result].should eq(1)
|
254
|
+
result[:used_express_checkout].should eq(true)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
it "return success request_result for valid transition" do
|
259
|
+
@result[:request_result].should eq(0)
|
260
|
+
@result[:used_express_checkout].should eq(true)
|
261
|
+
end
|
256
262
|
end
|
257
|
-
end
|
258
|
-
|
259
|
-
it 'require target_tree_id non-nil' do
|
260
|
-
expect { @client.downgrade(nil) }.to raise_error(ArgumentError)
|
261
|
-
end
|
262
263
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
264
|
+
context 'downgrade' do
|
265
|
+
before do
|
266
|
+
VCR.use_cassette('request_change/express/downgrade/default') do
|
267
|
+
@result = @client.request_change(@downgrade_tree_id)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'require target_tree_id non-nil' do
|
272
|
+
expect { @client.request_change(nil) }.to raise_error(ArgumentError)
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'require target_tree_id non-blank' do
|
276
|
+
expect { @client.request_change('') }.to raise_error(ArgumentError)
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
280
|
+
VCR.use_cassette('request_change/express/downgrade/unknown/resource_type') do
|
281
|
+
@client.resource_type = 'flugel'
|
282
|
+
expect { @client.request_change(@downgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-100) }
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
287
|
+
VCR.use_cassette('request_change/express/downgrade/unknown/resource_id') do
|
288
|
+
@client.resource_id = 'unknown'
|
289
|
+
expect { @client.request_change(@downgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-304) }
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'raise RubyEcommError for unknown target_tree_id' do
|
294
|
+
VCR.use_cassette('request_change/express/downgrade/unknown/target_tree_id') do
|
295
|
+
expect { @client.request_change(73541) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-999) }
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
it "return no-op request_result for transition to same" do
|
300
|
+
VCR.use_cassette('request_change/express/downgrade/noop') do
|
301
|
+
result = @client.request_change(@current_tree_id)
|
302
|
+
result[:request_result].should eq(1)
|
303
|
+
result[:used_express_checkout].should eq(true)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
it "return success request_result for valid transition" do
|
308
|
+
@result[:request_result].should eq(0)
|
309
|
+
@result[:used_express_checkout].should eq(true)
|
310
|
+
end
|
271
311
|
end
|
272
312
|
end
|
273
313
|
|
274
|
-
|
275
|
-
|
276
|
-
@client.
|
277
|
-
expect { @client.downgrade(@downgrade_tree_id) }.to raise_error(RubyEcommError){|e| e.result_code.should eq(-304) }
|
314
|
+
context 'via manager' do
|
315
|
+
before do
|
316
|
+
@client.stub(:express_checkout?).and_return(false)
|
278
317
|
end
|
279
|
-
end
|
280
318
|
|
281
|
-
|
282
|
-
|
283
|
-
|
319
|
+
context 'upgrade' do
|
320
|
+
before do
|
321
|
+
VCR.use_cassette('request_change/manager/upgrade/default') do
|
322
|
+
@result = @client.request_change(@upgrade_tree_id)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'require target_tree_id non-nil' do
|
327
|
+
expect { @client.request_change(nil) }.to raise_error(ArgumentError)
|
328
|
+
end
|
329
|
+
|
330
|
+
it 'require target_tree_id non-blank' do
|
331
|
+
expect { @client.request_change('') }.to raise_error(ArgumentError)
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
335
|
+
VCR.use_cassette('request_change/manager/upgrade/unknown/resource_type') do
|
336
|
+
@client.resource_type = 'flugel'
|
337
|
+
expect { @client.request_change(@upgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-100) }
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
342
|
+
VCR.use_cassette('request_change/manager/upgrade/unknown/resource_id') do
|
343
|
+
@client.resource_id = 'unknown'
|
344
|
+
expect { @client.request_change(@upgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-304) }
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'raise RubyEcommError for unknown target_tree_id' do
|
349
|
+
VCR.use_cassette('request_change/manager/upgrade/unknown/target_tree_id') do
|
350
|
+
expect { @client.request_change(73223) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-999) }
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
it "return no-op request_result for transition to same" do
|
355
|
+
VCR.use_cassette('request_change/manager/upgrade/noop') do
|
356
|
+
result = @client.request_change(@current_tree_id)
|
357
|
+
result[:request_result].should eq(1)
|
358
|
+
result[:used_express_checkout].should eq(false)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
it "return success request_result for valid transition" do
|
363
|
+
@result[:request_result].should eq(2)
|
364
|
+
@result[:used_express_checkout].should eq(false)
|
365
|
+
end
|
284
366
|
end
|
285
|
-
end
|
286
367
|
|
287
|
-
|
288
|
-
|
289
|
-
|
368
|
+
context 'downgrade' do
|
369
|
+
before do
|
370
|
+
VCR.use_cassette('request_change/manager/downgrade/default') do
|
371
|
+
@result = @client.request_change(@downgrade_tree_id)
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
it 'require target_tree_id non-nil' do
|
376
|
+
expect { @client.request_change(nil) }.to raise_error(ArgumentError)
|
377
|
+
end
|
378
|
+
|
379
|
+
it 'require target_tree_id non-blank' do
|
380
|
+
expect { @client.request_change('') }.to raise_error(ArgumentError)
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'raise RubyEcommError for unknown resource_type' do
|
384
|
+
VCR.use_cassette('request_change/manager/downgrade/unknown/resource_type') do
|
385
|
+
@client.resource_type = 'flugel'
|
386
|
+
expect { @client.request_change(@downgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-100) }
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'raise RubyEcommError for unknown resource_id' do
|
391
|
+
VCR.use_cassette('request_change/manager/downgrade/unknown/resource_id') do
|
392
|
+
@client.resource_id = 'unknown'
|
393
|
+
expect { @client.request_change(@downgrade_tree_id) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-304) }
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'raise RubyEcommError for unknown target_tree_id' do
|
398
|
+
VCR.use_cassette('request_change/manager/downgrade/unknown/target_tree_id') do
|
399
|
+
expect { @client.request_change(73541) }.to raise_error(RubyEcommError) { |e| e.result_code.should eq(-999) }
|
400
|
+
end
|
401
|
+
end
|
402
|
+
|
403
|
+
it "return no-op request_result for transition to same" do
|
404
|
+
VCR.use_cassette('request_change/manager/downgrade/noop') do
|
405
|
+
result = @client.request_change(@current_tree_id)
|
406
|
+
result[:request_result].should eq(1)
|
407
|
+
result[:used_express_checkout].should eq(false)
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
it "return success request_result for valid transition" do
|
412
|
+
@result[:request_result].should eq(2)
|
413
|
+
@result[:used_express_checkout].should eq(false)
|
414
|
+
end
|
290
415
|
end
|
291
416
|
end
|
292
|
-
|
293
|
-
it "return success request_result for valid transition" do
|
294
|
-
@result.should eq(2)
|
295
|
-
end
|
296
417
|
end
|
297
418
|
end
|