ruby_omx 0.0.15 → 0.0.16

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.
@@ -10,10 +10,10 @@ module RubyOmx
10
10
 
11
11
  # These values are essential to establishing a connection
12
12
  @udi_auth_token = params['udi_auth_token']
13
- @server = params['server'] || RubyOmx::DEFAULT_HOST + "?UDIAuthToken=#{@udi_auth_token}"
13
+ @server = (params['server'] || RubyOmx::DEFAULT_HOST) + "?UDIAuthToken=#{@udi_auth_token}"
14
14
  @http_biz_id = params['http_biz_id']
15
15
  @path = URI.parse(@server).request_uri
16
-
16
+
17
17
  raise MissingConnectionOptions if [@udi_auth_token, @http_biz_id].any? {|option| option.nil?}
18
18
  @http = connect
19
19
  end
@@ -19,11 +19,7 @@ module RubyOmx
19
19
  # Order Information
20
20
 
21
21
  def build_info_request(params={})
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
22
+ OrderInformationRequest.new(params.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token}))
27
23
  end
28
24
 
29
25
  def send_info_request(params={})
@@ -1,13 +1,4 @@
1
- #<PurchaseOrderUpdateResponse>
2
- # <Success>1</Success>
3
- # <PurchaseOrder PONumber="16651" SupplierID="76"/>
4
- # <PODate>2008-09-21 12:32:27</PODate>
5
- # <TotalAmount>26.50</TotalAmount>
6
- # <Action>New</Action> <!-- "New" if a new PO number was just assigned, "Update" if a PO number was supplied and the PO's header properties were changed, and/or a PO line was added or updated. -->
7
- #</PurchaseOrderUpdateResponse>
8
-
9
1
  #OrderInformationRequest (OIR200) This request type provides the ShippingInformationRequest (SIR) result for the order as a whole.
10
-
11
2
  module RubyOmx
12
3
 
13
4
  class ErrorData < Response
@@ -19,16 +10,13 @@ module RubyOmx
19
10
  xml_accessor :message, :from=>:content
20
11
  end
21
12
 
22
- class PurchaseOrderResponse < Response
23
- xml_name 'PurchaseOrder'
24
- xml_accessor :po_number, :from=>'@PONumber' #<PurchaseOrder PONumber="16651" SupplierID="76">
25
- xml_accessor :supplier_id, :from=>'@SupplierID'
26
- end
27
-
28
13
  class PurchaseOrderUpdateResponse < Response
29
14
  xml_name "PurchaseOrderUpdateResponse"
30
15
  xml_reader :success
31
- xml_accessor :purchase_order, :as => RubyOmx::PurchaseOrderResponse
16
+ #xml_accessor :purchase_order, :as => RubyOmx::PurchaseOrderResponse
17
+ xml_accessor :po_number, :from=>'@PONumber', :in=>'PurchaseOrder' #<PurchaseOrder PONumber="16651" SupplierID="76">
18
+ xml_accessor :supplier_id, :from=>'@SupplierID', :in=>'PurchaseOrder'
19
+
32
20
  xml_accessor :po_date, :from=>'PODate', :as=>DateTime
33
21
  xml_accessor :total_amount, :as=>Float
34
22
  xml_accessor :action
@@ -1,3 +1,3 @@
1
1
  module RubyOmx
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
data/test/orders_test.rb CHANGED
@@ -4,6 +4,10 @@ class OrdersTest < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
6
6
  @connection = RubyOmx::Base.new(@config)
7
+
8
+ # Alternative connection needed for v2 of OMX API (but not for UDOA)
9
+ @config_alt = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test_alt']
10
+ @connection_alt = RubyOmx::Base.new(@config_alt)
7
11
  end
8
12
 
9
13
  def test_orders_request_from_xml
@@ -140,7 +144,6 @@ class OrdersTest < MiniTest::Unit::TestCase
140
144
  { :field_id => '7', :line_number => '2', :value => 'a' }]
141
145
  }
142
146
  request = @connection.build_udoa_request(request_attrs)
143
- puts request.to_xml
144
147
  request2 = RubyOmx::UDOARequest.format(xml_for('UDOARequest_(UDOA200)_request',200))
145
148
  assert_equal request.to_xml.to_s, request2.to_xml.to_s
146
149
  end
@@ -208,8 +211,8 @@ class OrdersTest < MiniTest::Unit::TestCase
208
211
  end
209
212
 
210
213
  def test_send_info_request2
211
- @connection.stubs(:post).returns(xml_for('OrderInformationResponse(2.00)',200))
212
- response = @connection.send_info_request({ :order_number => '24603', :version=>'2.00' })
214
+ @connection_alt.stubs(:post).returns(xml_for('OrderInformationResponse(2.00)',200))
215
+ response = @connection_alt.send_info_request({ :order_number => '24603', :version=>'2.00' })
213
216
  assert_kind_of OrderInformationResponse, response
214
217
 
215
218
  assert_nil response.ship_date
@@ -237,7 +240,7 @@ class OrdersTest < MiniTest::Unit::TestCase
237
240
  assert_equal '5/31/2010 5:36:00 AM', response.line_items[0].line_status.date
238
241
  assert_kind_of Hash, response.as_hash
239
242
 
240
- response = @connection.send_info_request({ :order_id=> 'AZ-43253-234', :store_code=>'XX01', :version=>'2.00' })
243
+ response = @connection_alt.send_info_request({ :order_id=> 'AZ-43253-234', :store_code=>'XX01', :version=>'2.00' })
241
244
  assert_kind_of OrderInformationResponse, response
242
245
  end
243
246
 
@@ -25,6 +25,8 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
25
25
  def test_send_purchase_order_update_request
26
26
  @connection.stubs(:post).returns(xml_for('PurchaseOrderUpdateResponse(1.00)',200))
27
27
  request = PurchaseOrderUpdateRequest.new
28
+
29
+ # TODO why is this necessary
28
30
  l1 = RubyOmx::LineItem.new(:item_code=>'WATCH-1', :quantity=>1, :price=>122.50)
29
31
  l2 = RubyOmx::LineItem.new(:item_code=>'APPLE-12', :quantity=>31, :price=>1.50)
30
32
 
@@ -32,10 +34,8 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
32
34
  :line_items => [l1, l2],
33
35
  :supplier_id => '76'
34
36
  }
35
-
36
-
37
37
  r = @connection.build_purchase_order_update_request(po_data)
38
- puts r.to_xml
38
+ assert_instance_of String, r.to_xml.to_s
39
39
 
40
40
  # Missing Order Options
41
41
  begin
@@ -47,8 +47,8 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
47
47
  assert_kind_of PurchaseOrderUpdateResponse, response
48
48
  assert_equal '1', response.success
49
49
  assert_equal DateTime.parse('2008-09-21 12:32:27'), response.po_date
50
- assert_equal '16651', response.purchase_order.po_number
51
- assert_equal '76', response.purchase_order.supplier_id
50
+ assert_equal '16651', response.po_number
51
+ assert_equal '76', response.supplier_id
52
52
  assert_kind_of Hash, response.as_hash
53
53
 
54
54
  response = @connection.send_purchase_order_update_request(po_data.merge({:raw_xml => true}))
@@ -57,6 +57,6 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
57
57
  # old alias should still work
58
58
  response = @connection.append_po(po_data)
59
59
  assert_kind_of PurchaseOrderUpdateResponse, response
60
- assert_equal '16651', response.purchase_order.po_number
60
+ assert_equal '16651', response.po_number
61
61
  end
62
62
  end
data/test/test_config.yml CHANGED
@@ -1,3 +1,8 @@
1
1
  test:
2
2
  udi_auth_token: 470db4004809083c0048ef983
3
- http_biz_id: KbmCrvnuTESTINGTESTINGYBlggjNYxGqsujuglguAJhXeKBYD
3
+ http_biz_id: KbmCrvnuTESTINGTESTINGYBlggjNYxGqsujuglguAJhXeKBYD
4
+
5
+ test_alt:
6
+ udi_auth_token: 470db4004809083c0048ef983
7
+ http_biz_id: KbmCrvnuTESTINGTESTINGYBlggjNYxGqsujuglguAJhXeKBYD
8
+ server: https://api.omx.ordermotion.com/OM2/udi.ashx
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.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 Z
12
+ date: 2012-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: roxml