Class: Io::Flow::V0::Models::TaxDutyQuoteSimpleLevyValue

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

Overview

Value of a levy (tax or duty) with no additional detail.

Instance Attribute Summary collapse

Attributes inherited from TaxDutyQuoteLevyValue

#discriminator

Instance Method Summary collapse

Methods inherited from TaxDutyQuoteLevyValue

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ TaxDutyQuoteSimpleLevyValue

Returns a new instance of TaxDutyQuoteSimpleLevyValue.



65053
65054
65055
65056
65057
65058
65059
65060
65061
65062
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65053

def initialize(incoming={})
  super(:discriminator => TaxDutyQuoteLevyValue::Types::TAX_DUTY_QUOTE_SIMPLE_LEVY_VALUE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:amount, :rate, :description, :amount_refundable_on_return], 'TaxDutyQuoteSimpleLevyValue')
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal)
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
  @zero_levy_reason = (x = opts.delete(:zero_levy_reason); x.nil? ? nil : HttpClient::Preconditions.assert_class('zero_levy_reason', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ZeroLevyReasonCode) ? x : ::Io::Flow::V0::Models::ZeroLevyReasonCode.apply(x)) })
  @amount_refundable_on_return = HttpClient::Preconditions.assert_class('amount_refundable_on_return', HttpClient::Helper.to_big_decimal(opts.delete(:amount_refundable_on_return)), BigDecimal)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



65051
65052
65053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65051

def amount
  @amount
end

#amount_refundable_on_returnObject (readonly)

Returns the value of attribute amount_refundable_on_return.



65051
65052
65053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65051

def amount_refundable_on_return
  @amount_refundable_on_return
end

#descriptionObject (readonly)

Returns the value of attribute description.



65051
65052
65053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65051

def description
  @description
end

#rateObject (readonly)

Returns the value of attribute rate.



65051
65052
65053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65051

def rate
  @rate
end

#zero_levy_reasonObject (readonly)

Returns the value of attribute zero_levy_reason.



65051
65052
65053
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65051

def zero_levy_reason
  @zero_levy_reason
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



65068
65069
65070
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65068

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

#subtype_to_hashObject



65072
65073
65074
65075
65076
65077
65078
65079
65080
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65072

def subtype_to_hash
  {
    :amount => amount.to_f.to_s,
    :rate => rate.to_f.to_s,
    :description => description,
    :zero_levy_reason => zero_levy_reason.nil? ? nil : zero_levy_reason.map { |o| o.value },
    :amount_refundable_on_return => amount_refundable_on_return.to_f.to_s
  }
end

#to_jsonObject



65064
65065
65066
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 65064

def to_json
  JSON.dump(to_hash)
end