ruby_omx 0.0.26 → 0.0.27

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.
@@ -74,6 +74,19 @@ module RubyOmx
74
74
  end
75
75
  alias_method :append_supplier_item, :send_supplier_item_update_request
76
76
 
77
+ # Inventory Availability
78
+
79
+ def build_inventory_info_request(attrs={})
80
+ InventoryInfoRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
81
+ end
82
+
83
+ def send_inventory_info_request(attrs={})
84
+ request = build_inventory_info_request(attrs)
85
+ response = post(request.to_xml.to_s)
86
+ return response if request.raw_xml==true || request.raw_xml==1
87
+ InventoryInfoResponse.format(response)
88
+ end
89
+ alias_method :fetch_inventory, :send_inventory_info_request
77
90
 
78
91
  end
79
92
  end
@@ -0,0 +1,18 @@
1
+ module RubyOmx
2
+
3
+ class InventoryInfoRequest < Request
4
+
5
+ def initialize(attrs={})
6
+ return super unless attrs.any?
7
+ raise MissingRequestOptions if attrs[:items].nil?
8
+ super
9
+ self.version = attrs[:version] ||= '1.00'
10
+ self.udi_parameters << UDIParameter.new({:key=>'RealNonInventoryItemAvailability', :value=>attrs[:real_non_inventory_item_availability] || 'True' })
11
+ self.items = attrs[:items].collect { |h| Item.new(h) }
12
+ end
13
+
14
+ xml_name "InventoryInformationRequest"
15
+ xml_accessor :items, :as=>[Item], :in=>'Items'
16
+
17
+ end
18
+ end
@@ -1,8 +1,6 @@
1
1
  module RubyOmx
2
2
 
3
- class Item < Node
4
- xml_name "Item"
5
- xml_accessor :item_code, :from=>'@itemCode'
3
+ class SupplierItem < Item
6
4
  xml_accessor :supplier_id, :from=>'@supplierID'
7
5
  xml_accessor :supplier_item_code
8
6
  xml_accessor :description
@@ -20,11 +18,11 @@ module RubyOmx
20
18
  raise MissingRequestOptions if attrs[:items].nil?
21
19
  super
22
20
  self.version = attrs[:version] ||= '1.00'
23
- self.items = attrs[:items].collect { |h| Item.new(h) }
21
+ self.items = attrs[:items].collect { |h| SupplierItem.new(h) }
24
22
  end
25
23
 
26
24
  xml_name "SupplierItemUpdateRequest"
27
- xml_accessor :items, :as=>[Item], :in=>'Items'
25
+ xml_accessor :items, :as=>[SupplierItem], :in=>'Items'
28
26
  end
29
27
 
30
28
  end
@@ -0,0 +1,28 @@
1
+ module RubyOmx
2
+
3
+ class InventoryItem < Item
4
+ xml_reader :available, :as => Integer
5
+ end
6
+
7
+ class InventoryInfoResponse < StandardResponse
8
+ xml_name "InventoryInformationResponse"
9
+ xml_reader :items, :as => [InventoryItem], :in => "Items"
10
+
11
+
12
+ xml_reader :item_code, :from => '@itemCode', :in => "Item"
13
+ xml_reader :active, :from => '@active', :in => "Item"
14
+ xml_reader :incomplete, :from => '@incomplete', :in => "Item"
15
+ xml_reader :parent_item_code, :from => '@parentItemCode', :in => "Item"
16
+ xml_reader :product_name, :in => "Item"
17
+ xml_reader :available_inventory, :as => Integer, :in => "Item"
18
+ xml_reader :price_type, :from => '@priceType', :in => 'Item/PriceData'
19
+ xml_reader :quantity_type, :from => '@quantityType', :in => 'Item/PriceData'
20
+ xml_reader :price_quantity, :from => '@quantity', :in => 'Item/PriceData/Price', :as => Integer
21
+ xml_reader :price_multiplier, :from => '@multiplier', :in => 'Item/PriceData/Price'
22
+ xml_reader :price_amount, :from => 'Amount', :in => 'Item/PriceData/Price', :as => Float
23
+ xml_reader :price_addl_sh, :from => 'AdditionalSH', :in => 'Item/PriceData/Price', :as => Float
24
+ xml_reader :price_bonus, :from => 'Bonus', :in => 'Item/PriceData/Price', :as => Float
25
+ xml_reader :custom_attributes, :as => [CustomItemAttribute], :in => 'Item/CustomItemAttribute'
26
+ end
27
+
28
+ end
@@ -37,6 +37,11 @@ module RubyOmx
37
37
  end
38
38
  end
39
39
 
40
+ class Item < Node
41
+ xml_name "Item"
42
+ xml_accessor :item_code, :from=>'@itemCode'
43
+ end
44
+
40
45
  # LineItems appear in requests and responses
41
46
  class LineItem < Node
42
47
  xml_name "LineItem"
@@ -1,3 +1,3 @@
1
1
  module RubyOmx
2
- VERSION = "0.0.26"
2
+ VERSION = "0.0.27"
3
3
  end
data/test/items_test.rb CHANGED
@@ -188,5 +188,30 @@ class ItemsTest < MiniTest::Unit::TestCase
188
188
  response = @connection.append_supplier_item(request_attrs)
189
189
  assert_equal '1', response.success
190
190
  end
191
+
192
+ def test_inventory_info_request_from_xml
193
+ request = RubyOmx::InventoryInfoRequest.format(xml_for('InventoryInformationRequest(1.00)',200))
194
+ assert_equal '1.00', request.version
195
+ assert_equal 2, request.items.length
196
+ item = request.items.first
197
+ assert_equal '10400', item.item_code
198
+ end
191
199
 
200
+ def test_inventory_info_request_to_xml
201
+
202
+ request_attrs = {:items=>[{:item_code=>'10400'}, {:item_code=>'PARENT'}]}
203
+ request = @connection.build_inventory_info_request(request_attrs)
204
+ assert_instance_of String, request.to_xml.to_s
205
+
206
+ @connection.stubs(:post).returns(xml_for('InventoryInformationResponse(1.00)',200))
207
+ response = @connection.fetch_inventory rescue MissingRequestOptions
208
+
209
+ response = @connection.fetch_inventory(request_attrs)
210
+ assert_equal '1', response.success
211
+ assert_equal 2, response.items.length
212
+ item = response.items.first
213
+ assert_equal '10400', item.item_code
214
+ assert_equal -438, item.available
215
+ end
216
+
192
217
  end
data/test/real_test.rb CHANGED
@@ -43,9 +43,13 @@ class RealTestTest < MiniTest::Unit::TestCase
43
43
  puts response.to_s
44
44
  assert_kind_of PurchaseOrderUpdateResponse, response
45
45
  end
46
-
46
+
47
47
  def test_real_order_info
48
- order_info_data = { :order_id => '102-4169344-8910627', :store_code=>'Amazon.com MFN HDO', :version=>'2.00' }
48
+ #:store_code=>'Amazon.com MFN HDO'
49
+ #order_info_data = { :order_id => '002-5043507-2313848', :store_code=>'Amazon.com MFN HDO' }
50
+ order_info_data = { :order_id => '102-2853206-2589018', :store_code=>'Amazon.com MFN HDO' } # no first name
51
+
52
+ #order_info_data = { :order_number => '185488', :version=>'2.00' }
49
53
  r = @connection.build_info_request(order_info_data)
50
54
  assert_instance_of String, r.to_xml.to_s
51
55
  puts r.to_xml.to_s
@@ -54,5 +58,16 @@ class RealTestTest < MiniTest::Unit::TestCase
54
58
  puts response.to_xml.to_s
55
59
  assert_kind_of OrderInfoResponse, response
56
60
  end
61
+
62
+ def test_real_inventory_info
63
+ inventory_info_data = { :items => [ {:item_code=>'14141103-021-XL'}, {:item_code=>'14341104-021-XL'}] }
64
+ r = @connection.build_inventory_info_request(inventory_info_data)
65
+ assert_instance_of String, r.to_xml.to_s
66
+ puts r.to_xml.to_s
67
+
68
+ response = @connection.send_inventory_info_request(inventory_info_data)
69
+ puts response.to_xml.to_s
70
+ assert_kind_of InventoryInfoResponse, response
71
+ end
57
72
  =end
58
73
  end
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.26
4
+ version: 0.0.27
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-16 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: roxml
@@ -75,6 +75,7 @@ files:
75
75
  - lib/ruby_omx/orders.rb
76
76
  - lib/ruby_omx/purchase_orders.rb
77
77
  - lib/ruby_omx/request/custom_item_info_request.rb
78
+ - lib/ruby_omx/request/inventory_info_request.rb
78
79
  - lib/ruby_omx/request/item_info_request.rb
79
80
  - lib/ruby_omx/request/item_price_update_request.rb
80
81
  - lib/ruby_omx/request/item_update_request.rb
@@ -85,6 +86,7 @@ files:
85
86
  - lib/ruby_omx/request/udoa_request.rb
86
87
  - lib/ruby_omx/request.rb
87
88
  - lib/ruby_omx/response/custom_item_info_response.rb
89
+ - lib/ruby_omx/response/inventory_info_response.rb
88
90
  - lib/ruby_omx/response/item_info_response.rb
89
91
  - lib/ruby_omx/response/item_price_update_response.rb
90
92
  - lib/ruby_omx/response/item_update_response.rb