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
-
#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.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
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.
11661 11662 11663 11664 11665 11666 11667 11668 11669 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11661 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:number, :customer, :destination, :items], 'OrderForm') @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String) @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)) } @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.
11659 11660 11661 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11659 def customer @customer end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
11659 11660 11661 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11659 def destination @destination end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
11659 11660 11661 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11659 def discount @discount end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
11659 11660 11661 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11659 def items @items end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
11659 11660 11661 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11659 def number @number end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
11675 11676 11677 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11675 def copy(incoming={}) OrderForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
11679 11680 11681 11682 11683 11684 11685 11686 11687 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11679 def to_hash { :number => number, :customer => customer.to_hash, :destination => destination.to_hash, :items => items.map { |o| o.to_hash }, :discount => discount.nil? ? nil : discount.to_hash } end |
#to_json ⇒ Object
11671 11672 11673 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11671 def to_json JSON.dump(to_hash) end |