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
-
#delivered_duties ⇒ Object
readonly
Returns the value of attribute delivered_duties.
-
#delivered_duty ⇒ Object
readonly
Returns the value of attribute delivered_duty.
-
#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.
28216 28217 28218 28219 28220 28221 28222 28223 28224 28225 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28216 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :destination, :deliveries, :selections, :delivered_duties], '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.from_json(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)) } @delivered_duty = (x = (x = opts.delete(:delivered_duty); x.nil? ? "paid" : x); x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)) @delivered_duties = HttpClient::Preconditions.assert_class('delivered_duties', opts.delete(:delivered_duties), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::DeliveredDuty) ? x : ::Io::Flow::V0::Models::DeliveredDuty.apply(x)) } end |
Instance Attribute Details
#delivered_duties ⇒ Object (readonly)
Returns the value of attribute delivered_duties.
28214 28215 28216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28214 def delivered_duties @delivered_duties end |
#delivered_duty ⇒ Object (readonly)
Returns the value of attribute delivered_duty.
28214 28215 28216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28214 def delivered_duty @delivered_duty end |
#deliveries ⇒ Object (readonly)
Returns the value of attribute deliveries.
28214 28215 28216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28214 def deliveries @deliveries end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
28214 28215 28216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28214 def destination @destination end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28214 28215 28216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28214 def id @id end |
#selections ⇒ Object (readonly)
Returns the value of attribute selections.
28214 28215 28216 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28214 def selections @selections end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
28231 28232 28233 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28231 def copy(incoming={}) Quote.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
28235 28236 28237 28238 28239 28240 28241 28242 28243 28244 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28235 def to_hash { :id => id, :destination => destination.to_hash, :deliveries => deliveries.map { |o| o.to_hash }, :selections => selections.map { |o| o.to_hash }, :delivered_duty => delivered_duty.value, :delivered_duties => delivered_duties.map { |o| o.value } } end |
#to_json ⇒ Object
28227 28228 28229 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28227 def to_json JSON.dump(to_hash) end |