Class: Io::Flow::V0::Models::TaxDutyQuote

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TaxDutyQuote

Returns a new instance of TaxDutyQuote.



69919
69920
69921
69922
69923
69924
69925
69926
69927
69928
69929
69930
69931
69932
69933
# 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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def currency
  @currency
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def destination
  @destination
end

#idObject (readonly)

Returns the value of attribute id.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def id
  @id
end

#linesObject (readonly)

Returns the value of attribute lines.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def lines
  @lines
end

#merchant_of_recordObject (readonly)

Returns the value of attribute merchant_of_record.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def merchant_of_record
  @merchant_of_record
end

#primary_identifierObject (readonly)

Returns the value of attribute primary_identifier.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def primary_identifier
  @primary_identifier
end

#quote_dateObject (readonly)

Returns the value of attribute quote_date.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def quote_date
  @quote_date
end

#shippingObject (readonly)

Returns the value of attribute shipping.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def shipping
  @shipping
end

#total_valuesObject (readonly)

Returns the value of attribute total_values.



69917
69918
69919
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69917

def total_values
  @total_values
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



69939
69940
69941
# 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_hashObject



69943
69944
69945
69946
69947
69948
69949
69950
69951
69952
69953
69954
69955
69956
69957
# 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_jsonObject



69935
69936
69937
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69935

def to_json
  JSON.dump(to_hash)
end