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.
-
#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.
16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16928 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::Customer) ? x : ::Io::Flow::V0::Models::Customer.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)) } @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))) @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.
16926 16927 16928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926 def attributes @attributes end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
16926 16927 16928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926 def customer @customer end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
16926 16927 16928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926 def destination @destination end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
16926 16927 16928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926 def discount @discount end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
16926 16927 16928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926 def items @items end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
16926 16927 16928 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16926 def number @number end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
16943 16944 16945 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16943 def copy(incoming={}) OrderForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16947 def to_hash { :customer => customer.nil? ? nil : customer.to_hash, :items => items.map { |o| o.to_hash }, :number => number, :destination => destination.nil? ? nil : destination.to_hash, :discount => discount.nil? ? nil : discount.to_hash, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
16939 16940 16941 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16939 def to_json JSON.dump(to_hash) end |