ruby_omx 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ module RubyOmx
2
2
  module Items
3
3
 
4
4
  # ItemInformationRequest (ITIR100) This request type lists the name, default prices, inventory availability, sub-items, cross-sell items, substitution items, and bundle items for a given item code.
5
+
5
6
  def build_item_info_request(attrs={})
6
7
  ItemInfoRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
7
8
  end
@@ -14,6 +15,8 @@ module RubyOmx
14
15
  end
15
16
  alias_method :get_item_info, :send_item_info_request
16
17
 
18
+ # Customer Item Information Request
19
+
17
20
  def build_custom_item_info_request(attrs={})
18
21
  CustomItemInfoRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
19
22
  end
@@ -26,6 +29,9 @@ module RubyOmx
26
29
  end
27
30
  alias_method :get_custom_item_info, :send_custom_item_info_request
28
31
 
32
+
33
+ # Item Update Request
34
+
29
35
  def build_item_update_request(attrs={})
30
36
  ItemUpdateRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
31
37
  end
@@ -38,5 +44,36 @@ module RubyOmx
38
44
  end
39
45
  alias_method :append_item, :send_item_update_request
40
46
 
47
+
48
+ # Item Price Update Request
49
+
50
+ def build_item_price_update_request(attrs={})
51
+ ItemPriceUpdateRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
52
+ end
53
+
54
+ def send_item_price_update_request(attrs={})
55
+ request = build_item_price_update_request(attrs)
56
+ response = post(request.to_xml.to_s)
57
+ return response if request.raw_xml==true || request.raw_xml==1
58
+ ItemPriceUpdateResponse.format(response)
59
+ end
60
+ alias_method :append_item_price, :send_item_price_update_request
61
+
62
+
63
+ # Supplier Item Update Request
64
+
65
+ def build_supplier_item_update_request(attrs={})
66
+ SupplierItemUpdateRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
67
+ end
68
+
69
+ def send_supplier_item_update_request(attrs={})
70
+ request = build_supplier_item_update_request(attrs)
71
+ response = post(request.to_xml.to_s)
72
+ return response if request.raw_xml==true || request.raw_xml==1
73
+ SupplierItemUpdateResponse.format(response)
74
+ end
75
+ alias_method :append_supplier_item, :send_supplier_item_update_request
76
+
77
+
41
78
  end
42
79
  end
@@ -0,0 +1,33 @@
1
+ module RubyOmx
2
+
3
+ class PricePoint < Node
4
+ xml_name "PricePoint"
5
+ xml_accessor :quantity, :as=>Integer
6
+ xml_accessor :price, :as=>Float
7
+ xml_accessor :shipping_handling, :as=>Float
8
+ xml_accessor :multiplier, :from => '@multiplier'
9
+ end
10
+
11
+ class ItemPriceUpdateRequest < Request
12
+
13
+ def initialize(attrs={})
14
+ return super unless attrs.any?
15
+ required_fields = [:item_code, :keycode, :type] #:item_code, :product_status, :product_name, :product_group, :tax_code, :file_sub_code, :inventory_product_flag, :launch_date
16
+ raise MissingRequestOptions if required_fields.any? { |option| attrs[option].nil? }
17
+ super
18
+ self.version = attrs[:version] ||= '2.00'
19
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'ItemCode', :value=>attrs[:item_code]})
20
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'Keycode', :value=>attrs[:keycode]})
21
+ self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'Type', :value=>attrs[:type]})
22
+ self.price_points = attrs[:price_points].collect { |h| PricePoint.new(h) }
23
+ end
24
+
25
+ attr_accessor :item_code, :keycode, :type
26
+
27
+ xml_name "ItemPriceUpdateRequest"
28
+ xml_accessor :price_type, :from=>'@priceType', :in=>'PricePoints'
29
+ xml_accessor :quantity_type, :from=>'@quantityType', :in=>'PricePoints'
30
+ xml_accessor :price_points, :as=>[PricePoint], :in=>'PricePoints'
31
+ end
32
+
33
+ end
@@ -16,7 +16,10 @@ module RubyOmx
16
16
  xml_accessor :tax_code #<TaxCode>TC4</TaxCode>
17
17
  xml_accessor :inventory_type, :as=>Integer # <InventoryType>3</InventoryType>
18
18
  xml_accessor :drop_ship_file_sub_code, :as=>Integer #<DropShipFileSubCode>31</DropShipFileSubCode>
19
-
19
+ xml_accessor :order_split_flag #<OrderSplitFlag>False</OrderSplitFlag>
20
+ xml_accessor :inventory_manager
21
+ xml_accessor :inventory_warning_ooi, :from=>'InventoryWarningOOI' #<InventoryWarningOOI>False</InventoryWarningOOI>
22
+ xml_accessor :inventory_warning_loi, :from=>'InventoryWarningLOI' #<InventoryWarningLOI>False</InventoryWarningLOI>
20
23
  end
21
24
 
22
25
  class ItemUpdateRequest < Request
@@ -4,7 +4,7 @@ module RubyOmx
4
4
 
5
5
  def initialize(attrs={})
6
6
  return super unless attrs.any?
7
- raise MissingRequestOptions if attrs[:po_number].nil? && attrs[:supplier_id].nil?
7
+ raise MissingRequestOptions if (attrs[:po_number].nil? && attrs[:supplier_id].nil?)
8
8
  super
9
9
  self.version = attrs[:version] ||= '1.00'
10
10
 
@@ -0,0 +1,30 @@
1
+ module RubyOmx
2
+
3
+ class Item < Node
4
+ xml_name "Item"
5
+ xml_accessor :item_code, :from=>'@itemCode'
6
+ xml_accessor :supplier_id, :from=>'@supplierID'
7
+ xml_accessor :supplier_item_code
8
+ xml_accessor :description
9
+ xml_accessor :standard_price, :as=>Float
10
+ xml_accessor :delivery_lead_time_days, :as=>Integer
11
+ xml_accessor :minimum_quantity, :as=>Integer
12
+ xml_accessor :units_per_package, :as=>Integer
13
+ xml_accessor :package_description
14
+ end
15
+
16
+ class SupplierItemUpdateRequest < Request
17
+
18
+ def initialize(attrs={})
19
+ return super unless attrs.any?
20
+ raise MissingRequestOptions if attrs[:items].nil?
21
+ super
22
+ self.version = attrs[:version] ||= '1.00'
23
+ self.items = attrs[:items].collect { |h| Item.new(h) }
24
+ end
25
+
26
+ xml_name "SupplierItemUpdateRequest"
27
+ xml_accessor :items, :as=>[Item], :in=>'Items'
28
+ end
29
+
30
+ end
@@ -14,11 +14,9 @@ module RubyOmx
14
14
  xml_reader :attribute_groups, :as=>[AttributeGroup]
15
15
  end
16
16
 
17
- class CustomItemInfoResponse < Response
17
+ class CustomItemInfoResponse < StandardResponse
18
18
  xml_name "CustomItemAttributeInformationResponse"
19
19
  xml_reader :items, :as => [CIAIResponseItem], :in => "Items"
20
- xml_reader :success
21
- xml_reader :errors, :as=>[Error], :in=>'ErrorData'
22
20
  end
23
21
 
24
22
  end
@@ -1,6 +1,6 @@
1
1
  module RubyOmx
2
2
 
3
- class ItemInfoResponse < Response
3
+ class ItemInfoResponse < StandardResponse
4
4
  xml_name "ItemInformationResponse"
5
5
 
6
6
  xml_reader :item_code, :from => '@itemCode', :in => "Item"
@@ -17,7 +17,6 @@ module RubyOmx
17
17
  xml_reader :price_addl_sh, :from => 'AdditionalSH', :in => 'Item/PriceData/Price', :as => Float
18
18
  xml_reader :price_bonus, :from => 'Bonus', :in => 'Item/PriceData/Price', :as => Float
19
19
  xml_reader :custom_attributes, :as => [CustomItemAttribute], :in => 'Item/CustomItemAttribute'
20
- xml_reader :errors, :as=>[Error], :in=>'ErrorData'
21
20
  end
22
21
 
23
22
  end
@@ -0,0 +1,7 @@
1
+ module RubyOmx
2
+
3
+ class ItemPriceUpdateResponse < StandardResponse
4
+ xml_name "ItemPriceUpdateResponse"
5
+ end
6
+
7
+ end
@@ -1,15 +1,7 @@
1
1
  module RubyOmx
2
2
 
3
- class ItemUpdateResponse < Response
3
+ class ItemUpdateResponse < StandardResponse
4
4
  xml_name "ItemUpdateResponse"
5
- xml_reader :success
6
- xml_reader :errors, :as=>[Error], :in=>'ErrorData'
7
-
8
- def to_s
9
- error_string = self.errors.collect{ |e| e.message.to_s }.join(',')
10
- return "success: #{success}, errors: #{error_string}"
11
- end
12
-
13
5
  end
14
6
 
15
7
  end
@@ -1,11 +1,7 @@
1
- #OrderInformationRequest (OIR200) This request type provides the ShippingInformationRequest (SIR) result for the order as a whole.
2
-
3
1
  module RubyOmx
4
2
 
5
- class MemoSubmissionResponse < Response
3
+ class MemoSubmissionResponse < StandardResponse
6
4
  xml_name "MemoSubmissionResponse"
7
- xml_reader :success
8
- xml_accessor :errors, :as=>[Error], :in=>'ErrorData'
9
5
  end
10
6
 
11
7
  end
@@ -10,15 +10,6 @@ module RubyOmx
10
10
  xml_reader :value, :from => :content, :as=>Integer
11
11
  end
12
12
 
13
- #class OrderInfoOrderHeader < Node
14
- # xml_name "OrderHeader"
15
- # xml_reader :order_id
16
- # xml_reader :order_number
17
- # xml_reader :order_status_code, :from => '@statusCode', :in=>'OrderStatus'
18
- # xml_reader :order_status_date, :as=>DateTime
19
- # xml_reader :order_date, :as=>DateTime
20
- #end
21
-
22
13
  class OrderInfoLineItem < Node
23
14
  xml_name "LineItem"
24
15
  xml_reader :item_code
@@ -47,9 +38,8 @@ module RubyOmx
47
38
  # 7 shipped?
48
39
  end
49
40
 
50
- class OrderInfoResponse < Response
41
+ class OrderInfoResponse < StandardResponse
51
42
  xml_name "OrderInformationResponse"
52
- xml_reader :success
53
43
 
54
44
  xml_reader :order_id, :in=>'OrderHeader'
55
45
  xml_reader :order_number, :in=>'OrderHeader'
@@ -62,12 +52,6 @@ module RubyOmx
62
52
  xml_reader :customer_number, :from=>'@number', :in=>'Customer'
63
53
  xml_reader :tracking_number, :in=>'ShippingInformation/Shipment'
64
54
  xml_reader :ship_date, :in=>'ShippingInformation/Shipment',:as=>DateTime # if populated, it means all items have shipped
65
- xml_reader :errors, :as=>[Error], :in=>'ErrorData'
66
-
67
- def to_s
68
- error_string = errors.collect { |e| e.to_s }.join(',')
69
- "Status #{order_status_code} for order #{order_number} with errors #{error_string}"
70
- end
71
55
  end
72
56
 
73
57
  end
@@ -1,14 +1,12 @@
1
1
  module RubyOmx
2
2
 
3
- class PurchaseOrderUpdateResponse < Response
3
+ class PurchaseOrderUpdateResponse < StandardResponse
4
4
  xml_name "PurchaseOrderUpdateResponse"
5
- xml_reader :success
6
5
  xml_accessor :po_number, :from=>'@PONumber', :in=>'PurchaseOrder' #<PurchaseOrder PONumber="16651" SupplierID="76">
7
6
  xml_accessor :supplier_id, :from=>'@SupplierID', :in=>'PurchaseOrder'
8
7
  xml_accessor :po_date, :from=>'PODate', :as=>DateTime
9
8
  xml_accessor :total_amount, :as=>Float
10
9
  xml_accessor :action
11
- xml_accessor :errors, :as=>[Error], :in=>'ErrorData'
12
10
  end
13
11
 
14
12
  end
@@ -0,0 +1,7 @@
1
+ module RubyOmx
2
+
3
+ class SupplierItemUpdateResponse < StandardResponse
4
+ xml_name "SupplierItemUpdateResponse"
5
+ end
6
+
7
+ end
@@ -2,10 +2,8 @@ module RubyOmx
2
2
 
3
3
  class UDOAResponse < Response
4
4
  xml_name "UDOAResponse"
5
- xml_reader :success, :as => Integer
6
5
  xml_reader :OMX
7
6
  xml_reader :order_number, :in => "UDOARequest/Header"
8
- xml_accessor :errors, :as=>[Error], :in=>'ErrorData'
9
7
  end
10
8
 
11
9
  end
@@ -55,5 +55,15 @@ module RubyOmx
55
55
  xml_reader :name, :from => '@name'
56
56
  xml_reader :value, :from => :content
57
57
  end
58
+
59
+ class StandardResponse < Response
60
+ xml_reader :success
61
+ xml_reader :errors, :as=>[Error], :in=>'ErrorData'
62
+
63
+ def to_s
64
+ error_string = self.errors.collect{ |e| e.message.to_s }.join(',')
65
+ return "success: #{success}, errors: #{error_string}"
66
+ end
67
+ end
58
68
 
59
69
  end
@@ -1,3 +1,3 @@
1
1
  module RubyOmx
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
3
3
  end
data/test/items_test.rb CHANGED
@@ -97,7 +97,11 @@ class ItemsTest < MiniTest::Unit::TestCase
97
97
  :file_sub_code=>20,
98
98
  :inventory_product_flag=>'True',
99
99
  :tax_code=>'TC4',
100
- :inventory_type=>3 }]}
100
+ :inventory_type=>3,
101
+ :order_split_flag=>'True',
102
+ :drop_ship_file_sub_code=>31,
103
+ :inventory_manager=>'blah'
104
+ }]}
101
105
 
102
106
 
103
107
  request = @connection.build_item_update_request(request_attrs)
@@ -110,4 +114,79 @@ class ItemsTest < MiniTest::Unit::TestCase
110
114
  assert_equal '1', response.success
111
115
  end
112
116
 
117
+
118
+ def test_item_price_update_request_from_xml
119
+ request = RubyOmx::ItemPriceUpdateRequest.format(xml_for('ItemPriceUpdateRequest(1.00)',200))
120
+ assert_equal '1.00', request.version
121
+ assert_equal 'unit', request.price_type
122
+ assert_equal 'restricted', request.quantity_type
123
+ assert_equal 1, request.price_points.length
124
+ price_point = request.price_points.first
125
+ assert_equal 10, price_point.quantity
126
+ assert_equal 3.1415926535897932384626433832795, price_point.price
127
+ end
128
+
129
+ def test_item_price_update_request_to_xml
130
+
131
+ request_attrs = {
132
+ :item_code=>'03-0303',
133
+ :keycode=>'EVDE',
134
+ :type=>'Keycode',
135
+ :price_type=>'unit',
136
+ :quantity_type=>'restricted',
137
+ :price_points=>[{
138
+ :quantity => 1,
139
+ :price=>10.0,
140
+ :shipping_handling=>1.0
141
+ }]}
142
+
143
+ request = @connection.build_item_price_update_request(request_attrs)
144
+ assert_instance_of String, request.to_xml.to_s
145
+
146
+ @connection.stubs(:post).returns(xml_for('ItemPriceUpdateResponse(1.00)',200))
147
+ response = @connection.append_item_price rescue MissingRequestOptions
148
+
149
+ response = @connection.append_item_price(request_attrs)
150
+ assert_equal '1', response.success
151
+ assert_equal 'success: 1, errors: ', response.to_s
152
+ end
153
+
154
+
155
+ def test_supplier_item_update_request_from_xml
156
+ request = RubyOmx::SupplierItemUpdateRequest.format(xml_for('SupplierItemUpdateRequest(1.00)',200))
157
+ assert_equal '1.00', request.version
158
+ assert_equal 1, request.items.length
159
+ item = request.items.first
160
+ assert_equal 11.22, item.standard_price
161
+ assert_equal 50, item.minimum_quantity
162
+ assert_equal "WID500a", item.item_code
163
+ assert_equal '1', item.supplier_id
164
+ assert_equal 2, item.units_per_package
165
+ assert_equal 'large box', item.package_description
166
+ end
167
+
168
+ def test_supplier_item_update_request_to_xml
169
+
170
+ request_attrs = {:items=>[{
171
+ :item_code=>'03-0303',
172
+ :supplier_id=>'76',
173
+ :supplier_item_code=>'03-0303',
174
+ :description=>'Description',
175
+ :standard_price=>10.5,
176
+ :delivery_lead_time_days=>5,
177
+ :minimum_quantity=>1,
178
+ :units_per_package=>1,
179
+ :package_description=>'Standard' }]
180
+ }
181
+
182
+ request = @connection.build_supplier_item_update_request(request_attrs)
183
+ assert_instance_of String, request.to_xml.to_s
184
+
185
+ @connection.stubs(:post).returns(xml_for('SupplierItemUpdateResponse(1.00)',200))
186
+ response = @connection.append_supplier_item rescue MissingRequestOptions
187
+
188
+ response = @connection.append_supplier_item(request_attrs)
189
+ assert_equal '1', response.success
190
+ end
191
+
113
192
  end
@@ -28,6 +28,7 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
28
28
  @connection.stubs(:post).returns(xml_for('PurchaseOrderUpdateResponse(1.00)',200))
29
29
 
30
30
  po_data = { :po_number => '16651', # actually would not have both po number and supplier id
31
+ :cross_reference => 'PurchaseOrder 3432',
31
32
  :line_items => [@line1, @line2],
32
33
  :supplier_id => '76'
33
34
  }
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.20
4
+ version: 0.0.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -76,20 +76,24 @@ files:
76
76
  - lib/ruby_omx/purchase_orders.rb
77
77
  - lib/ruby_omx/request/custom_item_info_request.rb
78
78
  - lib/ruby_omx/request/item_info_request.rb
79
+ - lib/ruby_omx/request/item_price_update_request.rb
79
80
  - lib/ruby_omx/request/item_update_request.rb
80
81
  - lib/ruby_omx/request/memo_submission_request.rb
81
82
  - lib/ruby_omx/request/order_info_request.rb
82
83
  - lib/ruby_omx/request/purchase_order_update_request.rb
84
+ - lib/ruby_omx/request/supplier_item_update_request.rb
83
85
  - lib/ruby_omx/request/udoa_request.rb
84
86
  - lib/ruby_omx/request.rb
85
87
  - lib/ruby_omx/response/custom_item_info_response.rb
86
88
  - lib/ruby_omx/response/item_info_response.rb
89
+ - lib/ruby_omx/response/item_price_update_response.rb
87
90
  - lib/ruby_omx/response/item_update_response.rb
88
91
  - lib/ruby_omx/response/memo_submission_response.rb
89
92
  - lib/ruby_omx/response/order_info_response.rb
90
93
  - lib/ruby_omx/response/purchase_order_update_response.rb
91
94
  - lib/ruby_omx/response/response_error.rb
92
95
  - lib/ruby_omx/response/smart_report_response.rb
96
+ - lib/ruby_omx/response/supplier_item_update_response.rb
93
97
  - lib/ruby_omx/response/udoa_response.rb
94
98
  - lib/ruby_omx/response.rb
95
99
  - lib/ruby_omx/version.rb