class Io::Flow::V0::Models::Quote

Represents a collection of deliveries and available options for fulfillment of that delivery

Attributes

delivered_duties[R]
delivered_duty[R]
deliveries[R]
destination[R]
id[R]
selections[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 61364
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

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 61379
def copy(incoming={})
  Quote.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end
to_hash() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 61383
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() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 61375
def to_json
  JSON.dump(to_hash)
end