Class: Io::Flow::V0::Models::OrderEstimate
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderEstimate
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Lightweight estimate for a group of items without any customer-related information. This will contain available estimates on shipping, taxes, and duties.
Instance Attribute Summary collapse
-
#deliveries ⇒ Object
readonly
Returns the value of attribute deliveries.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#prices ⇒ Object
readonly
Returns the value of attribute prices.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderEstimate
constructor
A new instance of OrderEstimate.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderEstimate
Returns a new instance of OrderEstimate.
14588 14589 14590 14591 14592 14593 14594 14595 14596 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14588 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:items, :destination, :deliveries, :prices, :total], 'OrderEstimate') @items = HttpClient::Preconditions.assert_class('items', opts.delete(:items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LocalizedLineItem) ? x : ::Io::Flow::V0::Models::LocalizedLineItem.new(x)) } @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)) @deliveries = HttpClient::Preconditions.assert_class('deliveries', opts.delete(:deliveries), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryEstimate) ? x : ::Io::Flow::V0::Models::DeliveryEstimate.new(x)) } @prices = HttpClient::Preconditions.assert_class('prices', opts.delete(:prices), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderPriceDetail) ? x : ::Io::Flow::V0::Models::OrderPriceDetail.new(x)) } @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x)) end |
Instance Attribute Details
#deliveries ⇒ Object (readonly)
Returns the value of attribute deliveries.
14586 14587 14588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14586 def deliveries @deliveries end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
14586 14587 14588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14586 def destination @destination end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
14586 14587 14588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14586 def items @items end |
#prices ⇒ Object (readonly)
Returns the value of attribute prices.
14586 14587 14588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14586 def prices @prices end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
14586 14587 14588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14586 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
14602 14603 14604 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14602 def copy(incoming={}) OrderEstimate.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
14606 14607 14608 14609 14610 14611 14612 14613 14614 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14606 def to_hash { :items => items.map { |o| o.to_hash }, :destination => destination.to_hash, :deliveries => deliveries.map { |o| o.to_hash }, :prices => prices.map { |o| o.to_hash }, :total => total.to_hash } end |
#to_json ⇒ Object
14598 14599 14600 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 14598 def to_json JSON.dump(to_hash) end |