Class: Io::Flow::V0::Models::DeminimisPerItem

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

Overview

De Minimis per item describes rules which require minimum and/or maximum values per item

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 = {}) ⇒ DeminimisPerItem

Returns a new instance of DeminimisPerItem.



39421
39422
39423
39424
39425
39426
39427
39428
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39421

def initialize(incoming={})
  super(:discriminator => Deminimis::Types::DEMINIMIS_PER_ITEM)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:currency], 'DeminimisPerItem')
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @minimum = (x = opts.delete(:minimum); x.nil? ? nil : HttpClient::Preconditions.assert_class('minimum', HttpClient::Helper.to_big_decimal(x), BigDecimal))
  @maximum = (x = opts.delete(:maximum); x.nil? ? nil : HttpClient::Preconditions.assert_class('maximum', HttpClient::Helper.to_big_decimal(x), BigDecimal))
end

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency.



39419
39420
39421
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39419

def currency
  @currency
end

#maximumObject (readonly)

Returns the value of attribute maximum.



39419
39420
39421
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39419

def maximum
  @maximum
end

#minimumObject (readonly)

Returns the value of attribute minimum.



39419
39420
39421
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39419

def minimum
  @minimum
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



39434
39435
39436
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39434

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

#subtype_to_hashObject



39438
39439
39440
39441
39442
39443
39444
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39438

def subtype_to_hash
  {
    :currency => currency,
    :minimum => minimum.to_f.to_s,
    :maximum => maximum.to_f.to_s
  }
end

#to_jsonObject



39430
39431
39432
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 39430

def to_json
  JSON.dump(to_hash)
end