ruby_omx 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby_omx/base.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module RubyOmx
2
2
  DEFAULT_HOST = 'https://api.omx.ordermotion.com/hdde/xml/udi.asp'
3
-
3
+ ALT_HOST = 'https://api.omx.ordermotion.com/OM2/udi.ashx'
4
+
4
5
  class Base
5
6
  attr_accessor :connection
6
7
 
@@ -6,20 +6,21 @@ module RubyOmx
6
6
  return super unless a.present? # bail if no array of options has been given
7
7
  http_biz_id = a.delete(:http_biz_id)
8
8
  udi_auth_token = a.delete(:udi_auth_token)
9
- #udi_auth_token = a.delete(:udi_auth_token)
10
-
11
- required_fields = [:order_number]
12
- raise MissingOrderOptions if required_fields.any? { |option| a[option].nil? }
9
+
10
+ raise MissingOrderOptions if a[:order_number].nil? && (a[:store_code].nil? || a[:order_id].nil?)
13
11
  super
14
- self.version = a[:version] ||= '1.00'
12
+ self.version = a[:version] ||= '2.00'
15
13
 
16
- self.udi_parameters = [ RubyOmx::UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token}),
17
- RubyOmx::UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id}),
18
- RubyOmx::UDIParameter.new({:key=>'OrderNumber', :value=>a[:order_number]}),
19
- RubyOmx::UDIParameter.new({:key=>'level', :value=>a[:level] ||=0 })]
14
+ self.udi_parameters = []
15
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token})
16
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id})
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=>'OrderId', :value=>a[:order_id]}) if a[:order_id]
19
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'StoreCode', :value=>a[:store_code]}) if a[:store_code]
20
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'level', :value=>a[:level] ||=2 })
20
21
  end
21
22
 
22
- attr_accessor :order_number, :raw_xml
23
+ attr_accessor :order_number, :order_id, :store_code, :raw_xml
23
24
 
24
25
  xml_name "OrderInformationRequest"
25
26
  xml_accessor :version, :from => '@version'
@@ -6,7 +6,7 @@ module RubyOmx
6
6
  xml_name "LineStatus"
7
7
  #<LineStatus date="2/9/2006 2:47:00 PM" text="OK">40</LineStatus>
8
8
  xml_reader :text, :from => '@text' # C/L means cancelled, OK with a date means processing
9
- xml_reader :date, :from => '@date', :as=>DateTime # cancellation date if cancelled, processing date if processing
9
+ xml_reader :date, :from => "@date" # reverting to string as date is invalid, cancellation date if cancelled, processing date if processing
10
10
  xml_reader :value, :from => :content, :as=>Integer
11
11
  end
12
12
 
@@ -14,6 +14,8 @@ module RubyOmx
14
14
  xml_name "OrderHeader"
15
15
  xml_reader :order_id
16
16
  xml_reader :order_number
17
+ xml_reader :order_status_code, :from => '@statusCode', :in=>'OrderStatus'
18
+ xml_reader :order_status_date, :as=>DateTime
17
19
  xml_reader :order_date, :as=>DateTime
18
20
  end
19
21
 
@@ -47,6 +49,8 @@ module RubyOmx
47
49
 
48
50
  class OrderInformationResponse < Response
49
51
  xml_name "OrderInformationResponse"
52
+ xml_reader :success
53
+
50
54
  xml_reader :order_header, :as=>OrderInfoOrderHeader
51
55
  #xml_reader :shipping_information, :as=>OrderInfoShippingInfo
52
56
  xml_reader :line_items, :as => [OrderInfoLineItem], :in=>'OrderDetail'
@@ -1,3 +1,3 @@
1
1
  module RubyOmx
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/test/orders_test.rb CHANGED
@@ -184,26 +184,37 @@ class OrdersTest < MiniTest::Unit::TestCase
184
184
  end
185
185
 
186
186
  def test_send_info_request
187
- @connection.stubs(:post).returns(xml_for('OrderInformationResponse(1.00)',200))
187
+ @connection.stubs(:post).returns(xml_for('OrderInformationResponse(2.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
190
 
192
- assert_equal DateTime.parse('2006-02-09 14:47:00'), response.ship_date
191
+ assert_nil response.ship_date
193
192
  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
193
+
194
+ assert_nil response.order_header.order_id
195
+ assert_equal '24603', response.order_header.order_number
196
+ assert_equal DateTime.parse('2003-04-01 22:15:00'), response.order_header.order_date
197
+ assert_equal DateTime.parse('2010-05-31 05:36:00'), response.order_header.order_status_date
198
+ assert_equal '4', response.order_header.order_status_code
199
+
200
+
201
+ assert_equal 2, response.line_items.length
202
+ assert_equal '24603-0', response.line_items[0].shipment_number
203
+ assert_equal 10, response.line_items[0].line_cogs
204
+ assert_equal 10, response.line_items[0].unit_cogs
205
+
206
+ assert_equal 'APPLE', response.line_items[0].warehouse_reference
207
+ assert_equal 'APPLE', response.line_items[0].item_code
208
+ assert_equal 'APPLE', response.line_items[0].supplier_item_code
209
+
202
210
  assert_instance_of OrderInfoLineStatus, response.line_items[0].line_status
203
211
  assert_equal "OK", response.line_items[0].line_status.text
204
212
  assert_equal 40, response.line_items[0].line_status.value
205
- assert_equal DateTime.parse('2/9/2006 2:47:00 PM'), response.line_items[0].line_status.date
213
+ assert_equal '5/31/2010 5:36:00 AM', response.line_items[0].line_status.date
206
214
  assert_kind_of Hash, response.as_hash
215
+
216
+ response = @connection.send_info_request({ :order_id=> 'AZ-43253-234', :store_code=>'XX01' })
217
+ assert_kind_of OrderInformationResponse, response
207
218
  end
208
219
 
209
220
  def test_send_smart_report_request
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_omx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: