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
-
#accuracy ⇒ Object
readonly
Returns the value of attribute accuracy.
-
#basis ⇒ Object
readonly
Returns the value of attribute basis.
-
#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.
21191 21192 21193 21194 21195 21196 21197 21198 21199 21200 21201 21202 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21191 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 |
Instance Attribute Details
#accuracy ⇒ Object (readonly)
Returns the value of attribute accuracy.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def accuracy @accuracy end |
#basis ⇒ Object (readonly)
Returns the value of attribute basis.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def basis @basis end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def name @name end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def price @price end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def rate @rate end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
21189 21190 21191 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21189 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
21208 21209 21210 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21208 def copy(incoming={}) AllocationLevyComponent.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
21212 21213 21214 21215 21216 21217 21218 21219 21220 21221 21222 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21212 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 ⇒ Object
21204 21205 21206 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 21204 def to_json JSON.dump(to_hash) end |