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.
-
#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.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#order_type ⇒ Object
readonly
Returns the value of attribute order_type.
-
#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.
49005 49006 49007 49008 49009 49010 49011 49012 49013 49014 49015 49016 49017 49018 49019 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49005 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:items], 'OrderPutForm') @order_type = (x = (x = opts.delete(:order_type); x.nil? ? "standard" : x); x.is_a?(::Io::Flow::V0::Models::OrderType) ? x : ::Io::Flow::V0::Models::OrderType.apply(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)) } @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))) @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))) @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.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def attributes @attributes end |
#authorization_keys ⇒ Object (readonly)
Returns the value of attribute authorization_keys.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def @authorization_keys end |
#customer ⇒ Object (readonly)
Returns the value of attribute customer.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def customer @customer end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def delivered_duty @delivered_duty end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def destination @destination end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def discount @discount end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def discounts @discounts end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def items @items end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def @options end |
#order_type ⇒ Object (readonly)
Returns the value of attribute order_type.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def order_type @order_type end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
49003 49004 49005 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49003 def selections @selections end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
49025 49026 49027 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49025 def copy(incoming={}) OrderPutForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
49029 49030 49031 49032 49033 49034 49035 49036 49037 49038 49039 49040 49041 49042 49043 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49029 def to_hash { :order_type => order_type.value, :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, :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
49021 49022 49023 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49021 def to_json JSON.dump(to_hash) end |