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.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#prices ⇒ Object
readonly
Returns the value of attribute prices.
-
#promotions ⇒ Object
readonly
Returns the value of attribute promotions.
-
#selections ⇒ Object
readonly
Returns the value of attribute selections.
-
#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.
24710 24711 24712 24713 24714 24715 24716 24717 24718 24719 24720 24721 24722 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24710 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :items, :destination, :deliveries, :prices, :selections, :total], 'OrderEstimate') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @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::OrderAddress) ? x : ::Io::Flow::V0::Models::OrderAddress.new(x)) @deliveries = HttpClient::Preconditions.assert_class('deliveries', opts.delete(:deliveries), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Delivery) ? x : ::Io::Flow::V0::Models::Delivery.from_json(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)) } @selections = HttpClient::Preconditions.assert_class('selections', opts.delete(:selections), Array).map { |v| HttpClient::Preconditions.assert_class('selections', v, String) } @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::LocalizedTotal) ? x : ::Io::Flow::V0::Models::LocalizedTotal.new(x)) @lines = (x = opts.delete(:lines); x.nil? ? nil : HttpClient::Preconditions.assert_class('lines', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::Line) ? x : ::Io::Flow::V0::Models::Line.new(x)) }) @promotions = (x = opts.delete(:promotions); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Promotions) ? x : ::Io::Flow::V0::Models::Promotions.new(x))) end |
Instance Attribute Details
#deliveries ⇒ Object (readonly)
Returns the value of attribute deliveries.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def deliveries @deliveries end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def destination @destination end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def id @id end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def items @items end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def lines @lines end |
#prices ⇒ Object (readonly)
Returns the value of attribute prices.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def prices @prices end |
#promotions ⇒ Object (readonly)
Returns the value of attribute promotions.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def promotions @promotions end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def selections @selections end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
24708 24709 24710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24708 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
24728 24729 24730 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24728 def copy(incoming={}) OrderEstimate.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
24732 24733 24734 24735 24736 24737 24738 24739 24740 24741 24742 24743 24744 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24732 def to_hash { :id => id, :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 }, :selections => selections, :total => total.to_hash, :lines => lines.nil? ? nil : lines.map { |o| o.to_hash }, :promotions => promotions.nil? ? nil : promotions.to_hash } end |
#to_json ⇒ Object
24724 24725 24726 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 24724 def to_json JSON.dump(to_hash) end |