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.



10936
10937
10938
10939
10940
10941
10942
10943
10944
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10936

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

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



10934
10935
10936
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10934

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



10934
10935
10936
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10934

def name
  @name
end

#rateObject (readonly)

Returns the value of attribute rate.



10934
10935
10936
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10934

def rate
  @rate
end

#totalObject (readonly)

Returns the value of attribute total.



10934
10935
10936
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10934

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10950
10951
10952
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10950

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

#subtype_to_hashObject



10954
10955
10956
10957
10958
10959
10960
10961
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10954

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

#to_jsonObject



10946
10947
10948
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10946

def to_json
  JSON.dump(to_hash)
end