Class: ApiReference::MatrixConfig
- Defined in:
- lib/api_reference/models/matrix_config.rb
Overview
Configuration for matrix pricing
Instance Attribute Summary collapse
-
#default_unit_amount ⇒ String
Default per unit rate for any usage not bucketed into a specified matrix_value.
-
#dimensions ⇒ Array[String]
One or two event property values to evaluate matrix groups by.
-
#matrix_values ⇒ Array[MatrixValue]
Matrix values configuration.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(dimensions:, default_unit_amount:, matrix_values:) ⇒ MatrixConfig
constructor
A new instance of MatrixConfig.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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:, matrix_values:) ⇒ MatrixConfig
Returns a new instance of MatrixConfig.
44 45 46 47 48 |
# File 'lib/api_reference/models/matrix_config.rb', line 44 def initialize(dimensions:, default_unit_amount:, matrix_values:) @dimensions = dimensions @default_unit_amount = default_unit_amount @matrix_values = matrix_values end |
Instance Attribute Details
#default_unit_amount ⇒ String
Default per unit rate for any usage not bucketed into a specified matrix_value
19 20 21 |
# File 'lib/api_reference/models/matrix_config.rb', line 19 def default_unit_amount @default_unit_amount end |
#dimensions ⇒ Array[String]
One or two event property values to evaluate matrix groups by
14 15 16 |
# File 'lib/api_reference/models/matrix_config.rb', line 14 def dimensions @dimensions end |
#matrix_values ⇒ Array[MatrixValue]
Matrix values configuration
23 24 25 |
# File 'lib/api_reference/models/matrix_config.rb', line 23 def matrix_values @matrix_values end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/api_reference/models/matrix_config.rb', line 51 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 # 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 << (MatrixValue.from_hash(structure) if structure) end end matrix_values = nil unless hash.key?('matrix_values') # Create object from extracted values. MatrixConfig.new(dimensions: dimensions, default_unit_amount: default_unit_amount, matrix_values: matrix_values) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/api_reference/models/matrix_config.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['dimensions'] = 'dimensions' @_hash['default_unit_amount'] = 'default_unit_amount' @_hash['matrix_values'] = 'matrix_values' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/api_reference/models/matrix_config.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/api_reference/models/matrix_config.rb', line 35 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/api_reference/models/matrix_config.rb', line 77 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.dimensions, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.default_unit_amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.matrix_values, ->(val) { MatrixValue.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['dimensions'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['default_unit_amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['matrix_values'], ->(val) { MatrixValue.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
113 114 115 116 117 |
# File 'lib/api_reference/models/matrix_config.rb', line 113 def inspect class_name = self.class.name.split('::').last "<#{class_name} dimensions: #{@dimensions.inspect}, default_unit_amount:"\ " #{@default_unit_amount.inspect}, matrix_values: #{@matrix_values.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
106 107 108 109 110 |
# File 'lib/api_reference/models/matrix_config.rb', line 106 def to_s class_name = self.class.name.split('::').last "<#{class_name} dimensions: #{@dimensions}, default_unit_amount: #{@default_unit_amount},"\ " matrix_values: #{@matrix_values}>" end |