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.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#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.
17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17090 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
#key ⇒ Object (readonly)
Returns the value of attribute key.
17088 17089 17090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17088 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
17088 17089 17090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17088 def name @name end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
17088 17089 17090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17088 def price @price end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
17088 17089 17090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17088 def rate @rate end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
17088 17089 17090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17088 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
17105 17106 17107 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17105 def copy(incoming={}) AllocationLevyComponent.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
17109 17110 17111 17112 17113 17114 17115 17116 17117 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17109 def subtype_to_hash { :key => key.value, :total => total.to_hash, :rate => rate, :name => name, :price => price.nil? ? nil : price.to_hash } end |
#to_json ⇒ Object
17101 17102 17103 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 17101 def to_json JSON.dump(to_hash) end |