ruby_omx 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ 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
-
9
+
10
10
  raise MissingOrderOptions if a[:order_number].nil? && (a[:store_code].nil? || a[:order_id].nil?)
11
11
  self.version = a[:version] ||= '1.00'
12
12
  super
@@ -1,36 +1,23 @@
1
1
  module RubyOmx
2
2
 
3
- class PurchaseOrderLineItem < Response
4
- xml_name 'LineItem'
5
- xml_accessor :line_number, :from=>'@lineNumber'
6
- xml_accessor :item_code #
7
- xml_accessor :quantity # required for new line, optional for update (if omitted, existing value is not changed)
8
- xml_accessor :price # required for new line, optional for update (if omitted, existing value is not changed)
9
- end
10
-
11
- class PurchaseOrder < Response
12
- xml_name 'PurchaseOrder'
13
- xml_accessor :po_number, :from=>'@PONumber' #<PurchaseOrder PONumber="16651" supplierID="76">
14
- xml_accessor :supplier_id, :from=>'@supplierID'
15
- xml_accessor :line_items, :as=>[PurchaseOrderLineItem], :in => 'LineDetail'
16
- end
17
-
18
3
  class PurchaseOrderUpdateRequest < Response
19
4
  def initialize(a=nil)
20
- return super unless a.present? # bail if no array of options has been given
21
- http_biz_id = a.delete(:http_biz_id)
22
- udi_auth_token = a.delete(:udi_auth_token)
23
- #udi_auth_token = a.delete(:udi_auth_token)
5
+ if a.present?
6
+ http_biz_id = a.delete(:http_biz_id)
7
+ udi_auth_token = a.delete(:udi_auth_token)
24
8
 
25
- required_fields = [:purchase_order]
26
- raise MissingPurchaseOrderOptions if required_fields.any? { |option| a[option].nil? }
27
- raise MissingPurchaseOrderOptions if a[:purchase_order][:po_number].nil? && a[:purchase_order][:supplier_id].nil?
28
- raise MissingPurchaseOrderOptions if a[:purchase_order][:line_items].nil?
29
- super
30
- self.version = a[:version] ||= '1.00'
31
- self.udi_parameters = []
32
- self.udi_parameters << UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token})
33
- self.udi_parameters << UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id})
9
+ #required_fields = [:purchase_order]
10
+ #raise MissingPurchaseOrderOptions if required_fields.any? { |option| a[option].nil? }
11
+ #raise MissingPurchaseOrderOptions if a[:purchase_order][:po_number].nil? && a[:purchase_order][:supplier_id].nil?
12
+ #raise MissingPurchaseOrderOptions if a[:purchase_order][:line_items].nil?
13
+ super
14
+ self.version = a[:version] ||= '1.00'
15
+ self.udi_parameters = []
16
+ self.udi_parameters << UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token})
17
+ self.udi_parameters << UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id})
18
+ else
19
+ super
20
+ end
34
21
  end
35
22
 
36
23
  attr_accessor :raw_xml
@@ -38,6 +25,9 @@ module RubyOmx
38
25
  xml_name "PurchaseOrderUpdateRequest"
39
26
  xml_accessor :version, :from => '@version'
40
27
  xml_accessor :udi_parameters, :as => [RubyOmx::UDIParameter], :in => 'UDIParameter'
41
- xml_accessor :purchase_order, :as => PurchaseOrder
28
+
29
+ xml_accessor :po_number, :from=>'@PONumber', :in=>'PurchaseOrder' #<PurchaseOrder PONumber="16651" supplierID="76">
30
+ xml_accessor :supplier_id, :from=>'@supplierID', :in=>'PurchaseOrder'
31
+ xml_accessor :line_items, :as => [RubyOmx::LineItem], :in => 'PurchaseOrder/LineDetail'
42
32
  end
43
33
  end
@@ -10,6 +10,15 @@
10
10
 
11
11
  module RubyOmx
12
12
 
13
+ class ErrorData < Response
14
+ xml_name 'Error'
15
+ xml_accessor :error_id, :from=>'@errorID'
16
+ xml_accessor :error_severity, :from=>'@errorSeverity'
17
+ xml_accessor :error_detail_0, :from=>'@errorDetail0'
18
+ xml_accessor :error_detail_1, :from=>'@errorDetail1'
19
+ xml_accessor :message, :from=>:content
20
+ end
21
+
13
22
  class PurchaseOrderResponse < Response
14
23
  xml_name 'PurchaseOrder'
15
24
  xml_accessor :po_number, :from=>'@PONumber' #<PurchaseOrder PONumber="16651" SupplierID="76">
@@ -22,7 +31,8 @@ module RubyOmx
22
31
  xml_accessor :purchase_order, :as => RubyOmx::PurchaseOrderResponse
23
32
  xml_accessor :po_date, :from=>'PODate', :as=>DateTime
24
33
  xml_accessor :total_amount, :as=>Float
25
- xml_accessor :action
34
+ xml_accessor :action
35
+ xml_accessor :errors, :as=>[ErrorData], :in=>'ErrorData'
26
36
  end
27
37
 
28
38
  end
@@ -7,14 +7,6 @@ module RubyOmx
7
7
  xml_accessor :zip, :from => 'ZIP'
8
8
  xml_accessor :tld, :from => 'TLD'
9
9
  end
10
-
11
- class LineItem < Response
12
- xml_name "LineItem"
13
- xml_accessor :line_number, :from => '@lineNumber'
14
- xml_accessor :item_code
15
- xml_accessor :quantity, :as => Integer
16
- xml_accessor :unit_price, :as => Float
17
- end
18
10
 
19
11
  class CustomField < Response
20
12
  xml_name 'Field'
@@ -31,6 +23,7 @@ module RubyOmx
31
23
 
32
24
  class UDOARequest < Response
33
25
  def initialize(a=nil)
26
+ super if a.nil?
34
27
  if !a.nil?
35
28
  http_biz_id = a.delete(:http_biz_id)
36
29
  udi_auth_token = a.delete(:udi_auth_token)
@@ -94,7 +87,7 @@ module RubyOmx
94
87
  xml_accessor :card_auth_code, :in => 'Payment'
95
88
  xml_accessor :card_transaction_id, :from => 'CardTransactionID', :in => 'Payment'
96
89
 
97
- xml_accessor :line_items, :as => [LineItem], :in => 'OrderDetail'
90
+ xml_accessor :line_items, :as => [RubyOmx::LineItem], :in => 'OrderDetail'
98
91
  xml_accessor :custom_fields, :as => [CustomField], :in => 'CustomFields/Report'
99
92
  xml_accessor :total_amount, :in => 'Check'
100
93
  end
@@ -52,4 +52,13 @@ module RubyOmx
52
52
  xml_accessor :value, :from => :content
53
53
  end
54
54
 
55
+ class LineItem < Response
56
+ xml_name "LineItem"
57
+ xml_accessor :line_number, :from => '@lineNumber'
58
+ xml_accessor :item_code
59
+ xml_accessor :quantity, :as => Integer
60
+ xml_accessor :unit_price, :as => Float
61
+ xml_accessor :price, :as => Float
62
+ end
63
+
55
64
  end
@@ -1,3 +1,3 @@
1
1
  module RubyOmx
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
data/test/orders_test.rb CHANGED
@@ -140,6 +140,7 @@ class OrdersTest < MiniTest::Unit::TestCase
140
140
  { :field_id => '7', :line_number => '2', :value => 'a' }]
141
141
  }
142
142
  request = @connection.build_udoa_request(request_attrs)
143
+ puts request.to_xml
143
144
  request2 = RubyOmx::UDOARequest.format(xml_for('UDOARequest_(UDOA200)_request',200))
144
145
  assert_equal request.to_xml.to_s, request2.to_xml.to_s
145
146
  end
@@ -12,11 +12,11 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
12
12
  def test_request_from_xml
13
13
  request = RubyOmx::PurchaseOrderUpdateRequest.format(xml_for('PurchaseOrderUpdateRequest(1.00)',200))
14
14
  assert_equal '1.00', request.version
15
- assert_equal '16651', request.purchase_order.po_number
16
- assert_equal '76', request.purchase_order.supplier_id
17
- assert_equal 2, request.purchase_order.line_items.length
18
- assert_equal @line1[:item_code], request.purchase_order.line_items[0].item_code
19
- assert_equal @line2[:item_code], request.purchase_order.line_items[1].item_code
15
+ assert_equal '16651', request.po_number
16
+ assert_equal '76', request.supplier_id
17
+ assert_equal 2, request.line_items.length
18
+ assert_equal @line1[:item_code], request.line_items[0].item_code
19
+ assert_equal @line2[:item_code], request.line_items[1].item_code
20
20
 
21
21
  assert_equal 'UDIAuthToken', request.udi_parameters[0].key
22
22
  assert_equal @config['udi_auth_token'], request.udi_parameters[0].value
@@ -25,13 +25,18 @@ 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
- po_data = { :purchase_order => {
29
- :po_number => '16651',
30
- :supplier_id => '76',
31
- :line_items => [@line1, @line2]
32
- }
33
- }
34
-
28
+ l1 = RubyOmx::LineItem.new(:item_code=>'WATCH-1', :quantity=>1, :price=>122.50)
29
+ l2 = RubyOmx::LineItem.new(:item_code=>'APPLE-12', :quantity=>31, :price=>1.50)
30
+
31
+ po_data = { :po_number => '16651',
32
+ :line_items => [l1, l2],
33
+ :supplier_id => '76'
34
+ }
35
+
36
+
37
+ r = @connection.build_purchase_order_update_request(po_data)
38
+ puts r.to_xml
39
+
35
40
  # Missing Order Options
36
41
  begin
37
42
  response = @connection.send_purchase_order_update_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.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: