Class: Io::Flow::V0::Models::DeminimisSimple
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
De Minimis for most common example which includes a value threshold and rules on what components are used in the duty calculation
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Returns the value of attribute components.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#minimum ⇒ Object
readonly
Returns the value of attribute minimum.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Deminimis
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ DeminimisSimple
constructor
A new instance of DeminimisSimple.
- #subtype_to_hash ⇒ Object
- #to_json ⇒ Object
Methods inherited from Deminimis
Constructor Details
#initialize(incoming = {}) ⇒ DeminimisSimple
Returns a new instance of DeminimisSimple.
30082 30083 30084 30085 30086 30087 30088 30089 30090 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30082 def initialize(incoming={}) super(:discriminator => Deminimis::Types::DEMINIMIS_SIMPLE) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:currency, :components], 'DeminimisSimple') @value = (x = opts.delete(:value); x.nil? ? nil : HttpClient::Preconditions.assert_class('value', HttpClient::Helper.to_big_decimal(x), BigDecimal)) @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String) @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)) } @minimum = (x = opts.delete(:minimum); x.nil? ? nil : HttpClient::Preconditions.assert_class('minimum', HttpClient::Helper.to_big_decimal(x), BigDecimal)) end |
Instance Attribute Details
#components ⇒ Object (readonly)
Returns the value of attribute components.
30080 30081 30082 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30080 def components @components end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
30080 30081 30082 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30080 def currency @currency end |
#minimum ⇒ Object (readonly)
Returns the value of attribute minimum.
30080 30081 30082 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30080 def minimum @minimum end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
30080 30081 30082 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30080 def value @value end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
30096 30097 30098 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30096 def copy(incoming={}) DeminimisSimple.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#subtype_to_hash ⇒ Object
30100 30101 30102 30103 30104 30105 30106 30107 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30100 def subtype_to_hash { :value => value.to_f.to_s, :currency => currency, :components => components.map { |o| o.value }, :minimum => minimum.to_f.to_s } end |
#to_json ⇒ Object
30092 30093 30094 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30092 def to_json JSON.dump(to_hash) end |