ruby_omx 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,3 +1,4 @@
1
1
  = RubyOmx
2
2
 
3
- This project uses MIT-LICENSE.
3
+ This project uses MIT-LICENSE.
4
+
data/lib/ruby_omx/base.rb CHANGED
@@ -4,14 +4,13 @@ module RubyOmx
4
4
  class Base
5
5
  attr_accessor :connection
6
6
 
7
- def self.debug; @@debug ||= false end
8
- def self.debug=(bool); @@debug = bool end
7
+ #def self.debug; @@debug ||= false end
8
+ #def self.debug=(bool); @@debug = bool end
9
9
 
10
10
  def initialize(options ={})
11
11
  @http_biz_id = options['http_biz_id']
12
12
  @udi_auth_token = options['udi_auth_token']
13
- raise "Must supply udi auth token" unless @udi_auth_token
14
- raise "Must supply http biz ID" unless @http_biz_id
13
+ raise RubyOmx::MissingAccessKey.new(['udi auth token', 'http biz id']) unless @udi_auth_token && @http_biz_id
15
14
  @connection = RubyOmx::Connection.connect(options)
16
15
  end
17
16
 
@@ -20,14 +19,14 @@ module RubyOmx
20
19
  @connection
21
20
  end
22
21
 
23
- def connected?
24
- !@connection.nil?
25
- end
22
+ #def connected?
23
+ # !@connection.nil?
24
+ #end
26
25
 
27
- def disconnect
28
- @connection.http.finish if @connection.persistent?
29
- @connection = nil
30
- end
26
+ #def disconnect
27
+ # @connection.http.finish if @connection.persistent?
28
+ # @connection = nil
29
+ #end
31
30
 
32
31
  # Wraps the current connection's request method and picks the appropriate response class to wrap the response in.
33
32
  # If the response is an error, it will raise that error as an exception. All such exceptions can be caught by rescuing
@@ -1,11 +1,9 @@
1
1
  module RubyOmx
2
2
 
3
3
  class Connection
4
- # Static/Class methods
5
- class << self
6
- def connect(options = {})
7
- new(options)
8
- end
4
+
5
+ def self.connect(options = {})
6
+ new(options)
9
7
  end
10
8
 
11
9
  def initialize(params = {})
@@ -13,7 +11,6 @@ module RubyOmx
13
11
  # These values are essential to establishing a connection
14
12
  @udi_auth_token = params['udi_auth_token']
15
13
  @server = params['server'] || RubyOmx::DEFAULT_HOST + "?UDIAuthToken=#{@udi_auth_token}"
16
- @persistent = params['persistent'] || false
17
14
  @http_biz_id = params['http_biz_id']
18
15
  @path = URI.parse(@server).request_uri
19
16
 
@@ -1,6 +1,6 @@
1
1
  module RubyOmx
2
2
 
3
- # Abstract super class of all Amazon::MWS exceptions
3
+ # Abstract super class of all RubyOmx exceptions
4
4
  class RubyOmxException < StandardError
5
5
  end
6
6
 
@@ -8,14 +8,14 @@ module RubyOmx
8
8
  class InvalidOption < RubyOmxException
9
9
  end
10
10
 
11
- class InvalidMessageType < RubyOmxException
12
- end
11
+ #class InvalidMessageType < RubyOmxException
12
+ #end
13
13
 
14
- class InvalidReportType < RubyOmxException
15
- end
14
+ #class InvalidReportType < RubyOmxException
15
+ #end
16
16
 
17
- class InvalidSchedule < RubyOmxException
18
- end
17
+ #class InvalidSchedule < RubyOmxException
18
+ #end
19
19
 
20
20
  class MissingConnectionOptions < RubyOmxException
21
21
  end
@@ -66,7 +66,7 @@ module RubyOmx
66
66
  end
67
67
  end
68
68
 
69
- # Raised if either the access key id or secret access key arguments are missing when establishing a connection.
69
+ # Raised if the access key arguments are missing when establishing a connection.
70
70
  class MissingAccessKey < InvalidOption
71
71
  def initialize(missing_keys)
72
72
  key_list = missing_keys.map {|key| key.to_s}.join(' and the ')
@@ -77,7 +77,7 @@ module RubyOmx
77
77
  # Raised if a request is attempted before any connections have been established.
78
78
  class NoConnectionEstablished < RubyOmxException
79
79
  def initialize
80
- super("\nPlease use Amazon::MWS::Base.establish_connection! before making API calls.")
80
+ super("\nPlease use RubyOmx::Base.establish_connection! before making API calls.")
81
81
  end
82
82
  end
83
83
 
@@ -6,10 +6,10 @@ module RubyOmx
6
6
  required_fields = [
7
7
  params[:item_code]
8
8
  ]
9
- raise MissingOrderOptions if required_fields.any? {|option| option.nil?}
9
+ raise MissingItemOptions if required_fields.any? {|option| option.nil?}
10
10
  item_code = params[:item_code]
11
- raw_xml = params[:raw_xml] ||= 0
12
-
11
+ raw_xml = params[:raw_xml] ||= false
12
+
13
13
  doc = Nokogiri::XML::Document.new
14
14
  root_tag = RubyOmx.add_child_helper(doc,'ItemInformationRequest','version','1.00',nil)
15
15
  udi_parameter = RubyOmx.add_child_helper(root_tag,'UDIParameter',nil,nil,nil)
@@ -17,22 +17,22 @@ module RubyOmx
17
17
  RubyOmx.add_child_helper(udi_parameter,'Parameter','key','ItemCode',item_code)
18
18
  RubyOmx.add_child_helper(udi_parameter,'Parameter','key','OutputSubItemAttributes','True')
19
19
  response = post(doc.to_xml)
20
- if raw_xml==1
20
+ if raw_xml==true || raw_xml==1
21
21
  return response
22
22
  else
23
- ItemInfoResponse.format(response)
23
+ ItemInformationResponse.format(response)
24
24
  end
25
25
 
26
26
  end
27
27
 
28
28
  #CustomItemAttributeInformationRequest (CIAIR200) This request type lists all the custom item attributes names and values for a given item code or list of item codes, in one or all custom item attribute groups.
29
- def get_custom_item_info(params ={})
29
+ def get_custom_item_attribute_info(params ={})
30
30
  required_fields = [
31
31
  params[:item_code]
32
32
  ]
33
- raise MissingOrderOptions if required_fields.any? {|option| option.nil?}
33
+ raise MissingItemOptions if required_fields.any? {|option| option.nil?}
34
34
  item_code = params[:item_code]
35
- raw_xml = params[:raw_xml] ||= 0
35
+ raw_xml = params[:raw_xml] ||= false
36
36
 
37
37
  doc = Nokogiri::XML::Document.new
38
38
  root_tag = RubyOmx.add_child_helper(doc,'CustomItemAttributeInformationRequest','version','2.00',nil)
@@ -41,10 +41,10 @@ module RubyOmx
41
41
  RubyOmx.add_child_helper(udi_parameter,'Parameter','key','ItemCode',item_code)
42
42
  RubyOmx.add_child_helper(udi_parameter,'Parameter','key','AttributeGroupID','All')
43
43
  response = post(doc.to_xml)
44
- if raw_xml==1
44
+ if raw_xml==true || raw_xml==1
45
45
  return response
46
46
  else
47
- ItemInfoResponse.format(response)
47
+ CustomItemAttributeInformationResponse.format(response)
48
48
  end
49
49
  end
50
50
 
@@ -1,6 +1,24 @@
1
1
  module RubyOmx
2
2
  module Orders
3
+
4
+ def build_udoa_request(params)
5
+ UDOARequest.new(params.merge({:http_biz_id=>@http_biz_id, :udi_auth_token=>@udi_auth_token}))
6
+ end
3
7
 
8
+ def send_udoa_request(params)
9
+ request = build_udoa_request(params)
10
+ response = post(request.to_xml)
11
+ if request.raw_xml==true || request.raw_xml==1
12
+ return response
13
+ end
14
+ UDOAResponse.format(response)
15
+ end
16
+
17
+ def append_order(params={})
18
+ send_udoa_request(params)
19
+ end
20
+
21
+ =begin
4
22
  #UniversalDirectOrderAppending (UDOA200) This request type is used to create orders in the application.
5
23
  def append_order(params ={})
6
24
 
@@ -15,43 +33,68 @@ module RubyOmx
15
33
  params[:method_code],
16
34
  params[:total_amount]
17
35
  ]
18
- #raise MissingOrderOptions if required_fields.any? {|option| option.nil?}
36
+ raise MissingOrderOptions if required_fields.any? {|option| option.nil?}
19
37
 
20
- raw_xml = params[:raw_xml] ||= 0
38
+ raw_xml = params[:raw_xml] ||= false
21
39
 
22
40
  doc = Nokogiri::XML::Document.new
23
41
  root_tag = RubyOmx.add_child_helper(doc,'UDOARequest','version','2.00',nil)
24
42
 
25
43
  udi_parameter = RubyOmx.add_child_helper(root_tag,'UDIParameter',nil,nil,nil)
26
- RubyOmx.add_child_helper(udi_parameter,'Parameter','key','HTTPBizID',@http_biz_id)
27
- RubyOmx.add_child_helper(udi_parameter,'Parameter','key','UDIAuthToken',@udi_auth_token)
28
- RubyOmx.add_child_helper(udi_parameter,'Parameter','key','QueueFlag',params[: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.
29
- RubyOmx.add_child_helper(udi_parameter,'Parameter','key','Keycode',params[:keycode])
30
- RubyOmx.add_child_helper(udi_parameter,'Parameter','key','VerifyFlag',params[: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.
31
- RubyOmx.add_child_helper(udi_parameter,'Parameter','key','Vendor',params[:vendor] ||= nil)
44
+ RubyOmx.add_child_helper(udi_parameter,'Parameter','key','HTTPBizID',@http_biz_id)
45
+ RubyOmx.add_child_helper(udi_parameter,'Parameter','key','UDIAuthToken',@udi_auth_token)
46
+ RubyOmx.add_child_helper(udi_parameter,'Parameter','key','QueueFlag',params[: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.
47
+ RubyOmx.add_child_helper(udi_parameter,'Parameter','key','Keycode',params[:keycode])
48
+ RubyOmx.add_child_helper(udi_parameter,'Parameter','key','VerifyFlag',params[: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.
49
+ RubyOmx.add_child_helper(udi_parameter,'Parameter','key','Vendor',params[:vendor] ||= nil)
32
50
 
33
51
  header = RubyOmx.add_child_helper(root_tag,'Header',nil,nil,nil)
34
- RubyOmx.add_child_helper(header,'StoreCode',nil,nil,params[:store_code] ||= '')
35
- RubyOmx.add_child_helper(header,'OrderID',nil,nil,params[:order_id])
36
- RubyOmx.add_child_helper(header,'OrderDate',nil,nil,params[:order_date]) # 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.
37
- RubyOmx.add_child_helper(header,'OriginType',nil,nil,params[:origin_type] ||= '2') # 2 = phone order, 3 = internet order
52
+ RubyOmx.add_child_helper(header,'StoreCode',nil,nil,params[:store_code] ||= '')
53
+ RubyOmx.add_child_helper(header,'OrderID',nil,nil,params[:order_id])
54
+ RubyOmx.add_child_helper(header,'OrderDate',nil,nil,params[:order_date]) # 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.
55
+ RubyOmx.add_child_helper(header,'OriginType',nil,nil,params[:origin_type] ||= '2') # 2 = phone order, 3 = internet order
38
56
 
39
57
  customer = RubyOmx.add_child_helper(root_tag,'Customer',nil,nil,nil)
40
- address = RubyOmx.add_child_helper(customer,'Address','type','BillTo',nil)
41
- RubyOmx.add_child_helper(address,'TitleCode',nil,nil,params[:title_code] ||= '0')
42
- RubyOmx.add_child_helper(address,'Firstname',nil,nil,params[:first_name] ||= 'Test')
43
- RubyOmx.add_child_helper(address,'Lastname',nil,nil,params[:last_name] ||= 'Test')
44
- RubyOmx.add_child_helper(address,'Address1',nil,nil,params[:address1] ||= nil)
45
- RubyOmx.add_child_helper(address,'Address2',nil,nil,params[:address2] ||= nil)
46
- RubyOmx.add_child_helper(address,'City',nil,nil,params[:city] ||=nil)
47
- RubyOmx.add_child_helper(address,'State',nil,nil,params[:state] ||= nil)
48
- RubyOmx.add_child_helper(address,'ZIP',nil,nil,params[:zip] ||=nil)
49
- RubyOmx.add_child_helper(address,'TLD',nil,nil,params[:tld] ||=nil)
50
- RubyOmx.add_child_helper(address,'PhoneNumber',nil,nil,params[:phone] ||= nil)
51
- RubyOmx.add_child_helper(address,'Email',nil,nil,params[:email] ||= nil)
58
+ address = RubyOmx.add_child_helper(customer,'Address','type','BillTo',nil)
59
+ RubyOmx.add_child_helper(address,'TitleCode',nil,nil,params[:title_code] ||= '0')
60
+ RubyOmx.add_child_helper(address,'Firstname',nil,nil,params[:first_name] ||= 'Test')
61
+ RubyOmx.add_child_helper(address,'Lastname',nil,nil,params[:last_name] ||= 'Test')
62
+ RubyOmx.add_child_helper(address,'Address1',nil,nil,params[:address1] ||= nil)
63
+ RubyOmx.add_child_helper(address,'Address2',nil,nil,params[:address2] ||= nil)
64
+ RubyOmx.add_child_helper(address,'City',nil,nil,params[:city] ||=nil)
65
+ RubyOmx.add_child_helper(address,'State',nil,nil,params[:state] ||= nil)
66
+ RubyOmx.add_child_helper(address,'ZIP',nil,nil,params[:zip] ||=nil)
67
+ RubyOmx.add_child_helper(address,'TLD',nil,nil,params[:tld] ||=nil)
68
+ RubyOmx.add_child_helper(address,'PhoneNumber',nil,nil,params[:phone] ||= nil)
69
+ RubyOmx.add_child_helper(address,'Email',nil,nil,params[:email] ||= nil)
52
70
 
53
71
  shipping_info = RubyOmx.add_child_helper(root_tag,'ShippingInformation',nil,nil,nil)
54
- RubyOmx.add_child_helper(shipping_info,'MethodCode',nil,nil,params[:method_code])
72
+
73
+ # Shipping Methods (numeric inputs to MethodCode)
74
+ # 0 UPS Ground (1-4 Days Transit Time) 0.00
75
+ # 2 Drop-Ship Montague 1 40.00
76
+ # 1 UPS Free UPS Ground Shipping (US ONLY) 0 0.00
77
+ # 3 UPS Ground 003 0.00
78
+ # 4 UPS 2nd Day Air 002 0.00
79
+ # 5 UPS Next Day Air 001 0.00
80
+ # 7 UPS 3 Day Select 004 0.00
81
+ # 12 UPS Worldwide Expedited 008 0.00
82
+ # 13 UPS Worldwide Express 009 0.00
83
+ # 14 UPS Worldwide Express Plus 010 0.00
84
+ # 6 International Flat Rate via USPS Express 2 35.00
85
+ # 8 USPS Express 29.99
86
+ # 9 USPS Priority 6.99
87
+ # 10 Int. Express USPS 0.00
88
+ # 11 Int. Priority USPS 0.00
89
+ # 15 USPS Domestic Priority Flat Rate 6.99
90
+ # 16 USPS Domestic Express Flat Rate 34.99
91
+ # 17 USPS International Global Priority 29.99
92
+ # 18 USPS International Global Express 39.99
93
+ # 19 Next Day Air (USA Only) 0.00
94
+ # 20 2nd Day Air (USA Only) 0.00
95
+ # 21 Priority Mail (Free $74.99 and above), 3-6 days 0.00
96
+ RubyOmx.add_child_helper(shipping_info,'MethodCode',nil,nil,params[:method_code])
97
+
55
98
  # address = RubyOmx.add_child_helper(shipping_info,'Address','type','ShipTo',nil)
56
99
  # RubyOmx.add_child_helper(address,'TitleCode',nil,nil,'0')
57
100
  # RubyOmx.add_child_helper(address,'Firstname',nil,nil,'Test') #TODO capture the first and last name for billing, not just shipping
@@ -64,11 +107,11 @@ module RubyOmx
64
107
  # RubyOmx.add_child_helper(address,'TLD',nil,nil,'US')
65
108
  # RubyOmx.add_child_helper(address,'PhoneNumber',nil,nil,nil)
66
109
  # RubyOmx.add_child_helper(address,'Email',nil,nil,nil)
67
- RubyOmx.add_child_helper(shipping_info,'ShippingAmount',nil,nil,params[:shipping_amount] ||= '0.00')
110
+ RubyOmx.add_child_helper(shipping_info,'ShippingAmount',nil,nil,params[:shipping_amount] ||= '0.00')
68
111
  #RubyOmx.add_child_helper(shipping_info,'HandlingAmount',nil,nil,'0')
69
112
  #RubyOmx.add_child_helper(shipping_info,'SpecialInstructions',nil,nil,'0')
70
- RubyOmx.add_child_helper(shipping_info,'GiftWrapping',nil,nil,params[:gift_wrapping] ||= 'False')
71
- RubyOmx.add_child_helper(shipping_info,'GiftMessage',nil,nil,params[:gift_message] ||= nil)
113
+ RubyOmx.add_child_helper(shipping_info,'GiftWrapping',nil,nil,params[:gift_wrapping] ||= 'False')
114
+ RubyOmx.add_child_helper(shipping_info,'GiftMessage',nil,nil,params[:gift_message] ||= nil)
72
115
 
73
116
  payment_type = RubyOmx.add_child_helper(root_tag,'Payment','type',params[:payment_type] ||= '6',nil) #6 for open invoice
74
117
  # RubyOmx.add_child_helper(payment_type,'CardNumber',nil,nil,'4111111111111111')
@@ -81,36 +124,34 @@ module RubyOmx
81
124
 
82
125
  order_detail = RubyOmx.add_child_helper(root_tag,'OrderDetail',nil,nil,nil)
83
126
 
84
- i=1
85
- params[:line_items].each do |item|
86
- raise MissingItemOptions if item[:item_code].nil?
87
- line_item = RubyOmx.add_child_helper(order_detail,'LineItem','lineNumber',i.to_s,nil)
88
- RubyOmx.add_child_helper(line_item,'ItemCode',nil,nil,item[:item_code])
89
- RubyOmx.add_child_helper(line_item,'Quantity',nil,nil,item[:quantity] ||= '1')
90
- if !item[:unit_price].nil?
91
- RubyOmx.add_child_helper(line_item,'UnitPrice',nil,nil,item[:unit_price])
92
- end
93
- #RubyOmx.add_child_helper(line_item,'StandingOrder','configurationID','5',nil)
94
- #customization = RubyOmx.add_child_helper(line_item,'ItemCustomizationData',nil,nil,nil)
95
- #field = RubyOmx.add_child_helper(customization,'CustomizationField','fieldID','127',nil)
96
- #RubyOmx.add_child_helper(field,'Value',nil,nil,'demoText')
97
- i+=1
98
- end
127
+ i=1
128
+ params[:line_items].each do |item|
129
+ raise MissingItemOptions if item[:item_code].nil?
130
+ line_item = RubyOmx.add_child_helper(order_detail,'LineItem','lineNumber',i.to_s,nil)
131
+ RubyOmx.add_child_helper(line_item,'ItemCode',nil,nil,item[:item_code])
132
+ RubyOmx.add_child_helper(line_item,'Quantity',nil,nil,item[:quantity] ||= '1')
133
+ if !item[:unit_price].nil?
134
+ RubyOmx.add_child_helper(line_item,'UnitPrice',nil,nil,item[:unit_price])
135
+ end
136
+ #RubyOmx.add_child_helper(line_item,'StandingOrder','configurationID','5',nil)
137
+ #customization = RubyOmx.add_child_helper(line_item,'ItemCustomizationData',nil,nil,nil)
138
+ #field = RubyOmx.add_child_helper(customization,'CustomizationField','fieldID','127',nil)
139
+ #RubyOmx.add_child_helper(field,'Value',nil,nil,'demoText')
140
+ i+=1
141
+ end
99
142
 
100
143
  check = RubyOmx.add_child_helper(root_tag,'Check',nil,nil,nil)
101
144
  RubyOmx.add_child_helper(check,'TotalAmount',nil,nil,params[:total_amount])
102
145
 
103
146
  response = post(doc.to_xml)
104
- if raw_xml==1
147
+ if raw_xml==true || raw_xml==1
105
148
  return response
106
149
  else
107
- AppendOrderResponse.format(response)
150
+ UDOAResponse.format(response)
108
151
  end
109
152
  end
110
153
 
111
154
  #OrderDetailUpdateRequest (ODUR100) This request type enables you to update certain data for orders.
112
-
113
-
114
155
  #CancellationHistoryRequest (CHR100) This request type lists all the cancellations that have occurred between two dates.
115
156
  #InvoiceProcessRequest (IPR100) This command takes an order number, and runs the invoicing and credit memo processes against the order if there are any order lines that can be subject to an invoice or credit memo, or if there are returns on the order.
116
157
  #OrderCancellationRequest (OCR100) This request type enables you to cancel some or all the line items in an order.
@@ -118,5 +159,6 @@ module RubyOmx
118
159
  #OrderSecondaryStatusUpdateRequest (OSSUR100) This request type enables you to set the secondary status of the OrderLines.
119
160
  #OrderUpdateRequest (OUR200) This request type enables you to change the Payment Plan of an order, as well as the basis date for payment plan calculation, and also update the "Alt ID 2" (a.k.a "Reference") field of the order.
120
161
  #OrderWaitDateUpdateRequest (OWDUR100) This request type enables you to change the Wait Date of an existing order.
162
+ =end
121
163
  end
122
164
  end
@@ -0,0 +1,43 @@
1
+ module RubyOmx
2
+
3
+ class CustomItemAttribute < Response
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 CIAIResponseItem < Response
11
+ xml_name "Item"
12
+ xml_reader :item_code, :from => '@itemCode'
13
+ xml_reader :active, :from => '@active'
14
+ xml_reader :attributes, :as => [CustomItemAttribute]
15
+ end
16
+
17
+ class CustomItemAttributeInformationResponse < Response
18
+ xml_name "CustomItemAttributeInformationResponse"
19
+
20
+ xml_reader :items, :as => [CIAIResponseItem], :in => "Items"
21
+ xml_reader :success
22
+
23
+ #xml_reader :item_code, :from => '@itemCode', :in => "Item"
24
+ #xml_reader :active, :from => '@active', :in => "Item"
25
+ #xml_reader :incomplete, :from => '@incomplete', :in => "Item"
26
+ #xml_reader :parent_item_code, :from => '@parentItemCode', :in => "Item"
27
+
28
+
29
+ #xml_reader :product_name, :in => "Item"
30
+ #xml_reader :available_inventory, :as => Integer, :in => "Item"
31
+ #xml_reader :sub_item_count, :as => Integer, :in => "Item"
32
+ #xml_reader :last_updated_date, :as => DateTime, :in => "Item"
33
+ #xml_reader :weight, :as => Float, :in => "Item"
34
+
35
+ #xml_reader :price_type, :from => '@priceType', :in => 'Item/PriceData'
36
+ #xml_reader :price_quantity, :from => '@quantity', :in => 'Item/PriceData/Price', :as => Integer
37
+ #xml_reader :price_amount, :from => 'Amount', :in => 'Item/PriceData/Price', :as => Float
38
+ #xml_reader :price_addl_sh, :from => 'AdditionalSH', :in => 'Item/PriceData/Price', :as => Float
39
+ #xml_reader :bonus, :in => 'Item/PriceData/Price', :as => Float
40
+
41
+ end
42
+
43
+ end
File without changes
@@ -1,28 +1,30 @@
1
1
  module RubyOmx
2
2
 
3
- class ItemInfoResponse < Response
4
- #xml_name "Item"
5
- xml_name "ItemInformationResponse"
6
- #result = "Item"
3
+ class ItemInformationResponse < Response
4
+ xml_name "ItemInformationResponse"
7
5
 
8
- xml_reader :item_code, :from => '@itemCode', :in => "Item"
9
- xml_reader :active, :from => '@active', :in => "Item"
10
- xml_reader :incomplete, :from => '@incomplete', :in => "Item"
11
- xml_reader :parent_item_code, :from => '@parentItemCode', :in => "Item"
6
+ xml_reader :item_code, :from => '@itemCode', :in => "Item"
7
+ xml_reader :active, :from => '@active', :in => "Item"
8
+ xml_reader :incomplete, :from => '@incomplete', :in => "Item"
9
+ xml_reader :parent_item_code, :from => '@parentItemCode', :in => "Item"
12
10
 
13
11
 
14
- xml_reader :product_name, :in => "Item"
15
- xml_reader :available_inventory, :as => Integer, :in => "Item"
16
- xml_reader :sub_item_count, :as => Integer, :in => "Item"
17
- xml_reader :last_updated_date, :as => DateTime, :in => "Item"
18
- xml_reader :weight, :as => Float, :in => "Item"
12
+ xml_reader :product_name, :in => "Item"
13
+ xml_reader :available_inventory, :as => Integer, :in => "Item"
14
+ #xml_reader :sub_item_count, :as => Integer, :in => "Item"
15
+ #xml_reader :last_updated_date, :as => DateTime, :in => "Item"
16
+ #xml_reader :weight, :as => Float, :in => "Item"
19
17
 
20
- xml_reader :price_type, :from => '@priceType', :in => 'Item/PriceData'
21
- xml_reader :price_quantity, :from => '@quantity', :in => 'Item/PriceData/Price', :as => Integer
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 :bonus, :in => 'Item/PriceData/Price', :as => Float
25
-
26
- end
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
+
23
+ xml_reader :price_amount, :from => 'Amount', :in => 'Item/PriceData/Price', :as => Float
24
+ xml_reader :price_addl_sh, :from => 'AdditionalSH', :in => 'Item/PriceData/Price', :as => Float
25
+ xml_reader :price_bonus, :from => 'Bonus', :in => 'Item/PriceData/Price', :as => Float
26
+
27
+ xml_reader :custom_attributes, :as => [CustomItemAttribute], :in => 'Item/CustomItemAttribute'
28
+ end
27
29
 
28
30
  end
@@ -0,0 +1,107 @@
1
+ module RubyOmx
2
+
3
+ class UDIParameter < Response
4
+ xml_name "Parameter"
5
+ xml_accessor :key, :from => '@key'
6
+ xml_accessor :value, :from => :content
7
+ end
8
+
9
+ class Address < Response
10
+ xml_name "Address"
11
+ xml_accessor :address_type, :from => '@type'
12
+ xml_accessor :title_code, :company, :firstname, :lastname, :address1, :address2, :city, :state, :phone_number, :email
13
+ xml_accessor :zip, :from => 'ZIP'
14
+ xml_accessor :tld, :from => 'TLD'
15
+ end
16
+
17
+ class LineItem < Response
18
+ xml_name "LineItem"
19
+ xml_accessor :line_number, :from => '@lineNumber'
20
+ xml_accessor :item_code
21
+ xml_accessor :quantity, :as => Integer
22
+ xml_accessor :unit_price, :as => Float
23
+ end
24
+
25
+ class CustomField < Response
26
+ xml_name 'Field'
27
+ xml_accessor :field_id, :from => '@fieldID'
28
+ xml_accessor :line_number, :from => '@lineNumber'
29
+ xml_accessor :value, :from => :content
30
+ end
31
+
32
+ class Flag < Response
33
+ xml_name 'Flag'
34
+ xml_accessor :name, :from => '@name'
35
+ xml_accessor :value, :from => :content
36
+ end
37
+
38
+ class UDOARequest < Response
39
+ def initialize(a=nil)
40
+ if !a.nil?
41
+ http_biz_id = a.delete(:http_biz_id)
42
+ udi_auth_token = a.delete(:udi_auth_token)
43
+
44
+ required_fields = [:keycode, :queue_flag, :verify_flag, :order_date, :order_id, :bill_to, :line_items, :method_code]
45
+ raise MissingOrderOptions if required_fields.any? { |option| a[option].nil? }
46
+ super
47
+ self.version = a[:version] ||= '2.00'
48
+ self.payment_type = a[:payment_type] ||= '6' #6 for open invoice
49
+ self.origin_type = a[:origin_type] ||= '2' # 2 = phone order, 3 = internet order
50
+ self.udi_parameters = []
51
+ self.udi_parameters << UDIParameter.new({:key=>'UDIAuthToken', :value=>udi_auth_token})
52
+ self.udi_parameters << UDIParameter.new({:key=>'HTTPBizID', :value=>http_biz_id})
53
+ self.udi_parameters << UDIParameter.new({:key=>'Keycode', :value=>a[:keycode]})
54
+ self.udi_parameters << UDIParameter.new({:key=>'VerifyFlag', :value=>a[: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.
55
+ self.udi_parameters << UDIParameter.new({:key=>'QueueFlag', :value=>a[: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.
56
+ self.udi_parameters << UDIParameter.new({:key=>'Vendor', :value=>a[:vendor] }) if !a[:vendor].nil?
57
+ self.bill_to = Address.new(a[:bill_to])
58
+ self.ship_to = Address.new(a[:ship_to])
59
+
60
+ i = 0
61
+ self.line_items = a[:line_items].collect { |h|
62
+ i+=1
63
+ h[:line_number] = h[:line_number] ||= i # Provide line numbers if they are omitted
64
+ LineItem.new(h)
65
+ }
66
+
67
+ self.custom_fields = a[:custom_fields].collect { |h| CustomField.new(h) } if !a[:custom_fields].nil?
68
+ self.flags = a[:flags].collect { |h| Flag.new(h) } if !a[:flags].nil?
69
+ else
70
+ super
71
+ end
72
+ end
73
+
74
+ attr_accessor :raw_xml, :keycode, :queue_flag, :verify_flag, :vendor
75
+
76
+ xml_name "UDOARequest"
77
+ xml_accessor :version, :from => '@version'
78
+ xml_accessor :udi_parameters, :as => [UDIParameter], :in => 'UDIParameter'
79
+ 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.
80
+ xml_accessor :order_id, :in => 'Header', :from => 'OrderID'
81
+ xml_accessor :origin_type, :in => 'Header'
82
+ xml_accessor :store_code, :in => 'Header'
83
+ xml_accessor :bill_to, :as => Address, :in => 'Customer'
84
+ xml_accessor :flags, :as => [Flag], :in => 'Customer/FlagData'
85
+ xml_accessor :ship_to, :as => Address, :in => 'ShippingInformation'
86
+
87
+ xml_accessor :method_code, :in => 'ShippingInformation', :as => Integer
88
+ xml_accessor :shipping_amount, :in => 'ShippingInformation', :as => Float
89
+ xml_accessor :handling_amount, :in => 'ShippingInformation', :as => Float
90
+ xml_accessor :special_instructions, :in => 'ShippingInformation'
91
+ xml_accessor :gift_wrapping, :in => 'ShippingInformation'
92
+ xml_accessor :gift_message, :in => 'ShippingInformation'
93
+
94
+ xml_accessor :payment_type, :in => 'Payment', :from => '@type'
95
+ xml_accessor :card_number, :in => 'Payment'
96
+ xml_accessor :card_verification, :in => 'Payment'
97
+ xml_accessor :card_exp_date_month, :in => 'Payment'
98
+ xml_accessor :card_exp_date_year, :in => 'Payment'
99
+ xml_accessor :card_status, :in => 'Payment'
100
+ xml_accessor :card_auth_code, :in => 'Payment'
101
+ xml_accessor :card_transaction_id, :from => 'CardTransactionID', :in => 'Payment'
102
+
103
+ xml_accessor :line_items, :as => [LineItem], :in => 'OrderDetail'
104
+ xml_accessor :custom_fields, :as => [CustomField], :in => 'CustomFields/Report'
105
+ xml_accessor :total_amount, :in => 'Check'
106
+ end
107
+ end
@@ -1,6 +1,6 @@
1
1
  module RubyOmx
2
2
 
3
- class AppendOrderResponse < Response
3
+ class UDOAResponse < Response
4
4
  xml_name "UDOAResponse"
5
5
 
6
6
  xml_reader :success, :as => Integer
@@ -3,6 +3,12 @@ module RubyOmx
3
3
  class Response
4
4
  include ROXML
5
5
  xml_convention :camelcase
6
+
7
+ def initialize(object_attribute_hash=nil)
8
+ if !object_attribute_hash.nil?
9
+ object_attribute_hash.map { |(k, v)| send("#{k}=", v) }
10
+ end
11
+ end
6
12
 
7
13
  # This is the factoryish method that is called!, not new
8
14
  def self.format(response)
@@ -26,5 +32,17 @@ module RubyOmx
26
32
  roxml_references.map {|r| r.accessor}
27
33
  end
28
34
 
35
+ # render a ROXML object as a normal hash, eliminating the @ and some unneeded admin fields
36
+ def as_hash
37
+ obj_hash = {}
38
+ self.instance_variables.each do |v|
39
+ m = v.to_s.sub('@','')
40
+ if m != 'roxml_references' && m!= 'promotion_ids'
41
+ obj_hash[m.to_sym] = self.instance_variable_get(v)
42
+ end
43
+ end
44
+ obj_hash
45
+ end
46
+
29
47
  end
30
48
  end
@@ -1,3 +1,3 @@
1
1
  module RubyOmx
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/ruby_omx.rb CHANGED
@@ -28,6 +28,7 @@ module RubyOmx
28
28
 
29
29
  end
30
30
 
31
+
31
32
  require 'ruby_omx/response'
32
33
  require 'ruby_omx/orders'
33
34
  require 'ruby_omx/items'
data/test/base_test.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ class BaseTest < MiniTest::Unit::TestCase
4
+
5
+ def test_connection
6
+
7
+ begin
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
+
17
+ @config = YAML.load_file( File.join(File.dirname(__FILE__), 'test_config.yml') )['test']
18
+ @connection = RubyOmx::Base.new(@config)
19
+
20
+ end
21
+ end
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ class ItemsTest < 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_get_item_information
10
+ @connection.stubs(:post).returns(xml_for('ItemInformationResponse(1.00)',200))
11
+ begin
12
+ response = @connection.get_item_info()
13
+ rescue MissingItemOptions
14
+ end
15
+
16
+ response = @connection.get_item_info(:item_code=>'01-114')
17
+ assert_equal '01-114', response.item_code
18
+ assert_equal 'True', response.active
19
+ assert_equal 'Driver', response.product_name
20
+ assert_equal 1130, response.available_inventory
21
+ assert_equal "Unit", response.price_type
22
+ assert_equal "Restricted", response.quantity_type
23
+ assert_equal 1, response.price_quantity
24
+ assert_equal "True", response.price_multiplier
25
+ assert_equal 2.02, response.price_amount
26
+ assert_equal 1.20, response.price_addl_sh
27
+ assert_equal 0.00, response.price_bonus
28
+ assert_equal 6, response.custom_attributes.length
29
+ assert_equal "1", response.custom_attributes.first.attribute_id
30
+ assert_equal "MYAttribute1", response.custom_attributes.first.value
31
+
32
+ assert_kind_of Hash, response.as_hash
33
+ end
34
+
35
+ def test_get_custom_item_attribute_information
36
+ @connection.stubs(:post).returns(xml_for('CustomItemAttributeInformationResponse(1.00)',200))
37
+ begin
38
+ response = @connection.get_custom_item_attribute_info()
39
+ rescue MissingItemOptions
40
+ end
41
+
42
+ response = @connection.get_custom_item_attribute_info(:item_code=>'00001')
43
+ assert_kind_of Hash, response.as_hash
44
+ assert_equal '1', response.success
45
+ i = response.items.first
46
+ assert_equal '10100', i.item_code
47
+ assert_equal 'True', i.active
48
+ i_attrs = i.attributes
49
+ assert_equal 20, i_attrs.length
50
+ assert_equal '1', i_attrs.first.attribute_id
51
+ assert_equal 'Keycode', i_attrs.first.name
52
+
53
+ assert_kind_of Hash, response.as_hash
54
+ end
55
+
56
+ end
@@ -0,0 +1,186 @@
1
+ require 'test_helper'
2
+
3
+ class OrdersTest < 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_orders_request_from_xml
10
+ request = RubyOmx::UDOARequest.format(xml_for('UDOARequest_(UDOA200)_request',200))
11
+ assert_equal '2.00', request.version
12
+
13
+ assert_equal 'UDIAuthToken', request.udi_parameters[0].key
14
+ assert_equal @config['udi_auth_token'], request.udi_parameters[0].value
15
+
16
+ assert_equal 'HTTPBizID', request.udi_parameters[1].key
17
+ assert_equal @config['http_biz_id'], request.udi_parameters[1].value
18
+
19
+ assert_equal 'Keycode', request.udi_parameters[2].key
20
+ assert_equal 'JTESTKEY', request.udi_parameters[2].value
21
+
22
+ assert_equal 'VerifyFlag', request.udi_parameters[3].key
23
+ assert_equal 'False', request.udi_parameters[3].value
24
+
25
+ assert_equal 'QueueFlag', request.udi_parameters[4].key
26
+ assert_equal 'False', request.udi_parameters[4].value
27
+
28
+
29
+ assert_equal DateTime.parse('2003-04-01 22:15:10'), request.order_date
30
+ assert_equal '3', request.origin_type
31
+ assert_equal 'XXX', request.store_code
32
+
33
+ assert_equal 'BillTo', request.bill_to.address_type
34
+ assert_equal '0', request.bill_to.title_code
35
+ assert_equal '', request.bill_to.company
36
+ assert_equal 'Bill', request.bill_to.firstname
37
+ assert_equal 'Thomas', request.bill_to.lastname
38
+ assert_equal '251 West 30th St', request.bill_to.address1
39
+ assert_equal '', request.bill_to.email
40
+
41
+ assert_equal 'ShipTo', request.ship_to.address_type
42
+ assert_equal '0', request.ship_to.title_code
43
+ assert_nil request.ship_to.company
44
+ assert_equal 'Maurice', request.ship_to.firstname
45
+ assert_equal 'Evans', request.ship_to.lastname
46
+ assert_equal '65 West 83rd St, Apt 4A', request.ship_to.address1
47
+ assert_nil request.ship_to.email
48
+
49
+ assert_equal 0, request.method_code
50
+ assert_equal 8.75, request.shipping_amount
51
+ assert_equal 0, request.handling_amount
52
+ assert_equal 'Please wrap this carefully', request.special_instructions
53
+ assert_equal 'True', request.gift_wrapping
54
+ assert_equal 'Happy Birthday Mauro!!', request.gift_message
55
+
56
+ assert_equal '1', request.payment_type
57
+ assert_equal '4111111111111111', request.card_number
58
+ assert_equal '222', request.card_verification
59
+ assert_equal '09', request.card_exp_date_month
60
+ assert_equal '2009', request.card_exp_date_year
61
+ assert_equal '11', request.card_status
62
+ assert_equal '010101', request.card_auth_code
63
+ assert_equal '123456789', request.card_transaction_id
64
+
65
+ assert_equal '1', request.line_items[0].line_number
66
+ assert_equal 'APPLE', request.line_items[0].item_code
67
+ assert_equal 1, request.line_items[0].quantity
68
+ assert_equal 'WATCH', request.line_items[1].item_code
69
+
70
+ assert_equal '2', request.custom_fields[0].field_id
71
+ assert_equal '1', request.custom_fields[0].line_number
72
+ assert_equal 'a', request.custom_fields[0].value
73
+ assert_equal 12, request.custom_fields.length
74
+
75
+ end
76
+
77
+ def test_orders_request_to_xml
78
+ request_attrs = {
79
+ :raw_xml => 0,
80
+ :keycode => 'JTESTKEY',
81
+ :verify_flag => 'False',
82
+ :queue_flag => 'False',
83
+ :order_date => DateTime.parse('2003-04-01 22:15:10'),
84
+ :order_id => '234-23423423',
85
+ :origin_type => '3',
86
+ :store_code => 'XXX',
87
+ :flags => [ { :name=>'DoNotMail', :value=>'True' },
88
+ { :name=>'DoNotCall', :value=>'True' },
89
+ { :name=>'DoNotEmail', :value=>'True' }],
90
+ :bill_to => { :address_type=>'BillTo',
91
+ :title_code => '0',
92
+ :company => '',
93
+ :firstname => 'Bill',
94
+ :lastname => 'Thomas',
95
+ :address1 => '251 West 30th St',
96
+ :address2 => 'Apt 12E',
97
+ :city => 'New York',
98
+ :state => 'NY',
99
+ :zip => '10001',
100
+ :tld => 'US',
101
+ :phone_number => '',
102
+ :email => ''},
103
+ :ship_to => { :address_type=>'ShipTo',
104
+ :title_code=>'0',
105
+ :firstname=>'Maurice',
106
+ :lastname=>'Evans',
107
+ :address1=>'65 West 83rd St, Apt 4A',
108
+ :address2=>'',
109
+ :city=>'New York',
110
+ :state=>'NY',
111
+ :zip => '10024',
112
+ :tld => 'US'},
113
+ :method_code => 0,
114
+ :shipping_amount => 8.75,
115
+ :handling_amount => 0.0,
116
+ :special_instructions => 'Please wrap this carefully',
117
+ :gift_wrapping => 'True',
118
+ :gift_message => 'Happy Birthday Mauro!!',
119
+ :payment_type => '1',
120
+ :card_number => '4111111111111111',
121
+ :card_verification => '222',
122
+ :card_exp_date_month => '09',
123
+ :card_exp_date_year => '2009',
124
+ :card_status => '11',
125
+ :card_auth_code => '010101',
126
+ :card_transaction_id => '123456789',
127
+ :line_items => [{ :item_code => 'APPLE', :quantity => 1 },
128
+ { :item_code => 'WATCH', :quantity => 1 }],
129
+ :custom_fields => [ { :field_id => '2', :line_number => '1', :value => 'a' },
130
+ { :field_id => '3', :line_number => '1', :value => 'a' },
131
+ { :field_id => '4', :line_number => '1', :value => 'a' },
132
+ { :field_id => '5', :line_number => '1', :value => 'a' },
133
+ { :field_id => '6', :line_number => '1', :value => 'a' },
134
+ { :field_id => '7', :line_number => '1', :value => 'a' },
135
+ { :field_id => '2', :line_number => '2', :value => 'a' },
136
+ { :field_id => '3', :line_number => '2', :value => 'a' },
137
+ { :field_id => '4', :line_number => '2', :value => 'a' },
138
+ { :field_id => '5', :line_number => '2', :value => 'a' },
139
+ { :field_id => '6', :line_number => '2', :value => 'a' },
140
+ { :field_id => '7', :line_number => '2', :value => 'a' }]
141
+ }
142
+ request = @connection.build_udoa_request(request_attrs)
143
+ request2 = RubyOmx::UDOARequest.format(xml_for('UDOARequest_(UDOA200)_request',200))
144
+ assert_equal request.to_xml.to_s, request2.to_xml.to_s
145
+ end
146
+
147
+ def test_send_udoa_request
148
+ @connection.stubs(:post).returns(xml_for('UDOARequest_(UDOA200)_response',200))
149
+ order_data = {
150
+ :keycode => 'TS01',
151
+ :vendor => '',
152
+ :queue_flag => 'False',
153
+ :verify_flag => 'True',
154
+ :order_date => Time.now.to_s(:db),
155
+ :order_id => '23423423423423',
156
+ :bill_to => { :lastname => 'Jim Smith'},
157
+ :line_items => [{ :quantity => 2, :unit_price => 5.00 }],
158
+ :method_code => '9'
159
+ }
160
+
161
+ # Missing Order Options
162
+ begin
163
+ response = @connection.send_udoa_request(order_data)
164
+ rescue MissingOrderOptions
165
+ end
166
+
167
+ # Should work
168
+ order_data[:line_items][0].merge!({ :item_code => 'SKU' })
169
+ response = @connection.send_udoa_request(order_data)
170
+
171
+ assert_kind_of UDOAResponse, response
172
+ assert !response.accessors.include?("code")
173
+ assert_equal 'OMX-ofyccytnacrtnedlldmyed', response.OMX
174
+ assert_equal '10512', response.order_number
175
+
176
+ assert_kind_of Hash, response.as_hash
177
+
178
+ response = @connection.send_udoa_request(order_data.merge({:raw_xml => true}))
179
+ assert_kind_of Net::HTTPOK, response
180
+
181
+ # old alias should still work
182
+ response = @connection.append_order(order_data)
183
+ assert_kind_of UDOAResponse, response
184
+ assert_equal 'OMX-ofyccytnacrtnedlldmyed', response.OMX
185
+ end
186
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ udi_auth_token: 470db4004809083c0048ef983
3
+ http_biz_id: KbmCrvnuTESTINGTESTINGYBlggjNYxGqsujuglguAJhXeKBYD
data/test/test_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  if RUBY_VERSION.match("1.9")
2
3
  require 'simplecov'
3
4
  SimpleCov.start do
@@ -11,9 +12,19 @@ require 'yaml'
11
12
  require 'mocha'
12
13
  require File.join(File.dirname(__FILE__), '..', 'lib', 'ruby_omx')
13
14
 
14
- def xml_for(name, code)
15
+ include RubyOmx
16
+
17
+ def xml_raw(name)
15
18
  file = File.open(Pathname.new(File.dirname(__FILE__)).expand_path.dirname.join("examples/xml/#{name}.xml"),'rb')
16
- mock_response(code, {:content_type=>'text/xml', :body=>file.read})
19
+ file.read
20
+ end
21
+
22
+ def xml_for(name, code)
23
+ mock_response(code, {:content_type=>'text/xml', :body=>xml_raw(name)})
24
+ end
25
+
26
+ def xml_for_raw(xml, code)
27
+ mock_response(code, {:content_type=>'text/xml', :body=>xml})
17
28
  end
18
29
 
19
30
  def mock_response(code, options={})
@@ -24,4 +35,5 @@ def mock_response(code, options={})
24
35
  response.instance_variable_set(:@read, true)
25
36
  response.content_type = content_type
26
37
  return response
27
- end
38
+ end
39
+
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -71,16 +71,22 @@ files:
71
71
  - lib/ruby_omx/exceptions.rb
72
72
  - lib/ruby_omx/items.rb
73
73
  - lib/ruby_omx/orders.rb
74
- - lib/ruby_omx/response/append_order_response.rb
74
+ - lib/ruby_omx/response/custom_item_attr_info_response.rb
75
+ - lib/ruby_omx/response/item_info_request.rb
75
76
  - lib/ruby_omx/response/item_info_response.rb
76
77
  - lib/ruby_omx/response/response_error.rb
78
+ - lib/ruby_omx/response/udoa_request.rb
79
+ - lib/ruby_omx/response/udoa_response.rb
77
80
  - lib/ruby_omx/response.rb
78
81
  - lib/ruby_omx/version.rb
79
82
  - lib/ruby_omx.rb
80
83
  - MIT-LICENSE
81
84
  - Rakefile
82
85
  - README.rdoc
83
- - test/ruby_omx_test.rb
86
+ - test/base_test.rb
87
+ - test/items_test.rb
88
+ - test/orders_test.rb
89
+ - test/test_config.yml
84
90
  - test/test_helper.rb
85
91
  homepage: http://github.com/aew/ruby_omx
86
92
  licenses: []
@@ -107,5 +113,8 @@ signing_key:
107
113
  specification_version: 3
108
114
  summary: Ruby wrapper for OrderMotion (OMX)
109
115
  test_files:
110
- - test/ruby_omx_test.rb
116
+ - test/base_test.rb
117
+ - test/items_test.rb
118
+ - test/orders_test.rb
119
+ - test/test_config.yml
111
120
  - test/test_helper.rb
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RubyOmxTest < MiniTest::Unit::TestCase
4
- def test_truth
5
- assert_kind_of Module, RubyOmx
6
- end
7
- end