Class: Io::Flow::V0::Models::OrderEstimateForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderEstimateForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Form to get a lightweight estimate of an order.
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#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 = {}) ⇒ OrderEstimateForm
constructor
A new instance of OrderEstimateForm.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderEstimateForm
Returns a new instance of OrderEstimateForm.
18026 18027 18028 18029 18030 18031 18032 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18026 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:items], 'OrderEstimateForm') @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)) } @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))) @selections = (x = opts.delete(:selections); x.nil? ? nil : HttpClient::Preconditions.assert_class('selections', x, Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, String) }) end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
18024 18025 18026 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18024 def destination @destination end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
18024 18025 18026 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18024 def items @items end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
18024 18025 18026 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18024 def selections @selections end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
18038 18039 18040 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18038 def copy(incoming={}) OrderEstimateForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
18042 18043 18044 18045 18046 18047 18048 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18042 def to_hash { :items => items.map { |o| o.to_hash }, :destination => destination.nil? ? nil : destination.to_hash, :selections => selections.nil? ? nil : selections } end |
#to_json ⇒ Object
18034 18035 18036 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18034 def to_json JSON.dump(to_hash) end |