class Io::Flow::V0::Models::TaxDutyQuote

An order to have tax and duty calculated. Quote will provide all values in the local currency.

Attributes

attributes[R]
currency[R]
delivered_duty[R]
destination[R]
id[R]
lines[R]
merchant_of_record[R]
primary_identifier[R]
quote_date[R]
shipping[R]
total_values[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 69919
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :primary_identifier, :destination, :quote_date, :currency, :lines, :shipping, :total_values], 'TaxDutyQuote')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @primary_identifier = HttpClient::Preconditions.assert_class('primary_identifier', opts.delete(:primary_identifier), String)
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @merchant_of_record = (x = (x = opts.delete(:merchant_of_record); x.nil? ? "flow" : x); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecord) ? x : ::Io::Flow::V0::Models::MerchantOfRecord.apply(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))
  @destination = (x = opts.delete(:destination); x.is_a?(::Io::Flow::V0::Models::StreetAddress) ? x : ::Io::Flow::V0::Models::StreetAddress.new(x))
  @quote_date = HttpClient::Preconditions.assert_class('quote_date', HttpClient::Helper.to_date_time_iso8601(opts.delete(:quote_date)), DateTime)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::TaxDutyQuoteLineItem) ? x : ::Io::Flow::V0::Models::TaxDutyQuoteLineItem.new(x)) }
  @shipping = HttpClient::Preconditions.assert_class('shipping', opts.delete(:shipping), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::TaxDutyQuoteSimpleShipping) ? x : ::Io::Flow::V0::Models::TaxDutyQuoteSimpleShipping.new(x)) }
  @total_values = (x = opts.delete(:total_values); x.is_a?(::Io::Flow::V0::Models::TaxDutyQuoteValues) ? x : ::Io::Flow::V0::Models::TaxDutyQuoteValues.new(x))
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 69939
def copy(incoming={})
  TaxDutyQuote.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 69943
def to_hash
  {
    :id => id,
    :primary_identifier => primary_identifier,
    :attributes => attributes,
    :merchant_of_record => merchant_of_record.value,
    :delivered_duty => delivered_duty.value,
    :destination => destination.to_hash,
    :quote_date => quote_date,
    :currency => currency,
    :lines => lines.map { |o| o.to_hash },
    :shipping => shipping.map { |o| o.to_hash },
    :total_values => total_values.to_hash
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 69935
def to_json
  JSON.dump(to_hash)
end