ruby_omx 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby_omx/base.rb +3 -18
- data/lib/ruby_omx/connection.rb +3 -5
- data/lib/ruby_omx/exceptions.rb +16 -54
- data/lib/ruby_omx/items.rb +32 -56
- data/lib/ruby_omx/memos.rb +4 -4
- data/lib/ruby_omx/node.rb +30 -0
- data/lib/ruby_omx/orders.rb +13 -13
- data/lib/ruby_omx/purchase_orders.rb +5 -4
- data/lib/ruby_omx/request/custom_item_info_request.rb +17 -0
- data/lib/ruby_omx/request/item_info_request.rb +16 -0
- data/lib/ruby_omx/request/item_update_request.rb +37 -0
- data/lib/ruby_omx/request/memo_submission_request.rb +21 -0
- data/lib/ruby_omx/request/order_info_request.rb +22 -0
- data/lib/ruby_omx/request/purchase_order_update_request.rb +21 -0
- data/lib/ruby_omx/request/udoa_request.rb +84 -0
- data/lib/ruby_omx/request.rb +24 -0
- data/lib/ruby_omx/response/custom_item_info_response.rb +24 -0
- data/lib/ruby_omx/response/item_info_response.rb +4 -18
- data/lib/ruby_omx/response/item_update_response.rb +15 -0
- data/lib/ruby_omx/response/memo_submission_response.rb +1 -1
- data/lib/ruby_omx/response/order_info_response.rb +25 -15
- data/lib/ruby_omx/response/purchase_order_update_response.rb +1 -4
- data/lib/ruby_omx/response/response_error.rb +3 -9
- data/lib/ruby_omx/response/smart_report_response.rb +2 -2
- data/lib/ruby_omx/response/udoa_response.rb +7 -8
- data/lib/ruby_omx/response.rb +26 -41
- data/lib/ruby_omx/version.rb +1 -1
- data/lib/ruby_omx.rb +3 -18
- data/test/base_test.rb +4 -13
- data/test/items_test.rb +76 -19
- data/test/orders_test.rb +11 -12
- data/test/purchase_orders_test.rb +5 -9
- data/test/real_config.yml +8 -0
- data/test/real_test.rb +61 -0
- metadata +17 -7
- data/lib/ruby_omx/response/custom_item_attr_info_response.rb +0 -43
- data/lib/ruby_omx/response/memo_submission_request.rb +0 -33
- data/lib/ruby_omx/response/order_info_request.rb +0 -29
- data/lib/ruby_omx/response/purchase_order_update_request.rb +0 -33
- data/lib/ruby_omx/response/udoa_request.rb +0 -94
@@ -0,0 +1,24 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class AttributeGroup < Node
|
4
|
+
xml_name "AttributeGroup"
|
5
|
+
xml_reader :name, :from=>'@name'
|
6
|
+
xml_reader :group_id, :from=>'@groupID'
|
7
|
+
xml_reader :attributes, :as => [CustomItemAttribute]
|
8
|
+
end
|
9
|
+
|
10
|
+
class CIAIResponseItem < Node
|
11
|
+
xml_name "Item"
|
12
|
+
xml_reader :item_code, :from => '@itemCode'
|
13
|
+
xml_reader :active, :from => '@active'
|
14
|
+
xml_reader :attribute_groups, :as=>[AttributeGroup]
|
15
|
+
end
|
16
|
+
|
17
|
+
class CustomItemInfoResponse < Response
|
18
|
+
xml_name "CustomItemAttributeInformationResponse"
|
19
|
+
xml_reader :items, :as => [CIAIResponseItem], :in => "Items"
|
20
|
+
xml_reader :success
|
21
|
+
xml_reader :errors, :as=>[Error], :in=>'ErrorData'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -1,37 +1,23 @@
|
|
1
1
|
module RubyOmx
|
2
2
|
|
3
|
-
class
|
4
|
-
xml_name "Attribute"
|
5
|
-
xml_reader :attribute_id, :from => '@attributeID'
|
6
|
-
xml_reader :name, :from => '@name'
|
7
|
-
xml_reader :value, :from => :content
|
8
|
-
end
|
9
|
-
|
10
|
-
class ItemInformationResponse < Response
|
3
|
+
class ItemInfoResponse < Response
|
11
4
|
xml_name "ItemInformationResponse"
|
12
5
|
|
13
6
|
xml_reader :item_code, :from => '@itemCode', :in => "Item"
|
14
7
|
xml_reader :active, :from => '@active', :in => "Item"
|
15
8
|
xml_reader :incomplete, :from => '@incomplete', :in => "Item"
|
16
9
|
xml_reader :parent_item_code, :from => '@parentItemCode', :in => "Item"
|
17
|
-
|
18
|
-
|
19
10
|
xml_reader :product_name, :in => "Item"
|
20
|
-
xml_reader :available_inventory, :as => Integer, :in => "Item"
|
21
|
-
#xml_reader :sub_item_count, :as => Integer, :in => "Item"
|
22
|
-
#xml_reader :last_updated_date, :as => DateTime, :in => "Item"
|
23
|
-
#xml_reader :weight, :as => Float, :in => "Item"
|
24
|
-
|
11
|
+
xml_reader :available_inventory, :as => Integer, :in => "Item"
|
25
12
|
xml_reader :price_type, :from => '@priceType', :in => 'Item/PriceData'
|
26
13
|
xml_reader :quantity_type, :from => '@quantityType', :in => 'Item/PriceData'
|
27
14
|
xml_reader :price_quantity, :from => '@quantity', :in => 'Item/PriceData/Price', :as => Integer
|
28
15
|
xml_reader :price_multiplier, :from => '@multiplier', :in => 'Item/PriceData/Price'
|
29
|
-
|
30
16
|
xml_reader :price_amount, :from => 'Amount', :in => 'Item/PriceData/Price', :as => Float
|
31
17
|
xml_reader :price_addl_sh, :from => 'AdditionalSH', :in => 'Item/PriceData/Price', :as => Float
|
32
18
|
xml_reader :price_bonus, :from => 'Bonus', :in => 'Item/PriceData/Price', :as => Float
|
33
|
-
|
34
|
-
|
19
|
+
xml_reader :custom_attributes, :as => [CustomItemAttribute], :in => 'Item/CustomItemAttribute'
|
20
|
+
xml_reader :errors, :as=>[Error], :in=>'ErrorData'
|
35
21
|
end
|
36
22
|
|
37
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class ItemUpdateResponse < Response
|
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
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module RubyOmx
|
4
4
|
|
5
|
-
class OrderInfoLineStatus <
|
5
|
+
class OrderInfoLineStatus < Node
|
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
|
@@ -10,16 +10,16 @@ module RubyOmx
|
|
10
10
|
xml_reader :value, :from => :content, :as=>Integer
|
11
11
|
end
|
12
12
|
|
13
|
-
class OrderInfoOrderHeader <
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
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
21
|
|
22
|
-
class OrderInfoLineItem <
|
22
|
+
class OrderInfoLineItem < Node
|
23
23
|
xml_name "LineItem"
|
24
24
|
xml_reader :item_code
|
25
25
|
xml_reader :product_name
|
@@ -47,17 +47,27 @@ module RubyOmx
|
|
47
47
|
# 7 shipped?
|
48
48
|
end
|
49
49
|
|
50
|
-
class
|
50
|
+
class OrderInfoResponse < Response
|
51
51
|
xml_name "OrderInformationResponse"
|
52
|
-
xml_reader :success
|
52
|
+
xml_reader :success
|
53
|
+
|
54
|
+
xml_reader :order_id, :in=>'OrderHeader'
|
55
|
+
xml_reader :order_number, :in=>'OrderHeader'
|
56
|
+
xml_reader :order_status_code, :from => '@statusCode', :in=>'OrderHeader/OrderStatus'
|
57
|
+
xml_reader :order_status_date, :as=>DateTime, :in=>'OrderHeader'
|
58
|
+
xml_reader :order_date, :as=>DateTime, :in=>'OrderHeader'
|
53
59
|
|
54
|
-
xml_reader :order_header, :as=>OrderInfoOrderHeader
|
55
|
-
#xml_reader :shipping_information, :as=>OrderInfoShippingInfo
|
60
|
+
#xml_reader :order_header, :as=>OrderInfoOrderHeader
|
56
61
|
xml_reader :line_items, :as => [OrderInfoLineItem], :in=>'OrderDetail'
|
57
|
-
|
58
62
|
xml_reader :customer_number, :from=>'@number', :in=>'Customer'
|
59
63
|
xml_reader :tracking_number, :in=>'ShippingInformation/Shipment'
|
60
64
|
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
|
61
71
|
end
|
62
72
|
|
63
73
|
end
|
@@ -1,17 +1,14 @@
|
|
1
|
-
#OrderInformationRequest (OIR200) This request type provides the ShippingInformationRequest (SIR) result for the order as a whole.
|
2
1
|
module RubyOmx
|
3
2
|
|
4
3
|
class PurchaseOrderUpdateResponse < Response
|
5
4
|
xml_name "PurchaseOrderUpdateResponse"
|
6
5
|
xml_reader :success
|
7
|
-
#xml_accessor :purchase_order, :as => RubyOmx::PurchaseOrderResponse
|
8
6
|
xml_accessor :po_number, :from=>'@PONumber', :in=>'PurchaseOrder' #<PurchaseOrder PONumber="16651" SupplierID="76">
|
9
7
|
xml_accessor :supplier_id, :from=>'@SupplierID', :in=>'PurchaseOrder'
|
10
|
-
|
11
8
|
xml_accessor :po_date, :from=>'PODate', :as=>DateTime
|
12
9
|
xml_accessor :total_amount, :as=>Float
|
13
10
|
xml_accessor :action
|
14
|
-
xml_accessor :errors, :as=>[
|
11
|
+
xml_accessor :errors, :as=>[Error], :in=>'ErrorData'
|
15
12
|
end
|
16
13
|
|
17
14
|
end
|
@@ -7,17 +7,11 @@ module RubyOmx
|
|
7
7
|
|
8
8
|
class ResponseError < Response
|
9
9
|
xml_name "ErrorResponse"
|
10
|
-
|
11
|
-
#xml_reader :type, :in => "Error"
|
12
|
-
#xml_reader :code, :in => "Error"
|
13
|
-
#xml_reader :message, :in => "Error"
|
14
|
-
#xml_reader :detail, :in => "Error"
|
15
|
-
#xml_reader :request_id
|
16
10
|
xml_reader :success
|
17
|
-
xml_reader :
|
18
|
-
|
11
|
+
xml_reader :error_messages, :as=>[ErrorMessage], :in=>'ErrorData'
|
12
|
+
|
19
13
|
def to_s
|
20
|
-
self.errors.join(',')
|
14
|
+
self.errors.collect{ |e| e.message.to_s }.join(',')
|
21
15
|
end
|
22
16
|
|
23
17
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module RubyOmx
|
2
2
|
|
3
|
-
class SmartReportField <
|
3
|
+
class SmartReportField < Node
|
4
4
|
xml_name "Field"
|
5
5
|
xml_reader :id, :from=>'@fieldID'
|
6
6
|
xml_reader :value, :from=>:content
|
7
7
|
end
|
8
8
|
|
9
|
-
class SmartReportRow <
|
9
|
+
class SmartReportRow < Node
|
10
10
|
xml_name "Row"
|
11
11
|
xml_reader :fields, :as=>[SmartReportField]
|
12
12
|
#1 Order Number
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module RubyOmx
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
3
|
+
class UDOAResponse < Response
|
4
|
+
xml_name "UDOAResponse"
|
5
|
+
xml_reader :success, :as => Integer
|
6
|
+
xml_reader :OMX
|
7
|
+
xml_reader :order_number, :in => "UDOARequest/Header"
|
8
|
+
xml_accessor :errors, :as=>[Error], :in=>'ErrorData'
|
9
|
+
end
|
11
10
|
|
12
11
|
end
|
data/lib/ruby_omx/response.rb
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
module RubyOmx
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
# ErrorData appears in responses
|
4
|
+
class Error < Node
|
5
|
+
xml_name 'Error'
|
6
|
+
xml_accessor :error_id, :from=>'@errorID'
|
7
|
+
xml_accessor :error_severity, :from=>'@errorSeverity'
|
8
|
+
xml_accessor :error_detail_0, :from=>'@errorDetail0'
|
9
|
+
xml_accessor :error_detail_1, :from=>'@errorDetail1'
|
10
|
+
xml_accessor :message, :from=>:content
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
"#{error_id}: #{error_severity} #{error_detail_0} #{error_detail_1} #{message}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Response < Node
|
4
18
|
include ROXML
|
5
19
|
xml_convention :camelcase
|
6
20
|
|
7
|
-
def initialize(object_attribute_hash=nil)
|
8
|
-
object_attribute_hash.map { |(k, v)| send("#{k}=", v) } if object_attribute_hash.present?
|
9
|
-
end
|
10
|
-
|
11
21
|
# This is the factoryish method that is called!, not new
|
12
22
|
def self.format(response)
|
13
23
|
if response.content_type =~ /xml/ || response.body =~ /<?xml/
|
@@ -25,50 +35,25 @@ module RubyOmx
|
|
25
35
|
return self.from_xml(response.body)
|
26
36
|
end
|
27
37
|
end
|
28
|
-
|
29
|
-
def accessors
|
30
|
-
roxml_references.map {|r| r.accessor}
|
31
|
-
end
|
32
|
-
|
33
|
-
# render a ROXML object as a normal hash, eliminating the @ and some unneeded admin fields
|
34
|
-
def as_hash
|
35
|
-
obj_hash = {}
|
36
|
-
self.instance_variables.each do |v|
|
37
|
-
m = v.to_s.sub('@','')
|
38
|
-
if m != 'roxml_references' && m!= 'promotion_ids'
|
39
|
-
obj_hash[m.to_sym] = self.instance_variable_get(v)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
obj_hash
|
43
|
-
end
|
44
|
-
|
45
38
|
end
|
46
39
|
|
47
|
-
#
|
48
|
-
|
49
|
-
class UDIParameter < Response
|
50
|
-
xml_name "Parameter"
|
51
|
-
xml_accessor :key, :from => '@key'
|
52
|
-
xml_accessor :value, :from => :content
|
53
|
-
end
|
54
|
-
|
55
|
-
class LineItem < Response
|
40
|
+
# LineItems appear in requests and responses
|
41
|
+
class LineItem < Node
|
56
42
|
xml_name "LineItem"
|
57
43
|
xml_accessor :line_number, :from => '@lineNumber'
|
58
44
|
xml_accessor :item_code
|
59
45
|
xml_accessor :quantity, :as => Integer
|
60
46
|
xml_accessor :unit_price, :as => Float
|
61
47
|
xml_accessor :price, :as => Float
|
48
|
+
xml_accessor :update_standard_price # default to 'False'
|
62
49
|
xml_accessor :cancel_line
|
63
50
|
end
|
64
|
-
|
65
|
-
class
|
66
|
-
xml_name
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
xml_accessor :error_detail_1, :from=>'@errorDetail1'
|
71
|
-
xml_accessor :message, :from=>:content
|
51
|
+
|
52
|
+
class CustomItemAttribute < Node
|
53
|
+
xml_name "Attribute"
|
54
|
+
xml_reader :attribute_id, :from => '@attributeID'
|
55
|
+
xml_reader :name, :from => '@name'
|
56
|
+
xml_reader :value, :from => :content
|
72
57
|
end
|
73
|
-
|
58
|
+
|
74
59
|
end
|
data/lib/ruby_omx/version.rb
CHANGED
data/lib/ruby_omx.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#require 'rubygems'
|
2
1
|
require 'cgi'
|
3
2
|
require 'uri'
|
4
3
|
require 'openssl'
|
@@ -12,29 +11,15 @@ require 'roxml'
|
|
12
11
|
|
13
12
|
$:.unshift(File.dirname(__FILE__))
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
module_function
|
18
|
-
def add_child_helper(parent_node,child_name,key,value,content)
|
19
|
-
new_node = parent_node.add_child(Nokogiri::XML::Node.new child_name, parent_node)
|
20
|
-
if !key.nil? && !value.nil?
|
21
|
-
new_node[key] = value
|
22
|
-
end
|
23
|
-
if !content.nil?
|
24
|
-
new_node.content = content
|
25
|
-
end
|
26
|
-
return new_node
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
|
14
|
+
require 'ruby_omx/node'
|
32
15
|
require 'ruby_omx/response'
|
16
|
+
require 'ruby_omx/request'
|
33
17
|
require 'ruby_omx/orders'
|
34
18
|
require 'ruby_omx/items'
|
35
19
|
require 'ruby_omx/purchase_orders'
|
36
20
|
require 'ruby_omx/memos'
|
37
21
|
Dir.glob(File.join(File.dirname(__FILE__), 'ruby_omx/response/*.rb')).each {|f| require f }
|
22
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'ruby_omx/request/*.rb')).each {|f| require f }
|
38
23
|
|
39
24
|
require 'ruby_omx/base'
|
40
25
|
require 'ruby_omx/version'
|
data/test/base_test.rb
CHANGED
@@ -3,19 +3,10 @@ require 'test_helper'
|
|
3
3
|
class BaseTest < MiniTest::Unit::TestCase
|
4
4
|
|
5
5
|
def test_connection
|
6
|
-
|
7
|
-
|
8
|
-
@connection = RubyOmx::Base.new()
|
9
|
-
rescue RubyOmx::MissingAccessKey
|
10
|
-
end
|
11
|
-
|
12
|
-
begin
|
13
|
-
@connection = RubyOmx::Base.new(:udi_auth_token=>'asdfasdf')
|
14
|
-
rescue RubyOmx::MissingAccessKey
|
15
|
-
end
|
16
|
-
|
6
|
+
@connection = RubyOmx::Base.new() rescue RubyOmx::MissingAccessKey
|
7
|
+
@connection = RubyOmx::Base.new(:udi_auth_token=>'asdfasdf') rescue RubyOmx::MissingAccessKey
|
17
8
|
@config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
|
18
|
-
@connection = RubyOmx::Base.new(@config)
|
19
|
-
|
9
|
+
@connection = RubyOmx::Base.new(@config)
|
20
10
|
end
|
11
|
+
|
21
12
|
end
|
data/test/items_test.rb
CHANGED
@@ -6,14 +6,39 @@ class ItemsTest < MiniTest::Unit::TestCase
|
|
6
6
|
@connection = RubyOmx::Base.new(@config)
|
7
7
|
end
|
8
8
|
|
9
|
+
def test_item_info_request_from_xml
|
10
|
+
request = RubyOmx::ItemInfoRequest.format(xml_for('ItemInformationRequest(1.00)',200))
|
11
|
+
assert_equal '1.00', request.version
|
12
|
+
assert_equal 'ItemCode', request.udi_parameters.last.key
|
13
|
+
assert_equal '01-114', request.udi_parameters.last.value
|
14
|
+
|
15
|
+
request = RubyOmx::CustomItemInfoRequest.format(xml_for('CustomItemAttributeInformationRequest(2.00)',200))
|
16
|
+
assert_equal '2.00', request.version
|
17
|
+
|
18
|
+
assert_equal 'AttributeGroupID', request.udi_parameters[3].key
|
19
|
+
assert_equal '5', request.udi_parameters[3].value
|
20
|
+
|
21
|
+
assert_equal 'ItemCode', request.udi_parameters[2].key
|
22
|
+
assert_equal 'DANKITEM4-1', request.udi_parameters[2].value
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_item_info_request_to_xml
|
26
|
+
request_attrs = { :item_code => '01-114' }
|
27
|
+
request = @connection.build_item_info_request(request_attrs)
|
28
|
+
request2 = RubyOmx::ItemInfoRequest.format(xml_for('ItemInformationRequest(1.00)',200))
|
29
|
+
assert_equal request.to_xml.to_s, request2.to_xml.to_s
|
30
|
+
|
31
|
+
request_attrs = { :item_code => 'DANKITEM4-1', :attribute_group_id=>'5' }
|
32
|
+
request = @connection.build_custom_item_info_request(request_attrs)
|
33
|
+
request2 = RubyOmx::CustomItemInfoRequest.format(xml_for('CustomItemAttributeInformationRequest(2.00)',200))
|
34
|
+
assert_equal request.to_xml.to_s, request2.to_xml.to_s
|
35
|
+
end
|
36
|
+
|
9
37
|
def test_get_item_information
|
10
38
|
@connection.stubs(:post).returns(xml_for('ItemInformationResponse(1.00)',200))
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
response = @connection.get_item_info(:item_code=>'01-114')
|
39
|
+
response = @connection.get_item_info() rescue MissingRequestOptions
|
40
|
+
|
41
|
+
response = @connection.get_item_info({:item_code=>'01-114'})
|
17
42
|
assert_equal '01-114', response.item_code
|
18
43
|
assert_equal 'True', response.active
|
19
44
|
assert_equal 'Driver', response.product_name
|
@@ -28,29 +53,61 @@ class ItemsTest < MiniTest::Unit::TestCase
|
|
28
53
|
assert_equal 6, response.custom_attributes.length
|
29
54
|
assert_equal "1", response.custom_attributes.first.attribute_id
|
30
55
|
assert_equal "MYAttribute1", response.custom_attributes.first.value
|
31
|
-
|
32
56
|
assert_kind_of Hash, response.as_hash
|
33
57
|
end
|
34
58
|
|
35
59
|
def test_get_custom_item_attribute_information
|
36
|
-
@connection.stubs(:post).returns(xml_for('CustomItemAttributeInformationResponse(
|
37
|
-
|
38
|
-
response = @connection.get_custom_item_attribute_info()
|
39
|
-
rescue MissingItemOptions
|
40
|
-
end
|
60
|
+
@connection.stubs(:post).returns(xml_for('CustomItemAttributeInformationResponse(2.00)',200))
|
61
|
+
response = @connection.get_custom_item_info() rescue MissingRequestOptions
|
41
62
|
|
42
|
-
response = @connection.
|
63
|
+
response = @connection.get_custom_item_info(:item_code=>'00001')
|
43
64
|
assert_kind_of Hash, response.as_hash
|
44
65
|
assert_equal '1', response.success
|
45
66
|
i = response.items.first
|
46
|
-
assert_equal '
|
67
|
+
assert_equal '00001', i.item_code
|
47
68
|
assert_equal 'True', i.active
|
48
|
-
i_attrs = i.attributes
|
49
|
-
assert_equal
|
50
|
-
assert_equal '
|
51
|
-
assert_equal '
|
52
|
-
|
69
|
+
i_attrs = i.attribute_groups.first.attributes
|
70
|
+
assert_equal 1, i_attrs.length
|
71
|
+
assert_equal '3', i_attrs.first.attribute_id
|
72
|
+
assert_equal 'otrofield', i_attrs.first.name
|
53
73
|
assert_kind_of Hash, response.as_hash
|
54
74
|
end
|
55
75
|
|
76
|
+
|
77
|
+
def test_item_update_request_from_xml
|
78
|
+
request = RubyOmx::ItemUpdateRequest.format(xml_for('ItemUpdateRequest(2.00)',200))
|
79
|
+
assert_equal '2.00', request.version
|
80
|
+
assert_equal 1, request.items.length
|
81
|
+
item = request.items.first
|
82
|
+
assert_equal 'APPLE', item.item_code
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_item_update_request_to_xml
|
86
|
+
|
87
|
+
request_attrs = {:items=> [{
|
88
|
+
:item_code => 'APPLE',
|
89
|
+
:product_status=>'True',
|
90
|
+
:incomplete_flag=>'False',
|
91
|
+
:product_name=>'Apple Product',
|
92
|
+
:product_group=>45,
|
93
|
+
:cost_of_goods=>10,
|
94
|
+
:upc_code=>'234234234',
|
95
|
+
:allow_order_line_info=>'True',
|
96
|
+
:launch_date=>'2/23/2006',
|
97
|
+
:file_sub_code=>20,
|
98
|
+
:inventory_product_flag=>'True',
|
99
|
+
:tax_code=>'TC4',
|
100
|
+
:inventory_type=>3 }]}
|
101
|
+
|
102
|
+
|
103
|
+
request = @connection.build_item_update_request(request_attrs)
|
104
|
+
assert_instance_of String, request.to_xml.to_s
|
105
|
+
|
106
|
+
@connection.stubs(:post).returns(xml_for('ItemUpdateResponse(2.00)',200))
|
107
|
+
response = @connection.append_item rescue MissingRequestOptions
|
108
|
+
|
109
|
+
response = @connection.append_item(request_attrs)
|
110
|
+
assert_equal '1', response.success
|
111
|
+
end
|
112
|
+
|
56
113
|
end
|
data/test/orders_test.rb
CHANGED
@@ -165,7 +165,7 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
165
165
|
# Missing Order Options
|
166
166
|
begin
|
167
167
|
response = @connection.send_udoa_request(order_data)
|
168
|
-
rescue
|
168
|
+
rescue MissingRequestOptions
|
169
169
|
end
|
170
170
|
|
171
171
|
order_data[:line_items][0].merge!({ :item_code => 'SKU' })
|
@@ -190,14 +190,13 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
190
190
|
def test_send_info_request1
|
191
191
|
@connection.stubs(:post).returns(xml_for('OrderInformationResponse(1.00)',200))
|
192
192
|
response = @connection.send_info_request({ :order_number => '16651' })
|
193
|
-
assert_kind_of
|
194
|
-
assert !response.accessors.include?("code")
|
193
|
+
assert_kind_of OrderInfoResponse, response
|
195
194
|
|
196
195
|
assert_equal DateTime.parse('2006-02-09 14:47:00'), response.ship_date
|
197
196
|
assert_equal '11229', response.customer_number
|
198
197
|
assert_equal "", response.tracking_number
|
199
|
-
assert_equal '16651', response.
|
200
|
-
assert_equal DateTime.parse('2005-06-20 14:25:00'), response.
|
198
|
+
assert_equal '16651', response.order_number
|
199
|
+
assert_equal DateTime.parse('2005-06-20 14:25:00'), response.order_date
|
201
200
|
assert_equal 1, response.line_items.length
|
202
201
|
assert_equal '16651-1', response.line_items[0].shipment_number
|
203
202
|
assert_equal 6.52, response.line_items[0].line_cogs
|
@@ -214,16 +213,16 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
214
213
|
def test_send_info_request2
|
215
214
|
@connection_alt.stubs(:post).returns(xml_for('OrderInformationResponse(2.00)',200))
|
216
215
|
response = @connection_alt.send_info_request({ :order_number => '24603', :version=>'2.00' })
|
217
|
-
assert_kind_of
|
216
|
+
assert_kind_of OrderInfoResponse, response
|
218
217
|
|
219
218
|
assert_nil response.ship_date
|
220
219
|
assert_equal "", response.tracking_number
|
221
220
|
|
222
|
-
assert_nil response.
|
223
|
-
assert_equal '24603', response.
|
224
|
-
assert_equal DateTime.parse('2003-04-01 22:15:00'), response.
|
225
|
-
assert_equal DateTime.parse('2010-05-31 05:36:00'), response.
|
226
|
-
assert_equal '4', response.
|
221
|
+
assert_nil response.order_id
|
222
|
+
assert_equal '24603', response.order_number
|
223
|
+
assert_equal DateTime.parse('2003-04-01 22:15:00'), response.order_date
|
224
|
+
assert_equal DateTime.parse('2010-05-31 05:36:00'), response.order_status_date
|
225
|
+
assert_equal '4', response.order_status_code
|
227
226
|
|
228
227
|
assert_equal '11552', response.customer_number
|
229
228
|
assert_equal 2, response.line_items.length
|
@@ -242,7 +241,7 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
242
241
|
assert_kind_of Hash, response.as_hash
|
243
242
|
|
244
243
|
response = @connection_alt.send_info_request({ :order_id=> 'AZ-43253-234', :store_code=>'XX01', :version=>'2.00' })
|
245
|
-
assert_kind_of
|
244
|
+
assert_kind_of OrderInfoResponse, response
|
246
245
|
end
|
247
246
|
|
248
247
|
def test_send_smart_report_request
|
@@ -23,17 +23,12 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
|
|
23
23
|
assert_equal 'UDIAuthToken', request.udi_parameters[0].key
|
24
24
|
assert_equal @config['udi_auth_token'], request.udi_parameters[0].value
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def test_send_purchase_order_update_request
|
28
28
|
@connection.stubs(:post).returns(xml_for('PurchaseOrderUpdateResponse(1.00)',200))
|
29
|
-
request = PurchaseOrderUpdateRequest.new
|
30
|
-
|
31
|
-
# TODO why is this necessary
|
32
|
-
l1 = RubyOmx::LineItem.new(:item_code=>'WATCH-1', :quantity=>1, :price=>122.50)
|
33
|
-
l2 = RubyOmx::LineItem.new(:item_code=>'APPLE-12', :quantity=>31, :price=>1.50)
|
34
29
|
|
35
|
-
po_data = { :po_number => '16651',
|
36
|
-
:line_items => [
|
30
|
+
po_data = { :po_number => '16651', # actually would not have both po number and supplier id
|
31
|
+
:line_items => [@line1, @line2],
|
37
32
|
:supplier_id => '76'
|
38
33
|
}
|
39
34
|
r = @connection.build_purchase_order_update_request(po_data)
|
@@ -42,7 +37,7 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
|
|
42
37
|
# Missing Order Options
|
43
38
|
begin
|
44
39
|
response = @connection.send_purchase_order_update_request({})
|
45
|
-
rescue
|
40
|
+
rescue MissingRequestOptions
|
46
41
|
end
|
47
42
|
|
48
43
|
response = @connection.send_purchase_order_update_request(po_data)
|
@@ -61,4 +56,5 @@ class PurchaseOrdersTest < MiniTest::Unit::TestCase
|
|
61
56
|
assert_kind_of PurchaseOrderUpdateResponse, response
|
62
57
|
assert_equal '16651', response.po_number
|
63
58
|
end
|
59
|
+
|
64
60
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
real:
|
2
|
+
http_biz_id: KbmCrvnukGKUosDSTVhWbhrYBlggjNYxGqsujuglguAJhXeKBYDdpwyiRcywvmiUrpHilblPqKgiPAOIfxOfvFOmZLUiNuIfeDrKJxvjeeblkhphUhgPixbvaCJADgIfaDjHWFHXePIFchOjQciNRdrephpJFEfGoUaSFAOcjHmhfgZidlmUsCBdXgmmxIBKhgRjxjJaTcrnCgSkghRWvRwjZgVeVvhHqALceQpdJLphwDlfFXgIHYjCGjCiwZW
|
3
|
+
udi_auth_token: 7509fd470db4004809083c0048ef983102d6325b27730421704c1b0899109ab51de58e4dfd80acff062f8042360b5ae01ed4851f50a5d5fe38a10e81c0471a089f20799ddf11c81cc541a10a014fe04e190aee6049efdf97699096bd79db0a9fd04ca90b2a90f63925c223d236fbe97b047c104b900b7e1010fbb39453e0920
|
4
|
+
|
5
|
+
real_alt:
|
6
|
+
http_biz_id: KbmCrvnukGKUosDSTVhWbhrYBlggjNYxGqsujuglguAJhXeKBYDdpwyiRcywvmiUrpHilblPqKgiPAOIfxOfvFOmZLUiNuIfeDrKJxvjeeblkhphUhgPixbvaCJADgIfaDjHWFHXePIFchOjQciNRdrephpJFEfGoUaSFAOcjHmhfgZidlmUsCBdXgmmxIBKhgRjxjJaTcrnCgSkghRWvRwjZgVeVvhHqALceQpdJLphwDlfFXgIHYjCGjCiwZW
|
7
|
+
udi_auth_token: 7509fd470db4004809083c0048ef983102d6325b27730421704c1b0899109ab51de58e4dfd80acff062f8042360b5ae01ed4851f50a5d5fe38a10e81c0471a089f20799ddf11c81cc541a10a014fe04e190aee6049efdf97699096bd79db0a9fd04ca90b2a90f63925c223d236fbe97b047c104b900b7e1010fbb39453e0920
|
8
|
+
server: https://api.omx.ordermotion.com/OM2/udi.ashx
|