active_fulfillment 1.0.3 → 2.0.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.
- data/CHANGELOG +4 -0
- data/Rakefile +3 -30
- data/VERSION +1 -1
- data/active_fulfillment.gemspec +6 -25
- data/lib/active_fulfillment/fulfillment/response.rb +6 -10
- data/lib/active_fulfillment/fulfillment/services/amazon.rb +1 -1
- data/lib/active_fulfillment/fulfillment/services/shipwire.rb +30 -14
- data/lib/active_fulfillment/fulfillment/services/webgistix.rb +3 -1
- data/lib/active_fulfillment/fulfillment/services.rb +1 -0
- data/lib/active_fulfillment.rb +3 -2
- data/test/fixtures.yml +6 -1
- data/test/remote/amazon_test.rb +4 -4
- data/test/remote/shipwire_test.rb +3 -3
- data/test/remote/webgistix_test.rb +2 -2
- data/test/test_helper.rb +6 -17
- data/test/unit/services/amazon_test.rb +2 -2
- data/test/unit/services/shipwire_test.rb +100 -21
- data/test/unit/services/webgistix_test.rb +1 -1
- metadata +97 -75
- data/lib/active_merchant/common/connection.rb +0 -162
- data/lib/active_merchant/common/country.rb +0 -328
- data/lib/active_merchant/common/error.rb +0 -26
- data/lib/active_merchant/common/post_data.rb +0 -24
- data/lib/active_merchant/common/posts_data.rb +0 -61
- data/lib/active_merchant/common/requires_parameters.rb +0 -16
- data/lib/active_merchant/common/utils.rb +0 -18
- data/lib/active_merchant/common/validateable.rb +0 -76
- data/lib/active_merchant/common.rb +0 -14
- data/lib/certs/cacert.pem +0 -7815
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
2
4
|
require 'rake'
|
3
5
|
require 'rake/testtask'
|
4
6
|
require 'rake/rdoctask'
|
5
|
-
require 'rake/gempackagetask'
|
6
|
-
require 'rake/contrib/rubyforgepublisher'
|
7
7
|
|
8
8
|
desc "Default Task"
|
9
9
|
task :default => 'test:units'
|
@@ -34,30 +34,3 @@ Rake::RDocTask.new do |rdoc|
|
|
34
34
|
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
35
35
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
36
36
|
end
|
37
|
-
|
38
|
-
task :install => [:package] do
|
39
|
-
`gem install pkg/#{PKG_FILE_NAME}.gem`
|
40
|
-
end
|
41
|
-
|
42
|
-
begin
|
43
|
-
require 'jeweler'
|
44
|
-
Jeweler::Tasks.new do |gemspec|
|
45
|
-
gemspec.name = 'active_fulfillment'
|
46
|
-
gemspec.summary = "Framework and tools for dealing with shipping, tracking and order fulfillment services."
|
47
|
-
gemspec.email = "cody@shopify.com"
|
48
|
-
gemspec.homepage = "http://github.com/shopify/active_fulfillment"
|
49
|
-
gemspec.authors = ["Cody Fauser", "James MacAulay"]
|
50
|
-
gemspec.add_dependency('activesupport', '>= 2.3.2')
|
51
|
-
gemspec.add_dependency('builder', '>= 2.0.0')
|
52
|
-
end
|
53
|
-
rescue LoadError
|
54
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
55
|
-
end
|
56
|
-
|
57
|
-
desc "Update common files from active_merchant directory"
|
58
|
-
task :update_common do
|
59
|
-
STDERR.puts "Updating common include from ../active_merchant. Please make sure this is up-to-date"
|
60
|
-
system("diff -u lib/active_merchant/common.rb ../active_merchant/lib/active_merchant/common.rb | patch -p0")
|
61
|
-
system("diff -ur lib/active_merchant/common ../active_merchant/lib/active_merchant/common | patch -p0")
|
62
|
-
STDERR.puts "done.."
|
63
|
-
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/active_fulfillment.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{active_fulfillment}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cody Fauser", "James MacAulay"]
|
@@ -25,16 +25,6 @@ Gem::Specification.new do |s|
|
|
25
25
|
"lib/active_fulfillment/fulfillment/services/amazon.rb",
|
26
26
|
"lib/active_fulfillment/fulfillment/services/shipwire.rb",
|
27
27
|
"lib/active_fulfillment/fulfillment/services/webgistix.rb",
|
28
|
-
"lib/active_merchant/common.rb",
|
29
|
-
"lib/active_merchant/common/connection.rb",
|
30
|
-
"lib/active_merchant/common/country.rb",
|
31
|
-
"lib/active_merchant/common/error.rb",
|
32
|
-
"lib/active_merchant/common/post_data.rb",
|
33
|
-
"lib/active_merchant/common/posts_data.rb",
|
34
|
-
"lib/active_merchant/common/requires_parameters.rb",
|
35
|
-
"lib/active_merchant/common/utils.rb",
|
36
|
-
"lib/active_merchant/common/validateable.rb",
|
37
|
-
"lib/certs/cacert.pem",
|
38
28
|
"test/fixtures.yml",
|
39
29
|
"test/fixtures/xml/amazon/inventory_get_response.xml",
|
40
30
|
"test/fixtures/xml/amazon/inventory_list_response.xml",
|
@@ -69,20 +59,11 @@ Gem::Specification.new do |s|
|
|
69
59
|
"test/unit/services/webgistix_test.rb"
|
70
60
|
]
|
71
61
|
|
72
|
-
|
73
|
-
|
74
|
-
|
62
|
+
s.add_dependency('activesupport', '>= 2.3.11')
|
63
|
+
s.add_dependency('builder', '>= 2.0.0')
|
64
|
+
s.add_dependency('active_utils', '>= 1.0.1')
|
75
65
|
|
76
|
-
|
77
|
-
|
78
|
-
s.add_runtime_dependency(%q<builder>, [">= 2.0.0"])
|
79
|
-
else
|
80
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
81
|
-
s.add_dependency(%q<builder>, [">= 2.0.0"])
|
82
|
-
end
|
83
|
-
else
|
84
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.2"])
|
85
|
-
s.add_dependency(%q<builder>, [">= 2.0.0"])
|
86
|
-
end
|
66
|
+
s.add_development_dependency('rake')
|
67
|
+
s.add_development_dependency('mocha')
|
87
68
|
end
|
88
69
|
|
@@ -1,14 +1,10 @@
|
|
1
1
|
module ActiveMerchant
|
2
2
|
module Fulfillment
|
3
|
-
|
4
|
-
class Error < StandardError
|
5
|
-
end
|
6
|
-
|
7
3
|
class Response
|
8
4
|
attr_reader :params
|
9
5
|
attr_reader :message
|
10
6
|
attr_reader :test
|
11
|
-
|
7
|
+
|
12
8
|
def success?
|
13
9
|
@success
|
14
10
|
end
|
@@ -16,17 +12,17 @@ module ActiveMerchant
|
|
16
12
|
def test?
|
17
13
|
@test
|
18
14
|
end
|
19
|
-
|
15
|
+
|
20
16
|
def initialize(success, message, params = {}, options = {})
|
21
17
|
@success, @message, @params = success, message, params.stringify_keys
|
22
|
-
@test = options[:test] || false
|
18
|
+
@test = options[:test] || false
|
23
19
|
end
|
24
|
-
|
20
|
+
|
25
21
|
private
|
26
22
|
def method_missing(method, *args)
|
27
23
|
@params[method.to_s] || super
|
28
24
|
end
|
29
25
|
end
|
30
|
-
|
26
|
+
|
31
27
|
end
|
32
|
-
end
|
28
|
+
end
|
@@ -342,7 +342,7 @@ module ActiveMerchant
|
|
342
342
|
track_node = REXML::XPath.first(document, '//ns1:FulfillmentShipmentPackage/ns1:TrackingNumber')
|
343
343
|
if track_node
|
344
344
|
id_node = REXML::XPath.first(document, '//ns1:MerchantFulfillmentOrderId')
|
345
|
-
response[:tracking_numbers][id_node.text] = track_node.text
|
345
|
+
response[:tracking_numbers][id_node.text] = [track_node.text]
|
346
346
|
end
|
347
347
|
|
348
348
|
response[:response_status] = SUCCESS
|
@@ -27,8 +27,10 @@ module ActiveMerchant
|
|
27
27
|
'UK' => 'United Kingdom'
|
28
28
|
}
|
29
29
|
|
30
|
-
INVALID_LOGIN = /Error with EmailAddress
|
31
|
-
|
30
|
+
INVALID_LOGIN = /(Error with Valid Username\/EmailAddress and Password Required)|(Could not verify Username\/EmailAddress and Password combination)/
|
31
|
+
|
32
|
+
class_attribute :affiliate_id
|
33
|
+
|
32
34
|
# The first is the label, and the last is the code
|
33
35
|
def self.shipping_methods
|
34
36
|
[ ['1 Day Service', '1D'],
|
@@ -72,6 +74,10 @@ module ActiveMerchant
|
|
72
74
|
@options[:include_pending_stock]
|
73
75
|
end
|
74
76
|
|
77
|
+
def include_empty_stock?
|
78
|
+
@options[:include_empty_stock]
|
79
|
+
end
|
80
|
+
|
75
81
|
private
|
76
82
|
def build_fulfillment_request(order_id, shipping_address, line_items, options)
|
77
83
|
xml = Builder::XmlMarkup.new :indent => 2
|
@@ -93,6 +99,7 @@ module ActiveMerchant
|
|
93
99
|
add_credentials(xml)
|
94
100
|
xml.tag! 'Warehouse', WAREHOUSES[options[:warehouse]]
|
95
101
|
xml.tag! 'ProductCode', options[:sku]
|
102
|
+
xml.tag! 'IncludeEmpty' if include_empty_stock?
|
96
103
|
end
|
97
104
|
end
|
98
105
|
|
@@ -113,6 +120,7 @@ module ActiveMerchant
|
|
113
120
|
xml.tag! 'EmailAddress', @options[:login]
|
114
121
|
xml.tag! 'Password', @options[:password]
|
115
122
|
xml.tag! 'Server', test? ? 'Test' : 'Production'
|
123
|
+
xml.tag! 'AffiliateId', affiliate_id if affiliate_id.present?
|
116
124
|
end
|
117
125
|
|
118
126
|
def add_order(xml, order_id, shipping_address, line_items, options)
|
@@ -125,6 +133,9 @@ module ActiveMerchant
|
|
125
133
|
Array(line_items).each_with_index do |line_item, index|
|
126
134
|
add_item(xml, line_item, index)
|
127
135
|
end
|
136
|
+
xml.tag! 'Note' do
|
137
|
+
xml.cdata! options[:note] unless options[:note].blank?
|
138
|
+
end
|
128
139
|
end
|
129
140
|
end
|
130
141
|
|
@@ -134,14 +145,10 @@ module ActiveMerchant
|
|
134
145
|
xml.tag! 'Full', address[:name]
|
135
146
|
end
|
136
147
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
xml.tag! 'Address1', address[:company]
|
142
|
-
xml.tag! 'Address2', address[:address1]
|
143
|
-
xml.tag! 'Address3', address[:address2]
|
144
|
-
end
|
148
|
+
xml.tag! 'Address1', address[:address1]
|
149
|
+
xml.tag! 'Address2', address[:address2]
|
150
|
+
|
151
|
+
xml.tag! 'Company', address[:company]
|
145
152
|
|
146
153
|
xml.tag! 'City', address[:city]
|
147
154
|
xml.tag! 'State', address[:state] unless address[:state].blank?
|
@@ -186,7 +193,7 @@ module ActiveMerchant
|
|
186
193
|
|
187
194
|
document = REXML::Document.new(xml)
|
188
195
|
document.root.elements.each do |node|
|
189
|
-
response[node.name.underscore.to_sym] = node
|
196
|
+
response[node.name.underscore.to_sym] = text_content(node)
|
190
197
|
end
|
191
198
|
|
192
199
|
response[:success] = response[:status] == '0'
|
@@ -207,7 +214,7 @@ module ActiveMerchant
|
|
207
214
|
amount = to_check.sum { |a| node.attributes[a].to_i }
|
208
215
|
response[:stock_levels][node.attributes['code']] = amount
|
209
216
|
else
|
210
|
-
response[node.name.underscore.to_sym] = node
|
217
|
+
response[node.name.underscore.to_sym] = text_content(node)
|
211
218
|
end
|
212
219
|
end
|
213
220
|
|
@@ -225,9 +232,12 @@ module ActiveMerchant
|
|
225
232
|
|
226
233
|
document.root.elements.each do |node|
|
227
234
|
if node.name == 'Order'
|
228
|
-
|
235
|
+
if node.attributes["shipped"] == "YES" && node.elements['TrackingNumber']
|
236
|
+
tracking_number = node.elements['TrackingNumber'].text
|
237
|
+
response[:tracking_numbers][node.attributes['id']] = [tracking_number]
|
238
|
+
end
|
229
239
|
else
|
230
|
-
response[node.name.underscore.to_sym] = node
|
240
|
+
response[node.name.underscore.to_sym] = text_content(node)
|
231
241
|
end
|
232
242
|
end
|
233
243
|
|
@@ -240,6 +250,12 @@ module ActiveMerchant
|
|
240
250
|
return if string.blank?
|
241
251
|
string.gsub("\n", '').squeeze(" ")
|
242
252
|
end
|
253
|
+
|
254
|
+
def text_content(xml_node)
|
255
|
+
text = xml_node.text
|
256
|
+
text = xml_node.cdatas.join if text.blank?
|
257
|
+
text
|
258
|
+
end
|
243
259
|
end
|
244
260
|
end
|
245
261
|
end
|
@@ -28,7 +28,9 @@ module ActiveMerchant
|
|
28
28
|
def self.shipping_methods
|
29
29
|
[
|
30
30
|
["UPS Ground Shipping", "Ground"],
|
31
|
+
["UPS Ground", "Ground"],
|
31
32
|
["UPS Standard Shipping (Canada Only)", "Standard"],
|
33
|
+
["UPS Standard Shipping (CA & MX Only)", "Standard"],
|
32
34
|
["UPS 3-Business Day", "3-Day Select"],
|
33
35
|
["UPS 2-Business Day", "2nd Day Air"],
|
34
36
|
["UPS 2-Business Day AM", "2nd Day Air AM"],
|
@@ -299,7 +301,7 @@ module ActiveMerchant
|
|
299
301
|
params = node.elements.to_a.each_with_object({}) {|elem, hash| hash[elem.name] = elem.text}
|
300
302
|
|
301
303
|
tracking = params['ShipmentTrackingNumber']
|
302
|
-
response[:tracking_numbers][params['InvoiceNumber']] = tracking unless tracking == NOT_SHIPPED
|
304
|
+
response[:tracking_numbers][params['InvoiceNumber']] = [tracking] unless tracking == NOT_SHIPPED
|
303
305
|
end
|
304
306
|
|
305
307
|
response
|
data/lib/active_fulfillment.rb
CHANGED
@@ -30,9 +30,10 @@ rescue LoadError
|
|
30
30
|
require 'active_support'
|
31
31
|
end
|
32
32
|
|
33
|
-
require 'active_support/core_ext/class/
|
33
|
+
require 'active_support/core_ext/class/attribute'
|
34
34
|
require 'active_support/core_ext/class/delegating_attributes'
|
35
35
|
require 'active_support/core_ext/time/calculations'
|
36
|
+
require 'active_support/core_ext/date/calculations'
|
36
37
|
require 'active_support/core_ext/numeric/time'
|
37
38
|
require 'active_support/core_ext/enumerable'
|
38
39
|
begin
|
@@ -51,7 +52,7 @@ end
|
|
51
52
|
require 'cgi'
|
52
53
|
require 'net/https'
|
53
54
|
require 'rexml/document'
|
54
|
-
require '
|
55
|
+
require 'active_utils'
|
55
56
|
|
56
57
|
require 'active_fulfillment/fulfillment/base'
|
57
58
|
require 'active_fulfillment/fulfillment/response'
|
data/test/fixtures.yml
CHANGED
data/test/remote/amazon_test.rb
CHANGED
@@ -33,7 +33,7 @@ class RemoteAmazonTest < Test::Unit::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_successful_order_submission
|
36
|
-
response = @service.fulfill(
|
36
|
+
response = @service.fulfill(ActiveMerchant::Utils.generate_unique_id, @address, @line_items, @options)
|
37
37
|
assert response.success?
|
38
38
|
assert !response.test?
|
39
39
|
end
|
@@ -45,7 +45,7 @@ class RemoteAmazonTest < Test::Unit::TestCase
|
|
45
45
|
}
|
46
46
|
)
|
47
47
|
|
48
|
-
response = @service.fulfill(
|
48
|
+
response = @service.fulfill(ActiveMerchant::Utils.generate_unique_id, @address, @line_items, @options)
|
49
49
|
assert response.success?
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ class RemoteAmazonTest < Test::Unit::TestCase
|
|
54
54
|
:login => 'y',
|
55
55
|
:password => 'p')
|
56
56
|
|
57
|
-
response = service.fulfill(
|
57
|
+
response = service.fulfill(ActiveMerchant::Utils.generate_unique_id, @address, @line_items, @options)
|
58
58
|
assert !response.success?
|
59
59
|
assert_equal "aws:Client.InvalidClientTokenId The AWS Access Key Id you provided does not exist in our records.", response.message
|
60
60
|
end
|
@@ -114,4 +114,4 @@ class RemoteAmazonTest < Test::Unit::TestCase
|
|
114
114
|
assert response.success?
|
115
115
|
end
|
116
116
|
|
117
|
-
end
|
117
|
+
end
|
@@ -45,7 +45,7 @@ class RemoteShipwireTest < Test::Unit::TestCase
|
|
45
45
|
assert !response.success?
|
46
46
|
assert response.test?
|
47
47
|
assert_equal 'Error', response.params['status']
|
48
|
-
assert_equal "Could not verify
|
48
|
+
assert_equal "Could not verify Username/EmailAddress and Password combination", response.message
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_successful_order_submission_to_us
|
@@ -112,7 +112,7 @@ class RemoteShipwireTest < Test::Unit::TestCase
|
|
112
112
|
assert !response.success?
|
113
113
|
assert response.test?
|
114
114
|
assert_equal 'Error', response.params['status']
|
115
|
-
assert_equal "Error with EmailAddress
|
115
|
+
assert_equal "Error with Valid Username/EmailAddress and Password Required. There is an error in XML document.", response.message
|
116
116
|
end
|
117
117
|
|
118
118
|
def test_get_inventory
|
@@ -142,4 +142,4 @@ class RemoteShipwireTest < Test::Unit::TestCase
|
|
142
142
|
)
|
143
143
|
assert !service.valid_credentials?
|
144
144
|
end
|
145
|
-
end
|
145
|
+
end
|
@@ -79,8 +79,8 @@ class RemoteWebgistixTest < Test::Unit::TestCase
|
|
79
79
|
'1254658', 'FAItest123', 'Flat Rate Test Order 4'
|
80
80
|
])
|
81
81
|
assert response.success?
|
82
|
-
assert_equal '4209073191018052136352154', response.tracking_numbers['1254658']
|
83
|
-
assert_equal '9101805213907472080032', response.tracking_numbers['Flat Rate Test Order 4']
|
82
|
+
assert_equal ['4209073191018052136352154'], response.tracking_numbers['1254658']
|
83
|
+
assert_equal ['9101805213907472080032'], response.tracking_numbers['Flat Rate Test Order 4']
|
84
84
|
assert_nil response.tracking_numbers['FAItest123'] # 'Not Shipped'
|
85
85
|
end
|
86
86
|
|
data/test/test_helper.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
3
3
|
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.setup
|
7
|
+
|
4
8
|
require 'test/unit'
|
5
9
|
require 'digest/md5'
|
6
10
|
require 'active_fulfillment'
|
11
|
+
require 'active_utils'
|
7
12
|
|
8
|
-
|
9
|
-
require 'mocha'
|
10
|
-
rescue LoadError
|
11
|
-
require 'rubygems'
|
12
|
-
require 'mocha'
|
13
|
-
end
|
13
|
+
require 'mocha'
|
14
14
|
|
15
15
|
module Test
|
16
16
|
module Unit
|
@@ -19,17 +19,6 @@ module Test
|
|
19
19
|
|
20
20
|
LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
|
21
21
|
DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
|
22
|
-
|
23
|
-
def generate_order_id
|
24
|
-
md5 = Digest::MD5.new
|
25
|
-
now = Time.now
|
26
|
-
md5 << now.to_s
|
27
|
-
md5 << String(now.usec)
|
28
|
-
md5 << String(rand(0))
|
29
|
-
md5 << String($$)
|
30
|
-
md5 << self.class.name
|
31
|
-
md5.hexdigest
|
32
|
-
end
|
33
22
|
|
34
23
|
def all_fixtures
|
35
24
|
@@fixtures ||= load_fixtures
|
@@ -98,7 +98,7 @@ class AmazonTest < Test::Unit::TestCase
|
|
98
98
|
|
99
99
|
response = @service.fetch_tracking_numbers(['TEST-00000001', 'TEST-00000002'])
|
100
100
|
assert response.success?
|
101
|
-
assert_equal
|
101
|
+
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
102
102
|
assert_nil response.tracking_numbers['TEST-00000002']
|
103
103
|
end
|
104
104
|
|
@@ -115,7 +115,7 @@ class AmazonTest < Test::Unit::TestCase
|
|
115
115
|
|
116
116
|
response = @service.fetch_tracking_numbers(['TEST-00000001', '#1337-1', 'TEST-00000002'])
|
117
117
|
assert response.success?
|
118
|
-
assert_equal
|
118
|
+
assert_equal %w{UPS00000001}, response.tracking_numbers['TEST-00000001']
|
119
119
|
end
|
120
120
|
|
121
121
|
def test_fetch_tracking_numbers_aborts_on_error
|
@@ -21,6 +21,7 @@ class ShipwireTest < Test::Unit::TestCase
|
|
21
21
|
:state => 'NC',
|
22
22
|
:country => 'US',
|
23
23
|
:zip => '23456',
|
24
|
+
:company => 'MyCorp',
|
24
25
|
:email => 'buyer@jadedpallet.com'
|
25
26
|
}
|
26
27
|
|
@@ -86,6 +87,16 @@ class ShipwireTest < Test::Unit::TestCase
|
|
86
87
|
assert_equal 921, response.stock_levels['KingMonkey']
|
87
88
|
end
|
88
89
|
|
90
|
+
def test_inventory_request_with_include_empty_tag
|
91
|
+
@shipwire = ShipwireService.new(
|
92
|
+
:login => 'cody@example.com',
|
93
|
+
:password => 'test',
|
94
|
+
:include_empty_stock => true
|
95
|
+
)
|
96
|
+
xml = REXML::Document.new(@shipwire.send(:build_inventory_request, {}))
|
97
|
+
assert REXML::XPath.first(xml, '//IncludeEmpty')
|
98
|
+
end
|
99
|
+
|
89
100
|
def test_no_tracking_numbers_available
|
90
101
|
@shipwire.expects(:ssl_post).returns(successful_empty_tracking_response)
|
91
102
|
response = @shipwire.fetch_tracking_numbers(['1234'])
|
@@ -94,8 +105,8 @@ class ShipwireTest < Test::Unit::TestCase
|
|
94
105
|
end
|
95
106
|
|
96
107
|
def test_successful_tracking
|
97
|
-
expected = { "2986" => "1ZW682E90326614239",
|
98
|
-
"2987" => "1ZW682E90326795080" }
|
108
|
+
expected = { "2986" => ["1ZW682E90326614239"],
|
109
|
+
"2987" => ["1ZW682E90326795080"] }
|
99
110
|
|
100
111
|
@shipwire.expects(:ssl_post).returns(successful_tracking_response)
|
101
112
|
response = @shipwire.fetch_tracking_numbers(["2986", "2987"])
|
@@ -132,6 +143,38 @@ class ShipwireTest < Test::Unit::TestCase
|
|
132
143
|
assert !@shipwire.valid_credentials?
|
133
144
|
end
|
134
145
|
|
146
|
+
def test_affiliate_id
|
147
|
+
ActiveMerchant::Fulfillment::ShipwireService.affiliate_id = 'affiliate_id'
|
148
|
+
|
149
|
+
xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
|
150
|
+
affiliate_id = REXML::XPath.first(xml, "//AffiliateId")
|
151
|
+
assert_equal 'affiliate_id', affiliate_id.text
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_company_name_in_request
|
155
|
+
xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
|
156
|
+
company_node = REXML::XPath.first(xml, "//Company")
|
157
|
+
assert_equal 'MyCorp', company_node.text
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_order_excludes_note_by_default
|
161
|
+
xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
|
162
|
+
note_node = REXML::XPath.first(xml, "//Note").cdatas.first
|
163
|
+
assert_nil note_node
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_order_includes_note_when_present
|
167
|
+
@options[:note] = "A test note"
|
168
|
+
xml = REXML::Document.new(@shipwire.send(:build_fulfillment_request, '123456', @address, @line_items, @options))
|
169
|
+
note_node = REXML::XPath.first(xml, "//Note").cdatas.first
|
170
|
+
assert_equal "A test note", note_node.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_error_response_cdata_parsing
|
174
|
+
@shipwire.expects(:ssl_post).returns(xml_fixture('shipwire/fulfillment_failure_response'))
|
175
|
+
assert !@shipwire.valid_credentials?
|
176
|
+
end
|
177
|
+
|
135
178
|
private
|
136
179
|
def successful_empty_tracking_response
|
137
180
|
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<TrackingUpdateResponse><Status>Test</Status><TotalOrders></TotalOrders><TotalShippedOrders></TotalShippedOrders><TotalProducts></TotalProducts><Bookmark></Bookmark></TrackingUpdateResponse>"
|
@@ -142,9 +185,15 @@ class ShipwireTest < Test::Unit::TestCase
|
|
142
185
|
<?xml version="1.0"?>
|
143
186
|
<TrackingUpdateResponse>
|
144
187
|
<Status>Test</Status>
|
145
|
-
<Order id="2986" shipped="YES"
|
146
|
-
|
147
|
-
|
188
|
+
<Order id="2986" shipped="YES" shipper="UPS GD" handling="1.00" shipping="13.66" total="14.66">
|
189
|
+
<TrackingNumber>1ZW682E90326614239</TrackingNumber>
|
190
|
+
</Order>
|
191
|
+
<Order id="2987" shipped="YES" shipper="UPS GD" handling="1.50" shipping="9.37" total="10.87">
|
192
|
+
<TrackingNumber>1ZW682E90326795080</TrackingNumber>
|
193
|
+
</Order>
|
194
|
+
<Order id="2988" shipped="NO" shipper="UPS GD" handling="" shipping="" total="">
|
195
|
+
<TrackingNumber></TrackingNumber>
|
196
|
+
</Order>
|
148
197
|
<TotalOrders>3</TotalOrders>
|
149
198
|
<TotalShippedOrders>2</TotalShippedOrders>
|
150
199
|
<Bookmark>2006-04-28 20:35:45</Bookmark>
|
@@ -157,21 +206,51 @@ class ShipwireTest < Test::Unit::TestCase
|
|
157
206
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
158
207
|
<TrackingUpdateResponse>
|
159
208
|
<Status>0</Status>
|
160
|
-
<Order id="21" shipped="YES"
|
161
|
-
|
162
|
-
|
163
|
-
<Order id="
|
164
|
-
|
165
|
-
|
166
|
-
<Order id="
|
167
|
-
|
168
|
-
|
169
|
-
<Order id="
|
170
|
-
|
171
|
-
|
172
|
-
<Order id="
|
173
|
-
|
174
|
-
|
209
|
+
<Order id="21" shipped="YES" shipper="5" handling="0.00" shipping="6.58" total="6.58">
|
210
|
+
<TrackingNumber>1Z6296VW0398500001</TrackingNumber>
|
211
|
+
</Order>
|
212
|
+
<Order id="22" shipped="YES" shipper="5" handling="0.00" shipping="8.13" total="8.13">
|
213
|
+
<TrackingNumber>1Z6296VW0390790002</TrackingNumber>
|
214
|
+
</Order>
|
215
|
+
<Order id="23" shipped="YES" shipper="5" handling="0.00" shipping="7.63" total="7.63">
|
216
|
+
<TrackingNumber>1Z6296VW0396490003</TrackingNumber>
|
217
|
+
</Order>
|
218
|
+
<Order id="24" shipped="YES" shipper="5" handling="0.00" shipping="8.97" total="8.97">
|
219
|
+
<TrackingNumber>1Z6296VW0390200004</TrackingNumber>
|
220
|
+
</Order>
|
221
|
+
<Order id="25" shipped="YES" shipper="5" handling="0.00" shipping="8.42" total="8.42">
|
222
|
+
<TrackingNumber>1Z6296VW0393240005</TrackingNumber>
|
223
|
+
</Order>
|
224
|
+
<Order id="26" shipped="YES" shipper="5" handling="0.00" shipping="8.42" total="8.42">
|
225
|
+
<TrackingNumber>1Z6296VW0396400006</TrackingNumber>
|
226
|
+
</Order>
|
227
|
+
<Order id="2581" shipped="YES" shipper="5" handling="0.00" shipping="8.21" total="8.21">
|
228
|
+
<TrackingNumber>1Z6296VW0391160007</TrackingNumber>
|
229
|
+
</Order>
|
230
|
+
<Order id="2576" shipped="YES" shipper="43" handling="0.00" shipping="18.60" total="18.60">
|
231
|
+
<TrackingNumber>CJ3026000018US</TrackingNumber>
|
232
|
+
</Order>
|
233
|
+
<Order id="2593" shipped="YES" shipper="5" handling="0.00" shipping="7.63" total="7.63">
|
234
|
+
<TrackingNumber>1Z6296VW0398660008</TrackingNumber>
|
235
|
+
</Order>
|
236
|
+
<Order id="2598" shipped="YES" shipper="5" handling="0.00" shipping="9.84" total="9.84">
|
237
|
+
<TrackingNumber>1Z6296VW0391610009</TrackingNumber>
|
238
|
+
</Order>
|
239
|
+
<Order id="2610" shipped="YES" shipper="5" handling="0.00" shipping="7.63" total="7.63">
|
240
|
+
<TrackingNumber>1Z6296VW0395650010</TrackingNumber>
|
241
|
+
</Order>
|
242
|
+
<Order id="2611" shipped="YES" shipper="5" handling="0.00" shipping="7.13" total="7.13">
|
243
|
+
<TrackingNumber>1Z6296VW0397050011</TrackingNumber>
|
244
|
+
</Order>
|
245
|
+
<Order id="2613" shipped="YES" shipper="5" handling="0.00" shipping="8.97" total="8.97">
|
246
|
+
<TrackingNumber>1Z6296VW0398970012</TrackingNumber>
|
247
|
+
</Order>
|
248
|
+
<Order id="2616" shipped="NO" shipper="5" handling="0.00" shipping="9.84" total="9.84">
|
249
|
+
<TrackingNumber></TrackingNumber>
|
250
|
+
</Order>
|
251
|
+
<Order id="2631" shipped="NO" shipper="" handling="" shipping="" total="">
|
252
|
+
<TrackingNumber></TrackingNumber>
|
253
|
+
</Order>
|
175
254
|
<TotalOrders>15</TotalOrders>
|
176
255
|
<TotalShippedOrders>13</TotalShippedOrders>
|
177
256
|
<TotalProducts/>
|
@@ -185,7 +264,7 @@ class ShipwireTest < Test::Unit::TestCase
|
|
185
264
|
<<-XML
|
186
265
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
187
266
|
<TrackingUpdateResponse><Status>Error</Status><ErrorMessage>
|
188
|
-
Error with EmailAddress
|
267
|
+
Error with Valid Username/EmailAddress and Password Required.
|
189
268
|
There is an error in XML document.
|
190
269
|
</ErrorMessage></TrackingUpdateResponse>
|
191
270
|
XML
|
@@ -106,7 +106,7 @@ class WebgistixTest < Test::Unit::TestCase
|
|
106
106
|
response = @service.fetch_tracking_numbers(['AB12345', 'XY4567'])
|
107
107
|
assert response.success?
|
108
108
|
assert_equal WebgistixService::SUCCESS_MESSAGE, response.message
|
109
|
-
assert_equal '1Z8E5A380396682872', response.tracking_numbers['AB12345']
|
109
|
+
assert_equal ['1Z8E5A380396682872'], response.tracking_numbers['AB12345']
|
110
110
|
assert_nil response.tracking_numbers['XY4567']
|
111
111
|
end
|
112
112
|
|