Class: ApiReference::ScalableMatrixWithTieredPricingConfig1

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

Overview

Configuration for scalable_matrix_with_tiered_pricing 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(tiers:, first_dimension:, matrix_scaling_factors:, second_dimension: SKIP) ⇒ ScalableMatrixWithTieredPricingConfig1

Returns a new instance of ScalableMatrixWithTieredPricingConfig1.



52
53
54
55
56
57
58
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 52

def initialize(tiers:, first_dimension:, matrix_scaling_factors:,
               second_dimension: SKIP)
  @tiers = tiers
  @first_dimension = first_dimension
  @second_dimension = second_dimension unless second_dimension == SKIP
  @matrix_scaling_factors = matrix_scaling_factors
end

Instance Attribute Details

#first_dimensionString

Used for the scalable matrix first dimension

Returns:

  • (String)


18
19
20
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 18

def first_dimension
  @first_dimension
end

#matrix_scaling_factorsArray[ScalableMatrixWithTieredScalingFactor]

Apply a scaling factor to each dimension



26
27
28
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 26

def matrix_scaling_factors
  @matrix_scaling_factors
end

#second_dimensionString

Used for the scalable matrix second dimension (optional)

Returns:

  • (String)


22
23
24
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 22

def second_dimension
  @second_dimension
end

#tiersArray[ScalableMatrixWithTieredTierEntry]

TODO: Write general description for this method



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

def tiers
  @tiers
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 61

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
  tiers = nil
  unless hash['tiers'].nil?
    tiers = []
    hash['tiers'].each do |structure|
      tiers << (ScalableMatrixWithTieredTierEntry.from_hash(structure) if structure)
    end
  end

  tiers = nil unless hash.key?('tiers')
  first_dimension =
    hash.key?('first_dimension') ? hash['first_dimension'] : nil
  # Parameter is an array, so we need to iterate through it
  matrix_scaling_factors = nil
  unless hash['matrix_scaling_factors'].nil?
    matrix_scaling_factors = []
    hash['matrix_scaling_factors'].each do |structure|
      matrix_scaling_factors << (ScalableMatrixWithTieredScalingFactor.from_hash(structure) if structure)
    end
  end

  matrix_scaling_factors = nil unless hash.key?('matrix_scaling_factors')
  second_dimension =
    hash.key?('second_dimension') ? hash['second_dimension'] : SKIP

  # Create object from extracted values.
  ScalableMatrixWithTieredPricingConfig1.new(tiers: tiers,
                                             first_dimension: first_dimension,
                                             matrix_scaling_factors: matrix_scaling_factors,
                                             second_dimension: second_dimension)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['tiers'] = 'tiers'
  @_hash['first_dimension'] = 'first_dimension'
  @_hash['second_dimension'] = 'second_dimension'
  @_hash['matrix_scaling_factors'] = 'matrix_scaling_factors'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
49
50
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 46

def self.nullables
  %w[
    second_dimension
  ]
end

.optionalsObject

An array for optional fields



39
40
41
42
43
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 39

def self.optionals
  %w[
    second_dimension
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 99

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.tiers,
                            ->(val) { ScalableMatrixWithTieredTierEntry.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
        APIHelper.valid_type?(value.first_dimension,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.matrix_scaling_factors,
                              ->(val) { ScalableMatrixWithTieredScalingFactor.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['tiers'],
                          ->(val) { ScalableMatrixWithTieredTierEntry.validate(val) },
                          is_model_hash: true,
                          is_inner_model_hash: true) and
      APIHelper.valid_type?(value['first_dimension'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['matrix_scaling_factors'],
                            ->(val) { ScalableMatrixWithTieredScalingFactor.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.



139
140
141
142
143
144
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 139

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

#to_sObject

Provides a human-readable string representation of the object.



132
133
134
135
136
# File 'lib/api_reference/models/scalable_matrix_with_tiered_pricing_config1.rb', line 132

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} tiers: #{@tiers}, first_dimension: #{@first_dimension}, second_dimension:"\
  " #{@second_dimension}, matrix_scaling_factors: #{@matrix_scaling_factors}>"
end