Class: Io::Flow::V0::Models::DeminimusSimple

Inherits:
Deminimus
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Deminimus

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ DeminimusSimple

Returns a new instance of DeminimusSimple.



9483
9484
9485
9486
9487
9488
9489
9490
9491
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9483

def initialize(incoming={})
  super(:name => Deminimus::Types::DEMINIMUS_SIMPLE)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:value, :currency, :components, :minimum], 'DeminimusSimple')
  @value = HttpClient::Preconditions.assert_class('value', HttpClient::Helper.to_big_decimal(opts.delete(:value)), 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 = HttpClient::Preconditions.assert_class('minimum', HttpClient::Helper.to_big_decimal(opts.delete(:minimum)), BigDecimal)
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



9481
9482
9483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9481

def components
  @components
end

#currencyObject (readonly)

Returns the value of attribute currency.



9481
9482
9483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9481

def currency
  @currency
end

#minimumObject (readonly)

Returns the value of attribute minimum.



9481
9482
9483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9481

def minimum
  @minimum
end

#valueObject (readonly)

Returns the value of attribute value.



9481
9482
9483
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9481

def value
  @value
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



9497
9498
9499
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9497

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

#subtype_to_hashObject



9501
9502
9503
9504
9505
9506
9507
9508
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9501

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

#to_jsonObject



9493
9494
9495
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9493

def to_json
  JSON.dump(to_hash)
end