Class: Io::Flow::V0::Models::Tax
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Tax
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a simple model of taxes that apply to a given item / destination.
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#deminimis ⇒ Object
readonly
Returns the value of attribute deminimis.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Tax
constructor
A new instance of Tax.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Tax
Returns a new instance of Tax.
26063 26064 26065 26066 26067 26068 26069 26070 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26063 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:name, :rate, :components], 'Tax') @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @rate = HttpClient::Preconditions.assert_class('rate', HttpClient::Helper.to_big_decimal(opts.delete(:rate)), BigDecimal) @components = HttpClient::Preconditions.assert_class('components', opts.delete(:components), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::LevyComponent) ? x : ::Io::Flow::V0::Models::LevyComponent.apply(x)) } @deminimis = (x = opts.delete(:deminimis); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Deminimis) ? x : ::Io::Flow::V0::Models::Deminimis.from_json(x))) end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
26061 26062 26063 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26061 def components @components end |
#deminimis ⇒ Object (readonly)
Returns the value of attribute deminimis.
26061 26062 26063 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26061 def deminimis @deminimis end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
26061 26062 26063 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26061 def name @name end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
26061 26062 26063 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26061 def rate @rate end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
26076 26077 26078 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26076 def copy(incoming={}) Tax.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
26080 26081 26082 26083 26084 26085 26086 26087 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26080 def to_hash { :name => name, :rate => rate, :components => components.map { |o| o.value }, :deminimis => deminimis.nil? ? nil : deminimis.to_hash } end |
#to_json ⇒ Object
26072 26073 26074 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26072 def to_json JSON.dump(to_hash) end |