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
data/lib/ruby_omx/base.rb
CHANGED
@@ -5,30 +5,14 @@ module RubyOmx
|
|
5
5
|
class Base
|
6
6
|
attr_accessor :connection
|
7
7
|
|
8
|
-
#def self.debug; @@debug ||= false end
|
9
|
-
#def self.debug=(bool); @@debug = bool end
|
10
|
-
|
11
8
|
def initialize(options ={})
|
12
9
|
@http_biz_id = options['http_biz_id']
|
13
10
|
@udi_auth_token = options['udi_auth_token']
|
14
11
|
raise RubyOmx::MissingAccessKey.new(['udi auth token', 'http biz id']) unless @udi_auth_token && @http_biz_id
|
15
12
|
@connection = RubyOmx::Connection.connect(options)
|
16
13
|
end
|
17
|
-
|
18
|
-
def connection
|
19
|
-
raise RubyOmx::NoConnectionEstablished.new if !connected?
|
20
|
-
@connection
|
21
|
-
end
|
22
14
|
|
23
|
-
#def connected?
|
24
|
-
# !@connection.nil?
|
25
|
-
#end
|
26
15
|
|
27
|
-
#def disconnect
|
28
|
-
# @connection.http.finish if @connection.persistent?
|
29
|
-
# @connection = nil
|
30
|
-
#end
|
31
|
-
|
32
16
|
# Wraps the current connection's request method and picks the appropriate response class to wrap the response in.
|
33
17
|
# If the response is an error, it will raise that error as an exception. All such exceptions can be caught by rescuing
|
34
18
|
# their superclass, the ResponseError exception class.
|
@@ -38,7 +22,7 @@ module RubyOmx
|
|
38
22
|
def request(verb, body = nil, attempts = 0, &block)
|
39
23
|
# Find the connection method in connection/management.rb which is evaled into Amazon::MWS::Base
|
40
24
|
response = @connection.request(verb, body, attempts, &block)
|
41
|
-
|
25
|
+
|
42
26
|
# Each calling class is responsible for formatting the result
|
43
27
|
return response
|
44
28
|
rescue InternalError, RequestTimeout
|
@@ -49,7 +33,7 @@ module RubyOmx
|
|
49
33
|
retry
|
50
34
|
end
|
51
35
|
end
|
52
|
-
|
36
|
+
|
53
37
|
# Make some convenience methods
|
54
38
|
[:get, :post, :put, :delete, :head].each do |verb|
|
55
39
|
class_eval(<<-EVAL, __FILE__, __LINE__)
|
@@ -58,5 +42,6 @@ module RubyOmx
|
|
58
42
|
end
|
59
43
|
EVAL
|
60
44
|
end
|
45
|
+
|
61
46
|
end
|
62
47
|
end
|
data/lib/ruby_omx/connection.rb
CHANGED
@@ -2,9 +2,7 @@ module RubyOmx
|
|
2
2
|
|
3
3
|
class Connection
|
4
4
|
|
5
|
-
def self.connect(options = {})
|
6
|
-
new(options)
|
7
|
-
end
|
5
|
+
def self.connect(options = {}); new(options) end
|
8
6
|
|
9
7
|
def initialize(params = {})
|
10
8
|
|
@@ -26,7 +24,7 @@ module RubyOmx
|
|
26
24
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
27
25
|
return http
|
28
26
|
end
|
29
|
-
|
27
|
+
|
30
28
|
# Make the request, based on the appropriate request object
|
31
29
|
# Called from RubyOmx::Base
|
32
30
|
def request(verb, body = nil, attempts = 0, &block)
|
@@ -40,7 +38,7 @@ module RubyOmx
|
|
40
38
|
@http = connect
|
41
39
|
attempts == 3 ? raise : (attempts += 1; retry)
|
42
40
|
end
|
43
|
-
|
41
|
+
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
data/lib/ruby_omx/exceptions.rb
CHANGED
@@ -7,52 +7,14 @@ module RubyOmx
|
|
7
7
|
# Abstract super class for all invalid options.
|
8
8
|
class InvalidOption < RubyOmxException
|
9
9
|
end
|
10
|
-
|
11
|
-
#class InvalidMessageType < RubyOmxException
|
12
|
-
#end
|
13
|
-
|
14
|
-
#class InvalidReportType < RubyOmxException
|
15
|
-
#end
|
16
|
-
|
17
|
-
#class InvalidSchedule < RubyOmxException
|
18
|
-
#end
|
19
|
-
|
20
|
-
class MissingConnectionOptions < RubyOmxException
|
21
|
-
end
|
22
10
|
|
23
|
-
class
|
11
|
+
class MissingRequestOptions < RubyOmxException
|
24
12
|
end
|
25
|
-
|
26
|
-
class MissingPurchaseOrderOptions < RubyOmxException
|
27
|
-
end
|
28
|
-
|
29
13
|
|
30
|
-
class MissingItemOptions < RubyOmxException
|
31
|
-
end
|
32
|
-
|
33
|
-
# All responses with a code between 300 and 599 that contain an <Error></Error> body are wrapped in an
|
34
|
-
# ErrorResponse which contains an Error object. This Error class generates a custom exception with the name
|
35
|
-
# of the xml Error and its message. All such runtime generated exception classes descend from ResponseError
|
36
|
-
# and contain the ErrorResponse object so that all code that makes a request can rescue ResponseError and get
|
37
|
-
# access to the ErrorResponse.
|
38
|
-
# class ResponseError < RubyOmxException
|
39
|
-
# def initialize(formatted_response)
|
40
|
-
# instance_eval(<<-EVAL, __FILE__, __LINE__)
|
41
|
-
# def request_id
|
42
|
-
# '#{formatted_response["RequestID"]}'
|
43
|
-
# end
|
44
|
-
# EVAL
|
45
|
-
#
|
46
|
-
# formatted_response["Error"].each do |key, value|
|
47
|
-
# instance_eval(<<-EVAL, __FILE__, __LINE__)
|
48
|
-
# def #{key.underscore}
|
49
|
-
# '#{value}'
|
50
|
-
# end
|
51
|
-
# EVAL
|
52
|
-
# end
|
53
|
-
# end
|
54
|
-
# end
|
55
14
|
|
15
|
+
class MissingConnectionOptions < RubyOmxException
|
16
|
+
end
|
17
|
+
|
56
18
|
class RequestTimeout < ResponseError
|
57
19
|
end
|
58
20
|
|
@@ -62,13 +24,13 @@ module RubyOmx
|
|
62
24
|
end
|
63
25
|
|
64
26
|
# Raised if an unrecognized option is passed when establishing a connection.
|
65
|
-
class InvalidConnectionOption < InvalidOption
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
27
|
+
#class InvalidConnectionOption < InvalidOption
|
28
|
+
# def initialize(invalid_options)
|
29
|
+
# message = "The following connection options are invalid: #{invalid_options.join(', ')}. " +
|
30
|
+
# "The valid connection options are: #{Connection::Options::VALID_OPTIONS.join(', ')}."
|
31
|
+
# super(message)
|
32
|
+
# end
|
33
|
+
#end
|
72
34
|
|
73
35
|
# Raised if the access key arguments are missing when establishing a connection.
|
74
36
|
class MissingAccessKey < InvalidOption
|
@@ -79,10 +41,10 @@ module RubyOmx
|
|
79
41
|
end
|
80
42
|
|
81
43
|
# Raised if a request is attempted before any connections have been established.
|
82
|
-
class NoConnectionEstablished < RubyOmxException
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
44
|
+
#class NoConnectionEstablished < RubyOmxException
|
45
|
+
# def initialize
|
46
|
+
# super("\nPlease use RubyOmx::Base.establish_connection! before making API calls.")
|
47
|
+
# end
|
48
|
+
#end
|
87
49
|
|
88
50
|
end
|
data/lib/ruby_omx/items.rb
CHANGED
@@ -2,65 +2,41 @@ 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
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
]
|
9
|
-
raise MissingItemOptions if required_fields.any? {|option| option.nil?}
|
10
|
-
item_code = params[:item_code]
|
11
|
-
raw_xml = params[:raw_xml] ||= false
|
12
|
-
|
13
|
-
doc = Nokogiri::XML::Document.new
|
14
|
-
root_tag = RubyOmx.add_child_helper(doc,'ItemInformationRequest','version','1.00',nil)
|
15
|
-
udi_parameter = RubyOmx.add_child_helper(root_tag,'UDIParameter',nil,nil,nil)
|
16
|
-
RubyOmx.add_child_helper(udi_parameter,'Parameter','key','HTTPBizID',@http_biz_id)
|
17
|
-
RubyOmx.add_child_helper(udi_parameter,'Parameter','key','ItemCode',item_code)
|
18
|
-
RubyOmx.add_child_helper(udi_parameter,'Parameter','key','OutputSubItemAttributes','True')
|
19
|
-
response = post(doc.to_xml)
|
20
|
-
if raw_xml==true || raw_xml==1
|
21
|
-
return response
|
22
|
-
else
|
23
|
-
ItemInformationResponse.format(response)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
5
|
+
def build_item_info_request(attrs={})
|
6
|
+
ItemInfoRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
|
7
|
+
end
|
27
8
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
raw_xml = params[:raw_xml] ||= false
|
9
|
+
def send_item_info_request(attrs={})
|
10
|
+
request = build_item_info_request(attrs)
|
11
|
+
response = post(request.to_xml.to_s)
|
12
|
+
return response if request.raw_xml==true || request.raw_xml==1
|
13
|
+
ItemInfoResponse.format(response)
|
14
|
+
end
|
15
|
+
alias_method :get_item_info, :send_item_info_request
|
36
16
|
|
37
|
-
|
38
|
-
|
39
|
-
udi_parameter = RubyOmx.add_child_helper(root_tag,'UDIParameter',nil,nil,nil)
|
40
|
-
RubyOmx.add_child_helper(udi_parameter,'Parameter','key','HTTPBizID',@http_biz_id)
|
41
|
-
RubyOmx.add_child_helper(udi_parameter,'Parameter','key','ItemCode',item_code)
|
42
|
-
RubyOmx.add_child_helper(udi_parameter,'Parameter','key','AttributeGroupID','All')
|
43
|
-
response = post(doc.to_xml)
|
44
|
-
if raw_xml==true || raw_xml==1
|
45
|
-
return response
|
46
|
-
else
|
47
|
-
CustomItemAttributeInformationResponse.format(response)
|
48
|
-
end
|
17
|
+
def build_custom_item_info_request(attrs={})
|
18
|
+
CustomItemInfoRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
|
49
19
|
end
|
50
20
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
21
|
+
def send_custom_item_info_request(attrs={})
|
22
|
+
request = build_custom_item_info_request(attrs)
|
23
|
+
response = post(request.to_xml.to_s)
|
24
|
+
return response if request.raw_xml==true || request.raw_xml==1
|
25
|
+
CustomItemInfoResponse.format(response)
|
26
|
+
end
|
27
|
+
alias_method :get_custom_item_info, :send_custom_item_info_request
|
28
|
+
|
29
|
+
def build_item_update_request(attrs={})
|
30
|
+
ItemUpdateRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
|
31
|
+
end
|
32
|
+
|
33
|
+
def send_item_update_request(attrs={})
|
34
|
+
request = build_item_update_request(attrs)
|
35
|
+
response = post(request.to_xml.to_s)
|
36
|
+
return response if request.raw_xml==true || request.raw_xml==1
|
37
|
+
ItemUpdateResponse.format(response)
|
38
|
+
end
|
39
|
+
alias_method :append_item, :send_item_update_request
|
40
|
+
|
65
41
|
end
|
66
42
|
end
|
data/lib/ruby_omx/memos.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module RubyOmx
|
2
2
|
module Memos
|
3
3
|
|
4
|
-
def build_memo_submission_request(
|
5
|
-
MemoSubmissionRequest.new(
|
4
|
+
def build_memo_submission_request(attrs={})
|
5
|
+
MemoSubmissionRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
|
6
6
|
end
|
7
7
|
|
8
|
-
def send_memo_submission_request(
|
9
|
-
request = build_memo_submission_request(
|
8
|
+
def send_memo_submission_request(attrs={})
|
9
|
+
request = build_memo_submission_request(attrs)
|
10
10
|
response = post(request.to_xml.to_s)
|
11
11
|
return response if request.raw_xml==true || request.raw_xml==1
|
12
12
|
MemoSubmissionResponse.format(response)
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
# Base class for request and response classes, which implement XML mapping via ROXML
|
4
|
+
class Node
|
5
|
+
include ROXML
|
6
|
+
xml_convention :camelcase
|
7
|
+
|
8
|
+
def initialize(attrs={})
|
9
|
+
attrs.map { |(k, v)| send("#{k}=", v) } if attrs.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
def accessors
|
13
|
+
roxml_references.map {|r| r.accessor}
|
14
|
+
end
|
15
|
+
|
16
|
+
# render a ROXML node as a normal hash, eliminating the @ and some unneeded admin fields
|
17
|
+
def as_hash
|
18
|
+
obj_hash = {}
|
19
|
+
self.instance_variables.each do |v|
|
20
|
+
m = v.to_s.sub('@','')
|
21
|
+
if m != 'roxml_references' && m!= 'promotion_ids'
|
22
|
+
obj_hash[m.to_sym] = self.instance_variable_get(v)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
return obj_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/ruby_omx/orders.rb
CHANGED
@@ -3,37 +3,37 @@ module RubyOmx
|
|
3
3
|
|
4
4
|
# Universal Direct Order Appending (UDOA)
|
5
5
|
|
6
|
-
def build_udoa_request(
|
7
|
-
UDOARequest.new(
|
6
|
+
def build_udoa_request(attrs={})
|
7
|
+
UDOARequest.new(attrs.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token}))
|
8
8
|
end
|
9
9
|
|
10
|
-
def send_udoa_request(
|
11
|
-
request = build_udoa_request(
|
10
|
+
def send_udoa_request(attrs={})
|
11
|
+
request = build_udoa_request(attrs)
|
12
12
|
response = post(request.to_xml.to_s)
|
13
13
|
return response if request.raw_xml==true || request.raw_xml==1
|
14
|
-
UDOAResponse.format(response)
|
14
|
+
UDOAResponse.format(response)
|
15
15
|
end
|
16
16
|
alias_method :append_order, :send_udoa_request
|
17
17
|
|
18
18
|
|
19
19
|
# Order Information
|
20
20
|
|
21
|
-
def build_info_request(
|
22
|
-
|
21
|
+
def build_info_request(attrs={})
|
22
|
+
OrderInfoRequest.new(attrs.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token}))
|
23
23
|
end
|
24
24
|
|
25
|
-
def send_info_request(
|
26
|
-
|
25
|
+
def send_info_request(attrs={})
|
26
|
+
@connection = RubyOmx::Connection.connect({ "http_biz_id" => @http_biz_id, "udi_auth_token" => @udi_auth_token, "server"=>ALT_HOST })
|
27
|
+
request = build_info_request(attrs)
|
27
28
|
response = post(request.to_xml.to_s)
|
28
29
|
return response if request.raw_xml==true || request.raw_xml==1
|
29
|
-
|
30
|
+
OrderInfoResponse.format(response)
|
30
31
|
end
|
31
32
|
|
32
33
|
|
33
34
|
# Smart Report Information
|
34
|
-
|
35
|
-
|
36
|
-
schedule_id = params[:schedule_id] ||= 1
|
35
|
+
def send_smart_report_request(attrs={})
|
36
|
+
schedule_id = attrs[:schedule_id] ||= 1
|
37
37
|
response = get("https://omx.ordermotion.com/en/net/SmartReports.aspx?HTTPBizID=#{@http_biz_id}&ScheduleID=#{schedule_id}")
|
38
38
|
SmartReportResponse.format(response)
|
39
39
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module RubyOmx
|
2
2
|
module PurchaseOrders
|
3
3
|
|
4
|
-
def build_purchase_order_update_request(
|
5
|
-
PurchaseOrderUpdateRequest.new(
|
4
|
+
def build_purchase_order_update_request(attrs={})
|
5
|
+
PurchaseOrderUpdateRequest.new(attrs.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
|
6
6
|
end
|
7
7
|
|
8
|
-
def send_purchase_order_update_request(
|
9
|
-
|
8
|
+
def send_purchase_order_update_request(attrs={})
|
9
|
+
@connection = RubyOmx::Connection.connect({ "http_biz_id" => @http_biz_id, "udi_auth_token" => @udi_auth_token, "server"=>ALT_HOST })
|
10
|
+
request = build_purchase_order_update_request(attrs)
|
10
11
|
response = post(request.to_xml.to_s)
|
11
12
|
return response if request.raw_xml==true || request.raw_xml==1
|
12
13
|
PurchaseOrderUpdateResponse.format(response)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class CustomItemInfoRequest < Request
|
4
|
+
|
5
|
+
def initialize(attrs={})
|
6
|
+
return super unless attrs.any?
|
7
|
+
raise MissingRequestOptions if attrs[:item_code].nil?
|
8
|
+
super
|
9
|
+
self.version = attrs[:version] ||= '2.00'
|
10
|
+
self.udi_parameters << UDIParameter.new({:key=>'ItemCode', :value=>attrs[:item_code]})
|
11
|
+
self.udi_parameters << UDIParameter.new({:key=>'AttributeGroupID', :value=>(attrs[:attribute_group_id]||='All')})
|
12
|
+
|
13
|
+
end
|
14
|
+
attr_accessor :item_code, :attribute_group_id
|
15
|
+
xml_name "CustomItemAttributeInformationRequest"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class ItemInfoRequest < Request
|
4
|
+
|
5
|
+
def initialize(attrs={})
|
6
|
+
return super unless attrs.any?
|
7
|
+
raise MissingRequestOptions if attrs[:item_code].nil?
|
8
|
+
super
|
9
|
+
self.version = attrs[:version] ||= '1.00'
|
10
|
+
self.udi_parameters << UDIParameter.new({:key=>'ItemCode', :value=>attrs[:item_code]})
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_accessor :item_code
|
14
|
+
xml_name "ItemInformationRequest"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class ItemUpdateItem < Node
|
4
|
+
xml_accessor :item_code #<ItemCode>APPLE</ItemCode>
|
5
|
+
xml_accessor :product_status #<ProductStatus>True</ProductStatus>
|
6
|
+
xml_accessor :incomplete_flag #<IncompleteFlag>True</IncompleteFlag>
|
7
|
+
xml_accessor :product_name #<ProductName>Deluxe Princess Fiona™ Child</ProductName>
|
8
|
+
xml_accessor :product_group, :as=>Integer #<ProductGroup>45</ProductGroup>
|
9
|
+
xml_accessor :cost_of_goods, :as=>Float #<CostOfGoods>10</CostOfGoods>
|
10
|
+
xml_accessor :upc_code, :from=>'UPCCode' #<UPCCode></UPCCode>
|
11
|
+
xml_accessor :accounting_reference #<AccountingReference></AccountingReference>
|
12
|
+
xml_accessor :allow_order_line_info #<AllowOrderLineInfo>True</AllowOrderLineInfo>
|
13
|
+
xml_accessor :launch_date #<LaunchDate>2/23/2006</LaunchDate>
|
14
|
+
xml_accessor :file_sub_code, :as=>Integer #<FileSubCode>20</FileSubCode>
|
15
|
+
xml_accessor :inventory_product_flag #<InventoryProductFlag>True</InventoryProductFlag>
|
16
|
+
xml_accessor :tax_code #<TaxCode>TC4</TaxCode>
|
17
|
+
xml_accessor :inventory_type, :as=>Integer # <InventoryType>3</InventoryType>
|
18
|
+
xml_accessor :drop_ship_file_sub_code, :as=>Integer #<DropShipFileSubCode>31</DropShipFileSubCode>
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class ItemUpdateRequest < Request
|
23
|
+
|
24
|
+
def initialize(attrs={})
|
25
|
+
return super unless attrs.any?
|
26
|
+
required_fields = [:items] #:item_code, :product_status, :product_name, :product_group, :tax_code, :file_sub_code, :inventory_product_flag, :launch_date
|
27
|
+
raise MissingRequestOptions if required_fields.any? { |option| attrs[option].nil? }
|
28
|
+
super
|
29
|
+
self.version = attrs[:version] ||= '2.00'
|
30
|
+
self.items = attrs[:items].collect { |h| ItemUpdateItem.new(h) }
|
31
|
+
end
|
32
|
+
|
33
|
+
xml_name "ItemUpdateRequest"
|
34
|
+
xml_accessor :items, :as=>[ItemUpdateItem], :in=>'Items'
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class MemoSubmissionRequest < Request
|
4
|
+
def initialize(a={})
|
5
|
+
super
|
6
|
+
self.version = a[:version] ||= '1.00'
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_accessor :order_number, :order_id, :store_code
|
10
|
+
|
11
|
+
xml_name "MemoSubmissionRequest"
|
12
|
+
xml_accessor :lead_number, :in=>'Memo'
|
13
|
+
xml_accessor :customer_number, :in=>'Memo'
|
14
|
+
xml_accessor :order_number, :in=>'Memo'
|
15
|
+
xml_accessor :shipment_number, :in=>'Memo'
|
16
|
+
xml_accessor :reminder_date, :in=>'Memo', :as=>DateTime # Dates are almost the same as the W3C Schema "date" type, but with a space instead of the "T" separating the date from the time.
|
17
|
+
xml_accessor :memo_type, :in=>'Memo', :as=>Integer
|
18
|
+
xml_accessor :memo_text, :in=>'Memo'
|
19
|
+
xml_accessor :memo_transmission_date, :in=>'Memo', :as=>DateTime
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class OrderInfoRequest < Request
|
4
|
+
|
5
|
+
def initialize(attrs={})
|
6
|
+
return super unless attrs.any?
|
7
|
+
|
8
|
+
# Require either an order number or a store code and an order id to locate the order
|
9
|
+
raise MissingRequestOptions if attrs[:order_number].nil? && (attrs[:store_code].nil? || attrs[:order_id].nil?)
|
10
|
+
super
|
11
|
+
self.version = attrs[:version] ||= '1.00'
|
12
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'OrderNumber', :value=>attrs[:order_number]}) if attrs[:order_number]
|
13
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'OrderID', :value=>attrs[:order_id]}) if attrs[:order_id]
|
14
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'StoreCode', :value=>attrs[:store_code]}) if attrs[:store_code]
|
15
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'level', :value=>attrs[:level] ||=2 })
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_accessor :order_number, :order_id, :store_code
|
19
|
+
|
20
|
+
xml_name "OrderInformationRequest"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class PurchaseOrderUpdateRequest < Request
|
4
|
+
|
5
|
+
def initialize(attrs={})
|
6
|
+
return super unless attrs.any?
|
7
|
+
raise MissingRequestOptions if attrs[:po_number].nil? && attrs[:supplier_id].nil?
|
8
|
+
super
|
9
|
+
self.version = attrs[:version] ||= '1.00'
|
10
|
+
|
11
|
+
# Instantiate LineItem variables for each
|
12
|
+
self.line_items = attrs[:line_items].collect { |h| LineItem.new(h) }
|
13
|
+
end
|
14
|
+
|
15
|
+
xml_name "PurchaseOrderUpdateRequest"
|
16
|
+
xml_accessor :po_number, :from=>'@PONumber', :in=>'PurchaseOrder' #<PurchaseOrder PONumber="16651" supplierID="76">
|
17
|
+
xml_accessor :supplier_id, :from=>'@supplierID', :in=>'PurchaseOrder'
|
18
|
+
xml_accessor :cross_reference #<CrossReference>PO 12345</CrossReference>
|
19
|
+
xml_accessor :line_items, :as => [RubyOmx::LineItem], :in => 'PurchaseOrder/LineDetail'
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class Address < Node
|
4
|
+
xml_name "Address"
|
5
|
+
xml_accessor :address_type, :from => '@type'
|
6
|
+
xml_accessor :title_code, :company, :firstname, :lastname, :address1, :address2, :city, :state, :phone_number, :email
|
7
|
+
xml_accessor :zip, :from => 'ZIP'
|
8
|
+
xml_accessor :tld, :from => 'TLD'
|
9
|
+
end
|
10
|
+
|
11
|
+
class CustomField < Node
|
12
|
+
xml_name 'Field'
|
13
|
+
xml_accessor :field_id, :from => '@fieldID'
|
14
|
+
xml_accessor :line_number, :from => '@lineNumber'
|
15
|
+
xml_accessor :value, :from => :content
|
16
|
+
end
|
17
|
+
|
18
|
+
class Flag < Node
|
19
|
+
xml_name 'Flag'
|
20
|
+
xml_accessor :name, :from => '@name'
|
21
|
+
xml_accessor :value, :from => :content
|
22
|
+
end
|
23
|
+
|
24
|
+
class UDOARequest < Request
|
25
|
+
def initialize(attrs={})
|
26
|
+
return super unless attrs.any?
|
27
|
+
|
28
|
+
required_fields = [:queue_flag, :verify_flag, :keycode, :order_date, :order_id, :bill_to, :line_items, :method_code]
|
29
|
+
raise MissingRequestOptions if required_fields.any? { |option| attrs[option].nil? }
|
30
|
+
super
|
31
|
+
self.version = attrs[:version] ||= '2.00'
|
32
|
+
self.payment_type = attrs[:payment_type] ||= '6' #6 for open invoice
|
33
|
+
self.origin_type = attrs[:origin_type] ||= '2' # 2 = phone order, 3 = internet order
|
34
|
+
self.udi_parameters << UDIParameter.new({:key=>'Keycode', :value=>attrs[:keycode]})
|
35
|
+
self.udi_parameters << UDIParameter.new({:key=>'VerifyFlag', :value=>attrs[:verify_flag] ||= 'True' }) # Determines whether a successful order should be saved, or only verified/calculated. When set to "True", OrderMotion will behave as if the order was placed, but not return an Order Number in the response.
|
36
|
+
self.udi_parameters << UDIParameter.new({:key=>'QueueFlag', :value=>attrs[:queue_flag] ||= 'False' }) # Determines whether any orders with errors will be stored in the OrderMotion "Outside Order Queue", to be corrected by an OrderMotion user before resubmission. If set to "True", almost all orders will be accepted by OrderMotion, but additional order information will only be returned in the response if the order is successfully placed. Otherwise, any order with any error (eg invalid ZIP code) will be rejected.
|
37
|
+
self.udi_parameters << UDIParameter.new({:key=>'Vendor', :value=>attrs[:vendor] }) if attrs[:vendor].present?
|
38
|
+
self.bill_to = Address.new(attrs[:bill_to])
|
39
|
+
self.ship_to = Address.new(attrs[:ship_to])
|
40
|
+
|
41
|
+
# Instantiate LineItem variables for each
|
42
|
+
i = 0
|
43
|
+
self.line_items = attrs[:line_items].collect { |h|
|
44
|
+
i+=1
|
45
|
+
h[:line_number] = h[:line_number] ||= i # Provide line numbers if they are omitted
|
46
|
+
LineItem.new(h)
|
47
|
+
}
|
48
|
+
|
49
|
+
self.custom_fields = attrs[:custom_fields].collect { |h| CustomField.new(h) } if attrs[:custom_fields].present?
|
50
|
+
self.flags = attrs[:flags].collect { |h| Flag.new(h) } if attrs[:flags].present?
|
51
|
+
end
|
52
|
+
|
53
|
+
attr_accessor :keycode, :queue_flag, :verify_flag, :vendor
|
54
|
+
|
55
|
+
xml_name "UDOARequest"
|
56
|
+
xml_accessor :order_date, :in => 'Header', :as => DateTime # Dates are almost the same as the W3C Schema "date" type, but with a space instead of the "T" separating the date from the time.
|
57
|
+
xml_accessor :order_id, :in => 'Header', :from => 'OrderID'
|
58
|
+
xml_accessor :origin_type, :in => 'Header'
|
59
|
+
xml_accessor :store_code, :in => 'Header'
|
60
|
+
xml_accessor :bill_to, :as => Address, :in => 'Customer'
|
61
|
+
xml_accessor :flags, :as => [Flag], :in => 'Customer/FlagData'
|
62
|
+
xml_accessor :ship_to, :as => Address, :in => 'ShippingInformation'
|
63
|
+
|
64
|
+
xml_accessor :method_code, :in => 'ShippingInformation', :as => Integer
|
65
|
+
xml_accessor :shipping_amount, :in => 'ShippingInformation', :as => Float
|
66
|
+
xml_accessor :handling_amount, :in => 'ShippingInformation', :as => Float
|
67
|
+
xml_accessor :special_instructions, :in => 'ShippingInformation'
|
68
|
+
xml_accessor :gift_wrapping, :in => 'ShippingInformation'
|
69
|
+
xml_accessor :gift_message, :in => 'ShippingInformation'
|
70
|
+
|
71
|
+
xml_accessor :payment_type, :in => 'Payment', :from => '@type'
|
72
|
+
xml_accessor :card_number, :in => 'Payment'
|
73
|
+
xml_accessor :card_verification, :in => 'Payment'
|
74
|
+
xml_accessor :card_exp_date_month, :in => 'Payment'
|
75
|
+
xml_accessor :card_exp_date_year, :in => 'Payment'
|
76
|
+
xml_accessor :card_status, :in => 'Payment'
|
77
|
+
xml_accessor :card_auth_code, :in => 'Payment'
|
78
|
+
xml_accessor :card_transaction_id, :from => 'CardTransactionID', :in => 'Payment'
|
79
|
+
|
80
|
+
xml_accessor :line_items, :as => [LineItem], :in => 'OrderDetail'
|
81
|
+
xml_accessor :custom_fields, :as => [CustomField], :in => 'CustomFields/Report'
|
82
|
+
xml_accessor :total_amount, :in => 'Check'
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
# UDI Parameters are included in every OMX request
|
4
|
+
class UDIParameter < Node
|
5
|
+
xml_name "Parameter"
|
6
|
+
xml_accessor :key, :from => '@key'
|
7
|
+
xml_accessor :value, :from => :content
|
8
|
+
end
|
9
|
+
|
10
|
+
class Request < Response
|
11
|
+
|
12
|
+
def initialize(attrs=nil)
|
13
|
+
self.udi_parameters = [UDIParameter.new({:key=>'UDIAuthToken', :value=>attrs.delete(:udi_auth_token)})]
|
14
|
+
self.udi_parameters << UDIParameter.new({:key=>'HTTPBizID', :value=>attrs.delete(:http_biz_id)})
|
15
|
+
super
|
16
|
+
raw_xml = attrs[:raw_xml] ||= false
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor :raw_xml
|
20
|
+
xml_accessor :udi_parameters, :as => [UDIParameter], :in => 'UDIParameter'
|
21
|
+
xml_accessor :version, :from => '@version'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|