Class: RubyOmx::UDOARequest
- Defined in:
- lib/ruby_omx/request/udoa_request.rb
Instance Attribute Summary collapse
-
#keycode ⇒ Object
Returns the value of attribute keycode.
-
#queue_flag ⇒ Object
Returns the value of attribute queue_flag.
-
#vendor ⇒ Object
Returns the value of attribute vendor.
-
#verify_flag ⇒ Object
Returns the value of attribute verify_flag.
Attributes inherited from Request
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ UDOARequest
constructor
A new instance of UDOARequest.
Methods inherited from Response
Methods inherited from Node
Constructor Details
#initialize(attrs = {}) ⇒ UDOARequest
Returns a new instance of UDOARequest.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_omx/request/udoa_request.rb', line 17 def initialize(attrs={}) return super unless attrs.any? required_fields = [:queue_flag, :verify_flag, :keycode, :order_date, :order_id, :bill_to, :line_items, :method_code] raise MissingRequestOptions if required_fields.any? { |option| attrs[option].nil? } super self.version = attrs[:version] ||= '2.00' self.payment_type = attrs[:payment_type] ||= '6' #6 for open invoice self.origin_type = attrs[:origin_type] ||= '2' # 2 = phone order, 3 = internet order self.udi_parameters << UDIParameter.new({:key=>'Keycode', :value=>attrs[:keycode]}) 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. 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. self.udi_parameters << UDIParameter.new({:key=>'Vendor', :value=>attrs[:vendor] }) if attrs[:vendor].present? self.bill_to = Address.new(attrs[:bill_to]) self.ship_to = Address.new(attrs[:ship_to]) # Instantiate LineItem variables for each i = 0 self.line_items = attrs[:line_items].collect { |h| i+=1 h[:line_number] = h[:line_number] ||= i # Provide line numbers if they are omitted LineItem.new(h) } self.custom_fields = attrs[:custom_fields].collect { |h| CustomField.new(h) } if attrs[:custom_fields].present? self.flags = attrs[:flags].collect { |h| Flag.new(h) } if attrs[:flags].present? end |
Instance Attribute Details
#keycode ⇒ Object
Returns the value of attribute keycode.
45 46 47 |
# File 'lib/ruby_omx/request/udoa_request.rb', line 45 def keycode @keycode end |
#queue_flag ⇒ Object
Returns the value of attribute queue_flag.
45 46 47 |
# File 'lib/ruby_omx/request/udoa_request.rb', line 45 def queue_flag @queue_flag end |
#vendor ⇒ Object
Returns the value of attribute vendor.
45 46 47 |
# File 'lib/ruby_omx/request/udoa_request.rb', line 45 def vendor @vendor end |
#verify_flag ⇒ Object
Returns the value of attribute verify_flag.
45 46 47 |
# File 'lib/ruby_omx/request/udoa_request.rb', line 45 def verify_flag @verify_flag end |