Class: Io::Flow::V0::Models::Duty
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Duty
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Represents a simple model of duties that apply to a given item / trade lane.
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 = {}) ⇒ Duty
constructor
A new instance of Duty.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Duty
Returns a new instance of Duty.
30861 30862 30863 30864 30865 30866 30867 30868 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30861 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:rate, :components], 'Duty') @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))) @name = (x = opts.delete(:name); x.nil? ? nil : HttpClient::Preconditions.assert_class('name', x, String)) end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
30859 30860 30861 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30859 def components @components end |
#deminimis ⇒ Object (readonly)
Returns the value of attribute deminimis.
30859 30860 30861 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30859 def deminimis @deminimis end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30859 30860 30861 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30859 def name @name end |
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
30859 30860 30861 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30859 def rate @rate end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
30874 30875 30876 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30874 def copy(incoming={}) Duty.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
30878 30879 30880 30881 30882 30883 30884 30885 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30878 def to_hash { :rate => rate.to_f.to_s, :components => components.map { |o| o.value }, :deminimis => deminimis.nil? ? nil : deminimis.to_hash, :name => name } end |
#to_json ⇒ Object
30870 30871 30872 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30870 def to_json JSON.dump(to_hash) end |