class Io::Flow::V0::Models::AllocationLevyComponent
Represents either a VAT or duty component.
Attributes
accuracy[R]
basis[R]
key[R]
name[R]
price[R]
rate[R]
total[R]
Public Class Methods
new(incoming={})
click to toggle source
Calls superclass method
Io::Flow::V0::Models::AllocationComponent::new
# File lib/flow_commerce/flow_api_v0_client.rb, line 30129 def initialize(incoming={}) super(:discriminator => AllocationComponent::Types::ALLOCATION_LEVY_COMPONENT) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:key, :total, :rate, :name], 'AllocationLevyComponent') @key = (x = opts.delete(:key); x.is_a?(::Io::Flow::V0::Models::OrderPriceDetailComponentKey) ? x : ::Io::Flow::V0::Models::OrderPriceDetailComponentKey.apply(x)) @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)) @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal) @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @price = (x = opts.delete(:price); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))) @accuracy = (x = (x = opts.delete(:accuracy); x.nil? ? "calculated" : x); x.is_a?(::Io::Flow::V0::Models::PriceAccuracy) ? x : ::Io::Flow::V0::Models::PriceAccuracy.apply(x)) @basis = (x = opts.delete(:basis); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))) end
Public Instance Methods
copy(incoming={})
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 30146 def copy(incoming={}) AllocationLevyComponent.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end
subtype_to_hash()
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 30150 def subtype_to_hash { :key => key.value, :total => total.to_hash, :rate => rate.to_f.to_s, :name => name, :price => price.nil? ? nil : price.to_hash, :accuracy => accuracy.value, :basis => basis.nil? ? nil : basis.to_hash } end
to_json()
click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 30142 def to_json JSON.dump(to_hash) end