Class: ApiReference::ThresholdTotalAmountConfig

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/threshold_total_amount_config.rb

Overview

Configuration for tiered total pricing

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(consumption_table:, prorate: false) ⇒ ThresholdTotalAmountConfig

Returns a new instance of ThresholdTotalAmountConfig.



43
44
45
46
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 43

def initialize(consumption_table:, prorate: false)
  @consumption_table = consumption_table
  @prorate = prorate unless prorate == SKIP
end

Instance Attribute Details

#consumption_tableArray[TieredTotalThreshold]

When the quantity consumed passes a provided threshold, the configured total will be charged

Returns:



15
16
17
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 15

def consumption_table
  @consumption_table
end

#prorateTrueClass | FalseClass

If true, the unit price will be prorated to the billing period

Returns:

  • (TrueClass | FalseClass)


19
20
21
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 19

def prorate
  @prorate
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 49

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  consumption_table = nil
  unless hash['consumption_table'].nil?
    consumption_table = []
    hash['consumption_table'].each do |structure|
      consumption_table << (TieredTotalThreshold.from_hash(structure) if structure)
    end
  end

  consumption_table = nil unless hash.key?('consumption_table')
  prorate = hash['prorate'] ||= false

  # Create object from extracted values.
  ThresholdTotalAmountConfig.new(consumption_table: consumption_table,
                                 prorate: prorate)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['consumption_table'] = 'consumption_table'
  @_hash['prorate'] = 'prorate'
  @_hash
end

.nullablesObject

An array for nullable fields



37
38
39
40
41
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 37

def self.nullables
  %w[
    prorate
  ]
end

.optionalsObject

An array for optional fields



30
31
32
33
34
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 30

def self.optionals
  %w[
    prorate
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



77
78
79
80
81
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 77

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} consumption_table: #{@consumption_table.inspect}, prorate:"\
  " #{@prorate.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



71
72
73
74
# File 'lib/api_reference/models/threshold_total_amount_config.rb', line 71

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} consumption_table: #{@consumption_table}, prorate: #{@prorate}>"
end