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
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#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.
11697 11698 11699 11700 11701 11702 11703 11704 11705 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11697 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:customer, :destination, :items], 'OrderPutForm') @customer = (x = opts.delete(:customer); x.is_a?(::Io::Flow::V0::Models::Customer) ? x : ::Io::Flow::V0::Models::Customer.new(x)) @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)) @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LineItem) ? x : ::Io::Flow::V0::Models::LineItem.new(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) }) @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))) end |
Instance Attribute Details
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
11695 11696 11697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11695 def customer @customer end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
11695 11696 11697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11695 def destination @destination end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
11695 11696 11697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11695 def discount @discount end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
11695 11696 11697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11695 def items @items end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
11695 11696 11697 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11695 def selections @selections end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
11711 11712 11713 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11711 def copy(incoming={}) OrderPutForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
11715 11716 11717 11718 11719 11720 11721 11722 11723 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11715 def to_hash { :customer => customer.to_hash, :destination => destination.to_hash, :items => items.map { |o| o.to_hash }, :selections => selections.nil? ? nil : selections, :discount => discount.nil? ? nil : discount.to_hash } end |
#to_json ⇒ Object
11707 11708 11709 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11707 def to_json JSON.dump(to_hash) end |