Class: ApiReference::MatrixWithAllocationConfig

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

Overview

Configuration for matrix pricing with usage allocation

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(dimensions:, default_unit_amount:, allocation:, matrix_values:) ⇒ MatrixWithAllocationConfig

Returns a new instance of MatrixWithAllocationConfig.



49
50
51
52
53
54
55
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 49

def initialize(dimensions:, default_unit_amount:, allocation:,
               matrix_values:)
  @dimensions = dimensions
  @default_unit_amount = default_unit_amount
  @allocation = allocation
  @matrix_values = matrix_values
end

Instance Attribute Details

#allocationString

Usage allocation

Returns:

  • (String)


23
24
25
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 23

def allocation
  @allocation
end

#default_unit_amountString

Default per unit rate for any usage not bucketed into a specified matrix_value

Returns:

  • (String)


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

def default_unit_amount
  @default_unit_amount
end

#dimensionsArray[String]

One or two event property values to evaluate matrix groups by

Returns:

  • (Array[String])


14
15
16
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 14

def dimensions
  @dimensions
end

#matrix_valuesArray[MatrixWithAllocationValueItem]

Matrix values configuration

Returns:



27
28
29
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 27

def matrix_values
  @matrix_values
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 58

def self.from_hash(hash)
  return nil unless hash

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

  matrix_values = nil unless hash.key?('matrix_values')

  # Create object from extracted values.
  MatrixWithAllocationConfig.new(dimensions: dimensions,
                                 default_unit_amount: default_unit_amount,
                                 allocation: allocation,
                                 matrix_values: matrix_values)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dimensions'] = 'dimensions'
  @_hash['default_unit_amount'] = 'default_unit_amount'
  @_hash['allocation'] = 'allocation'
  @_hash['matrix_values'] = 'matrix_values'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 40

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



92
93
94
95
96
97
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 92

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

#to_sObject

Provides a human-readable string representation of the object.



85
86
87
88
89
# File 'lib/api_reference/models/matrix_with_allocation_config.rb', line 85

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} dimensions: #{@dimensions}, default_unit_amount: #{@default_unit_amount},"\
  " allocation: #{@allocation}, matrix_values: #{@matrix_values}>"
end