Class: Io::Flow::V0::Models::Quote
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Quote
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a collection of deliveries and available options for fulfillment of that delivery
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.
-
#selections ⇒ Object
readonly
Returns the value of attribute selections.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Quote
constructor
A new instance of Quote.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Quote
Returns a new instance of Quote.
18699 18700 18701 18702 18703 18704 18705 18706 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18699 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :destination, :deliveries, :selections], 'Quote') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::ShippingAddress) ? x : ::Io::Flow::V0::Models::ShippingAddress.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.new(x)) } @selections = HttpClient::Preconditions.assert_class('selections', opts.delete(:selections), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveryOptionReference) ? x : ::Io::Flow::V0::Models::DeliveryOptionReference.new(x)) } end |
Instance Attribute Details
#deliveries ⇒ Object (readonly)
Returns the value of attribute deliveries.
18697 18698 18699 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18697 def deliveries @deliveries end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
18697 18698 18699 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18697 def destination @destination end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
18697 18698 18699 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18697 def id @id end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
18697 18698 18699 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18697 def selections @selections end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
18712 18713 18714 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18712 def copy(incoming={}) Quote.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
18716 18717 18718 18719 18720 18721 18722 18723 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18716 def to_hash { :id => id, :destination => destination.to_hash, :deliveries => deliveries.map { |o| o.to_hash }, :selections => selections.map { |o| o.to_hash } } end |
#to_json ⇒ Object
18708 18709 18710 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18708 def to_json JSON.dump(to_hash) end |