ruby_omx 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby_omx/orders.rb +5 -1
- data/lib/ruby_omx/response/order_info_request.rb +2 -2
- data/lib/ruby_omx/version.rb +1 -1
- data/test/orders_test.rb +26 -3
- metadata +1 -1
data/lib/ruby_omx/orders.rb
CHANGED
@@ -19,7 +19,11 @@ module RubyOmx
|
|
19
19
|
# Order Information
|
20
20
|
|
21
21
|
def build_info_request(params={})
|
22
|
-
|
22
|
+
if params['version'] == '2.00'
|
23
|
+
OrderInformationRequest.new(params.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token, :server=>RubyOmx::ALT_HOST + "?UDIAuthToken=#{@udi_auth_token}"}))
|
24
|
+
else
|
25
|
+
OrderInformationRequest.new(params.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token}))
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def send_info_request(params={})
|
@@ -8,14 +8,14 @@ module RubyOmx
|
|
8
8
|
udi_auth_token = a.delete(:udi_auth_token)
|
9
9
|
|
10
10
|
raise MissingOrderOptions if a[:order_number].nil? && (a[:store_code].nil? || a[:order_id].nil?)
|
11
|
+
self.version = a[:version] ||= '1.00'
|
11
12
|
super
|
12
|
-
self.version = a[:version] ||= '2.00'
|
13
13
|
|
14
14
|
self.udi_parameters = []
|
15
15
|
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token})
|
16
16
|
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id})
|
17
17
|
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'OrderNumber', :value=>a[:order_number]}) if a[:order_number]
|
18
|
-
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'
|
18
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'OrderID', :value=>a[:order_id]}) if a[:order_id]
|
19
19
|
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'StoreCode', :value=>a[:store_code]}) if a[:store_code]
|
20
20
|
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'level', :value=>a[:level] ||=2 })
|
21
21
|
end
|
data/lib/ruby_omx/version.rb
CHANGED
data/test/orders_test.rb
CHANGED
@@ -183,10 +183,33 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
183
183
|
assert_equal 'OMX-ofyccytnacrtnedlldmyed', response.OMX
|
184
184
|
end
|
185
185
|
|
186
|
-
def
|
187
|
-
@connection.stubs(:post).returns(xml_for('OrderInformationResponse(
|
186
|
+
def test_send_info_request1
|
187
|
+
@connection.stubs(:post).returns(xml_for('OrderInformationResponse(1.00)',200))
|
188
188
|
response = @connection.send_info_request({ :order_number => '16651' })
|
189
189
|
assert_kind_of OrderInformationResponse, response
|
190
|
+
assert !response.accessors.include?("code")
|
191
|
+
|
192
|
+
assert_equal DateTime.parse('2006-02-09 14:47:00'), response.ship_date
|
193
|
+
assert_equal "", response.tracking_number
|
194
|
+
assert_equal '16651', response.order_header.order_number
|
195
|
+
assert_equal DateTime.parse('2005-06-20 14:25:00'), response.order_header.order_date
|
196
|
+
assert_equal 1, response.line_items.length
|
197
|
+
assert_equal '16651-1', response.line_items[0].shipment_number
|
198
|
+
assert_equal 6.52, response.line_items[0].line_cogs
|
199
|
+
assert_equal 6.52, response.line_items[0].unit_cogs
|
200
|
+
assert_equal '01-113', response.line_items[0].supplier_item_code
|
201
|
+
assert_equal '01-113', response.line_items[0].item_code
|
202
|
+
assert_instance_of OrderInfoLineStatus, response.line_items[0].line_status
|
203
|
+
assert_equal "OK", response.line_items[0].line_status.text
|
204
|
+
assert_equal 40, response.line_items[0].line_status.value
|
205
|
+
assert_equal '2/9/2006 2:47:00 PM', response.line_items[0].line_status.date
|
206
|
+
assert_kind_of Hash, response.as_hash
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_send_info_request2
|
210
|
+
@connection.stubs(:post).returns(xml_for('OrderInformationResponse(2.00)',200))
|
211
|
+
response = @connection.send_info_request({ :order_number => '24603', :version=>'2.00' })
|
212
|
+
assert_kind_of OrderInformationResponse, response
|
190
213
|
|
191
214
|
assert_nil response.ship_date
|
192
215
|
assert_equal "", response.tracking_number
|
@@ -213,7 +236,7 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
213
236
|
assert_equal '5/31/2010 5:36:00 AM', response.line_items[0].line_status.date
|
214
237
|
assert_kind_of Hash, response.as_hash
|
215
238
|
|
216
|
-
response = @connection.send_info_request({ :order_id=> 'AZ-43253-234', :store_code=>'XX01' })
|
239
|
+
response = @connection.send_info_request({ :order_id=> 'AZ-43253-234', :store_code=>'XX01', :version=>'2.00' })
|
217
240
|
assert_kind_of OrderInformationResponse, response
|
218
241
|
end
|
219
242
|
|