ruby_omx 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby_omx/memos.rb +17 -0
- data/lib/ruby_omx/purchase_orders.rb +0 -2
- data/lib/ruby_omx/response/memo_submission_request.rb +33 -0
- data/lib/ruby_omx/response/memo_submission_response.rb +11 -0
- data/lib/ruby_omx/response/order_info_response.rb +1 -0
- data/lib/ruby_omx/version.rb +1 -1
- data/lib/ruby_omx.rb +2 -0
- data/test/memos_test.rb +45 -0
- data/test/orders_test.rb +2 -1
- metadata +6 -1
@@ -0,0 +1,17 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
module Memos
|
3
|
+
|
4
|
+
def build_memo_submission_request(params={})
|
5
|
+
MemoSubmissionRequest.new(params.merge({:udi_auth_token=>@udi_auth_token, :http_biz_id=>@http_biz_id}))
|
6
|
+
end
|
7
|
+
|
8
|
+
def send_memo_submission_request(params={})
|
9
|
+
request = build_memo_submission_request(params)
|
10
|
+
response = post(request.to_xml.to_s)
|
11
|
+
return response if request.raw_xml==true || request.raw_xml==1
|
12
|
+
MemoSubmissionResponse.format(response)
|
13
|
+
end
|
14
|
+
alias_method :send_memo, :send_memo_submission_request
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module RubyOmx
|
2
|
+
|
3
|
+
class MemoSubmissionRequest < Response
|
4
|
+
def initialize(a=nil)
|
5
|
+
return super unless a.present? # bail if no array of options has been given
|
6
|
+
http_biz_id = a.delete(:http_biz_id)
|
7
|
+
udi_auth_token = a.delete(:udi_auth_token)
|
8
|
+
|
9
|
+
self.version = a[:version] ||= '1.00'
|
10
|
+
super
|
11
|
+
|
12
|
+
self.udi_parameters = []
|
13
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token})
|
14
|
+
self.udi_parameters << RubyOmx::UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id})
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_accessor :order_number, :order_id, :store_code, :raw_xml
|
18
|
+
|
19
|
+
xml_name "MemoSubmissionRequest"
|
20
|
+
xml_accessor :version, :from => '@version'
|
21
|
+
xml_accessor :udi_parameters, :as => [RubyOmx::UDIParameter], :in => 'UDIParameter'
|
22
|
+
|
23
|
+
xml_accessor :lead_number, :in=>'Memo'
|
24
|
+
xml_accessor :customer_number, :in=>'Memo'
|
25
|
+
xml_accessor :order_number, :in=>'Memo'
|
26
|
+
xml_accessor :shipment_number, :in=>'Memo'
|
27
|
+
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.
|
28
|
+
xml_accessor :memo_type, :in=>'Memo', :as=>Integer
|
29
|
+
xml_accessor :memo_text, :in=>'Memo'
|
30
|
+
xml_accessor :memo_transmission_date, :in=>'Memo', :as=>DateTime
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#OrderInformationRequest (OIR200) This request type provides the ShippingInformationRequest (SIR) result for the order as a whole.
|
2
|
+
|
3
|
+
module RubyOmx
|
4
|
+
|
5
|
+
class MemoSubmissionResponse < Response
|
6
|
+
xml_name "MemoSubmissionResponse"
|
7
|
+
xml_reader :success
|
8
|
+
xml_accessor :errors, :as=>[RubyOmx::ErrorData], :in=>'ErrorData'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -55,6 +55,7 @@ module RubyOmx
|
|
55
55
|
#xml_reader :shipping_information, :as=>OrderInfoShippingInfo
|
56
56
|
xml_reader :line_items, :as => [OrderInfoLineItem], :in=>'OrderDetail'
|
57
57
|
|
58
|
+
xml_reader :customer_number, :from=>'@number', :in=>'Customer'
|
58
59
|
xml_reader :tracking_number, :in=>'ShippingInformation/Shipment'
|
59
60
|
xml_reader :ship_date, :in=>'ShippingInformation/Shipment',:as=>DateTime # if populated, it means all items have shipped
|
60
61
|
end
|
data/lib/ruby_omx/version.rb
CHANGED
data/lib/ruby_omx.rb
CHANGED
@@ -33,6 +33,7 @@ require 'ruby_omx/response'
|
|
33
33
|
require 'ruby_omx/orders'
|
34
34
|
require 'ruby_omx/items'
|
35
35
|
require 'ruby_omx/purchase_orders'
|
36
|
+
require 'ruby_omx/memos'
|
36
37
|
Dir.glob(File.join(File.dirname(__FILE__), 'ruby_omx/response/*.rb')).each {|f| require f }
|
37
38
|
|
38
39
|
require 'ruby_omx/base'
|
@@ -44,4 +45,5 @@ RubyOmx::Base.class_eval do
|
|
44
45
|
include RubyOmx::Orders
|
45
46
|
include RubyOmx::Items
|
46
47
|
include RubyOmx::PurchaseOrders
|
48
|
+
include RubyOmx::Memos
|
47
49
|
end
|
data/test/memos_test.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MemosTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
|
6
|
+
@connection = RubyOmx::Base.new(@config)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_request_from_xml
|
10
|
+
request = RubyOmx::MemoSubmissionRequest.format(xml_for('MemoSubmissionRequest(1.00)',200))
|
11
|
+
assert_equal '1.00', request.version
|
12
|
+
assert_equal '949538', request.order_number
|
13
|
+
assert_equal 'Test Memo', request.memo_text
|
14
|
+
assert_equal DateTime.parse('2003-04-01 22:15:10'), request.reminder_date
|
15
|
+
assert_equal DateTime.parse('2003-03-01 22:15:10'), request.memo_transmission_date
|
16
|
+
|
17
|
+
assert_equal 'UDIAuthToken', request.udi_parameters[0].key
|
18
|
+
assert_equal @config['udi_auth_token'], request.udi_parameters[0].value
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_send_memo_submission_request
|
22
|
+
@connection.stubs(:post).returns(xml_for('MemoSubmissionResponse(1.00)',200))
|
23
|
+
request = MemoSubmissionRequest.new
|
24
|
+
|
25
|
+
memo_data = { :order_number => '949538',
|
26
|
+
:memo_text=>'Test Memo',
|
27
|
+
:reminder_date=>Time.now + 1.month,
|
28
|
+
:memo_transmission_date=>Time.now }
|
29
|
+
|
30
|
+
r = @connection.build_memo_submission_request(memo_data)
|
31
|
+
assert_instance_of String, r.to_xml.to_s
|
32
|
+
|
33
|
+
response = @connection.send_memo_submission_request(memo_data)
|
34
|
+
assert_kind_of MemoSubmissionResponse, response
|
35
|
+
assert_equal '1', response.success
|
36
|
+
assert_kind_of Hash, response.as_hash
|
37
|
+
|
38
|
+
response = @connection.send_memo_submission_request(memo_data.merge({:raw_xml => true}))
|
39
|
+
assert_kind_of Net::HTTPOK, response
|
40
|
+
|
41
|
+
# old alias should still work
|
42
|
+
response = @connection.send_memo(memo_data)
|
43
|
+
assert_kind_of MemoSubmissionResponse, response
|
44
|
+
end
|
45
|
+
end
|
data/test/orders_test.rb
CHANGED
@@ -194,6 +194,7 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
194
194
|
assert !response.accessors.include?("code")
|
195
195
|
|
196
196
|
assert_equal DateTime.parse('2006-02-09 14:47:00'), response.ship_date
|
197
|
+
assert_equal '11229', response.customer_number
|
197
198
|
assert_equal "", response.tracking_number
|
198
199
|
assert_equal '16651', response.order_header.order_number
|
199
200
|
assert_equal DateTime.parse('2005-06-20 14:25:00'), response.order_header.order_date
|
@@ -224,7 +225,7 @@ class OrdersTest < MiniTest::Unit::TestCase
|
|
224
225
|
assert_equal DateTime.parse('2010-05-31 05:36:00'), response.order_header.order_status_date
|
225
226
|
assert_equal '4', response.order_header.order_status_code
|
226
227
|
|
227
|
-
|
228
|
+
assert_equal '11552', response.customer_number
|
228
229
|
assert_equal 2, response.line_items.length
|
229
230
|
assert_equal '24603-0', response.line_items[0].shipment_number
|
230
231
|
assert_equal 10, response.line_items[0].line_cogs
|
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.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -70,10 +70,13 @@ files:
|
|
70
70
|
- lib/ruby_omx/connection.rb
|
71
71
|
- lib/ruby_omx/exceptions.rb
|
72
72
|
- lib/ruby_omx/items.rb
|
73
|
+
- lib/ruby_omx/memos.rb
|
73
74
|
- lib/ruby_omx/orders.rb
|
74
75
|
- lib/ruby_omx/purchase_orders.rb
|
75
76
|
- lib/ruby_omx/response/custom_item_attr_info_response.rb
|
76
77
|
- lib/ruby_omx/response/item_info_response.rb
|
78
|
+
- lib/ruby_omx/response/memo_submission_request.rb
|
79
|
+
- lib/ruby_omx/response/memo_submission_response.rb
|
77
80
|
- lib/ruby_omx/response/order_info_request.rb
|
78
81
|
- lib/ruby_omx/response/order_info_response.rb
|
79
82
|
- lib/ruby_omx/response/purchase_order_update_request.rb
|
@@ -90,6 +93,7 @@ files:
|
|
90
93
|
- README.rdoc
|
91
94
|
- test/base_test.rb
|
92
95
|
- test/items_test.rb
|
96
|
+
- test/memos_test.rb
|
93
97
|
- test/orders_test.rb
|
94
98
|
- test/purchase_orders_test.rb
|
95
99
|
- test/test_config.yml
|
@@ -121,6 +125,7 @@ summary: Ruby wrapper for OrderMotion (OMX)
|
|
121
125
|
test_files:
|
122
126
|
- test/base_test.rb
|
123
127
|
- test/items_test.rb
|
128
|
+
- test/memos_test.rb
|
124
129
|
- test/orders_test.rb
|
125
130
|
- test/purchase_orders_test.rb
|
126
131
|
- test/test_config.yml
|