Class: Io::Flow::V0::Models::OrderPutForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderPutForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
The order put form is used to upsert an 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.
-
#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.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#selections ⇒ Object
readonly
Returns the value of attribute selections.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderPutForm
constructor
A new instance of OrderPutForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderPutForm
Returns a new instance of OrderPutForm.
20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20056 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:items], 'OrderPutForm') @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)) } @customer = (x = opts.delete(:customer); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Customer) ? x : ::Io::Flow::V0::Models::Customer.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))) @selections = (x = opts.delete(:selections); x.nil? ? nil : HttpClient::Preconditions.assert_class('selections', x, Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, 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))) @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 }) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def attributes @attributes end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def customer @customer end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def delivered_duty @delivered_duty end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def destination @destination end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def discount @discount end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def items @items end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
20054 20055 20056 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20054 def selections @selections end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
20072 20073 20074 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20072 def copy(incoming={}) OrderPutForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20076 def to_hash { :items => items.map { |o| o.to_hash }, :customer => customer.nil? ? nil : customer.to_hash, :delivered_duty => delivered_duty.nil? ? nil : delivered_duty.value, :selections => selections.nil? ? nil : selections, :destination => destination.nil? ? nil : destination.to_hash, :discount => discount.nil? ? nil : discount.to_hash, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
20068 20069 20070 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20068 def to_json JSON.dump(to_hash) end |