Class: Io::Flow::V0::Models::TaxDutyQuoteForm

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

Overview

Calculates tax and duty in two currencies, representing consumer and client values for an MoR sale. Preserves de minimis and LVG calculations from the consumer sale.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TaxDutyQuoteForm

Returns a new instance of TaxDutyQuoteForm.



69999
70000
70001
70002
70003
70004
70005
70006
70007
70008
70009
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69999

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:primary_identifier, :destination, :currency, :lines, :shipping], 'TaxDutyQuoteForm')
  @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 }
  @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))
  @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::TaxDutyQuoteLineItemForm) ? x : ::Io::Flow::V0::Models::TaxDutyQuoteLineItemForm.new(x)) }
  @shipping = HttpClient::Preconditions.assert_class('shipping', opts.delete(:shipping), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::TaxDutyQuoteSimpleShippingForm) ? x : ::Io::Flow::V0::Models::TaxDutyQuoteSimpleShippingForm.new(x)) }
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def currency
  @currency
end

#delivered_dutyObject (readonly)

Returns the value of attribute delivered_duty.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def delivered_duty
  @delivered_duty
end

#destinationObject (readonly)

Returns the value of attribute destination.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def destination
  @destination
end

#linesObject (readonly)

Returns the value of attribute lines.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def lines
  @lines
end

#primary_identifierObject (readonly)

Returns the value of attribute primary_identifier.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def primary_identifier
  @primary_identifier
end

#shippingObject (readonly)

Returns the value of attribute shipping.



69997
69998
69999
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 69997

def shipping
  @shipping
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



70015
70016
70017
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70015

def copy(incoming={})
  TaxDutyQuoteForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



70019
70020
70021
70022
70023
70024
70025
70026
70027
70028
70029
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70019

def to_hash
  {
    :primary_identifier => primary_identifier,
    :attributes => attributes,
    :delivered_duty => delivered_duty.value,
    :destination => destination.to_hash,
    :currency => currency,
    :lines => lines.map { |o| o.to_hash },
    :shipping => shipping.map { |o| o.to_hash }
  }
end

#to_jsonObject



70011
70012
70013
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 70011

def to_json
  JSON.dump(to_hash)
end