Class: Io::Flow::V0::Models::OrderForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The order form is used to create an open order, providing the details on pricing and delivery options for destination and items/quantities specified
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#authorization_keys ⇒ Object
readonly
Returns the value of attribute authorization_keys.
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderForm
constructor
A new instance of OrderForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderForm
Returns a new instance of OrderForm.
48033 48034 48035 48036 48037 48038 48039 48040 48041 48042 48043 48044 48045 48046 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48033 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:items], 'OrderForm') @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderCustomerForm) ? x : ::Io::Flow::V0::Models::OrderCustomerForm.new(x))) @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItemForm) ? x : ::Io::Flow::V0::Models::LineItemForm.new(x)) } @delivered_duty = (x = opts.delete(:delivered_duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x))) @number = (x = opts.delete(:number); x.nil? ? nil : HttpClient::Preconditions.assert_class('number', x, String)) @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x))) @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Money) ? x : ::Io::Flow::V0::Models::Money.new(x))) @discounts = (x = opts.delete(:discounts); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::DiscountsForm) ? x : ::Io::Flow::V0::Models::DiscountsForm.new(x))) @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }) @authorization_keys = (x = opts.delete(:authorization_keys); x.nil? ? nil : HttpClient::Preconditions.assert_class('authorization_keys', x, Array).map { |v| HttpClient::Preconditions.assert_class('authorization_keys', v, String) }) @options = (x = opts.delete(:options); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderOptions) ? x : ::Io::Flow::V0::Models::OrderOptions.new(x))) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def attributes @attributes end |
#authorization_keys ⇒ Object (readonly)
Returns the value of attribute authorization_keys.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def @authorization_keys end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def customer @customer end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def delivered_duty @delivered_duty end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def destination @destination end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def discount @discount end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def discounts @discounts end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def items @items end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def number @number end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
48031 48032 48033 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48031 def @options end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
48052 48053 48054 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48052 def copy(incoming={}) OrderForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
48056 48057 48058 48059 48060 48061 48062 48063 48064 48065 48066 48067 48068 48069 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48056 def to_hash { :customer => customer.nil? ? nil : customer.to_hash, :items => items.map { |o| o.to_hash }, :delivered_duty => delivered_duty.nil? ? nil : delivered_duty.value, :number => number, :destination => destination.nil? ? nil : destination.to_hash, :discount => discount.nil? ? nil : discount.to_hash, :discounts => discounts.nil? ? nil : discounts.to_hash, :attributes => attributes.nil? ? nil : attributes, :authorization_keys => .nil? ? nil : , :options => .nil? ? nil : .to_hash } end |
#to_json ⇒ Object
48048 48049 48050 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48048 def to_json JSON.dump(to_hash) end |