Class: Io::Flow::V0::Models::AllocationLevyComponent

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

Overview

Represents either a VAT or duty component.

Instance Attribute Summary collapse

Attributes inherited from AllocationComponent

#discriminator

Instance Method Summary collapse

Methods inherited from AllocationComponent

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ AllocationLevyComponent

Returns a new instance of AllocationLevyComponent.



17638
17639
17640
17641
17642
17643
17644
17645
17646
17647
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17638

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)))
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



17636
17637
17638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17636

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



17636
17637
17638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17636

def name
  @name
end

#priceObject (readonly)

Returns the value of attribute price.



17636
17637
17638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17636

def price
  @price
end

#rateObject (readonly)

Returns the value of attribute rate.



17636
17637
17638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17636

def rate
  @rate
end

#totalObject (readonly)

Returns the value of attribute total.



17636
17637
17638
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17636

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



17653
17654
17655
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17653

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

#subtype_to_hashObject



17657
17658
17659
17660
17661
17662
17663
17664
17665
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17657

def subtype_to_hash
  {
    :key => key.value,
    :total => total.to_hash,
    :rate => rate,
    :name => name,
    :price => price.nil? ? nil : price.to_hash
  }
end

#to_jsonObject



17649
17650
17651
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17649

def to_json
  JSON.dump(to_hash)
end