Class: ApiReference::ThresholdTotalAmountConfig1

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

Overview

Configuration for threshold_total_amount 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) ⇒ ThresholdTotalAmountConfig1

Returns a new instance of ThresholdTotalAmountConfig1.



43
44
45
46
# File 'lib/api_reference/models/threshold_total_amount_config1.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_config1.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_config1.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_config1.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.
  ThresholdTotalAmountConfig1.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_config1.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_config1.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_config1.rb', line 30

def self.optionals
  %w[
    prorate
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/api_reference/models/threshold_total_amount_config1.rb', line 72

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.consumption_table,
                                 ->(val) { TieredTotalThreshold.validate(val) },
                                 is_model_hash: true,
                                 is_inner_model_hash: true)
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['consumption_table'],
                        ->(val) { TieredTotalThreshold.validate(val) },
                        is_model_hash: true,
                        is_inner_model_hash: true)
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



95
96
97
98
99
# File 'lib/api_reference/models/threshold_total_amount_config1.rb', line 95

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.



89
90
91
92
# File 'lib/api_reference/models/threshold_total_amount_config1.rb', line 89

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