Class: Io::Flow::V0::Models::AllocationLevyComponent
- Inherits:
-
AllocationComponent
- Object
- AllocationComponent
- Io::Flow::V0::Models::AllocationLevyComponent
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents either a VAT or duty component.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Attributes inherited from AllocationComponent
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ AllocationLevyComponent
constructor
A new instance of AllocationLevyComponent.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from AllocationComponent
Constructor Details
#initialize(incoming = {}) ⇒ AllocationLevyComponent
Returns a new instance of AllocationLevyComponent.
11588 11589 11590 11591 11592 11593 11594 11595 11596 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11588 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
#key ⇒ Object (readonly)
Returns the value of attribute key.
11586 11587 11588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11586 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11586 11587 11588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11586 def name @name end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
11586 11587 11588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11586 def rate @rate end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
11586 11587 11588 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11586 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
11602 11603 11604 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11602 def copy(incoming={}) AllocationLevyComponent.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
11606 11607 11608 11609 11610 11611 11612 11613 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11606 def subtype_to_hash { :key => key.value, :total => total.to_hash, :rate => rate, :name => name } end |
#to_json ⇒ Object
11598 11599 11600 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 11598 def to_json JSON.dump(to_hash) end |