Class: Io::Flow::V0::Models::DeminimisSimple

Inherits:
Deminimis
  • Object
show all
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

Attributes inherited from Deminimis

#discriminator

Instance Method Summary collapse

Methods inherited from Deminimis

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ DeminimisSimple

Returns a new instance of DeminimisSimple.



12719
12720
12721
12722
12723
12724
12725
12726
12727
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12719

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

#componentsObject (readonly)

Returns the value of attribute components.



12717
12718
12719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12717

def components
  @components
end

#currencyObject (readonly)

Returns the value of attribute currency.



12717
12718
12719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12717

def currency
  @currency
end

#minimumObject (readonly)

Returns the value of attribute minimum.



12717
12718
12719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12717

def minimum
  @minimum
end

#valueObject (readonly)

Returns the value of attribute value.



12717
12718
12719
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12717

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



12733
12734
12735
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12733

def copy(incoming={})
  DeminimisSimple.new(subtype_to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#subtype_to_hashObject



12737
12738
12739
12740
12741
12742
12743
12744
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12737

def subtype_to_hash
  {
    :value => value,
    :currency => currency,
    :components => components.map { |o| o.value },
    :minimum => minimum
  }
end

#to_jsonObject



12729
12730
12731
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 12729

def to_json
  JSON.dump(to_hash)
end