Class: ApiReference::MatrixWithThresholdDiscountsConfig
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::MatrixWithThresholdDiscountsConfig
- Defined in:
- lib/api_reference/models/matrix_with_threshold_discounts_config.rb
Overview
Matrix pricing with per-dimension-subset threshold discounts. Each threshold-discount group targets a subset of matrix cells and applies a two-rate discount: a baseline % on spend at or below a threshold, and a steeper % on spend above.
Instance Attribute Summary collapse
-
#default_unit_amount ⇒ String
Unit price used for usage that does not match any defined matrix cell.
-
#first_dimension ⇒ String
First matrix dimension key.
-
#matrix_values ⇒ Array[MatrixCell]
Per-cell unit prices.
-
#second_dimension ⇒ String
Optional second matrix dimension key.
-
#threshold_discount_groups ⇒ Array[ThresholdDiscountGroup]
Per-cell unit prices.
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.
Instance Method Summary collapse
-
#initialize(first_dimension:, default_unit_amount:, matrix_values:, second_dimension: SKIP, threshold_discount_groups: SKIP) ⇒ MatrixWithThresholdDiscountsConfig
constructor
A new instance of MatrixWithThresholdDiscountsConfig.
-
#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(first_dimension:, default_unit_amount:, matrix_values:, second_dimension: SKIP, threshold_discount_groups: SKIP) ⇒ MatrixWithThresholdDiscountsConfig
Returns a new instance of MatrixWithThresholdDiscountsConfig.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 61 def initialize(first_dimension:, default_unit_amount:, matrix_values:, second_dimension: SKIP, threshold_discount_groups: SKIP) @first_dimension = first_dimension @second_dimension = second_dimension unless second_dimension == SKIP @default_unit_amount = default_unit_amount @matrix_values = matrix_values unless threshold_discount_groups == SKIP @threshold_discount_groups = threshold_discount_groups end end |
Instance Attribute Details
#default_unit_amount ⇒ String
Unit price used for usage that does not match any defined matrix cell.
25 26 27 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 25 def default_unit_amount @default_unit_amount end |
#first_dimension ⇒ String
First matrix dimension key.
17 18 19 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 17 def first_dimension @first_dimension end |
#matrix_values ⇒ Array[MatrixCell]
Per-cell unit prices.
29 30 31 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 29 def matrix_values @matrix_values end |
#second_dimension ⇒ String
Optional second matrix dimension key.
21 22 23 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 21 def second_dimension @second_dimension end |
#threshold_discount_groups ⇒ Array[ThresholdDiscountGroup]
Per-cell unit prices.
33 34 35 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 33 def threshold_discount_groups @threshold_discount_groups end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 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 104 105 106 107 108 109 110 111 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. first_dimension = hash.key?('first_dimension') ? hash['first_dimension'] : 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 << (MatrixCell.from_hash(structure) if structure) end end matrix_values = nil unless hash.key?('matrix_values') second_dimension = hash.key?('second_dimension') ? hash['second_dimension'] : SKIP # Parameter is an array, so we need to iterate through it threshold_discount_groups = nil unless hash['threshold_discount_groups'].nil? threshold_discount_groups = [] hash['threshold_discount_groups'].each do |structure| threshold_discount_groups << (ThresholdDiscountGroup.from_hash(structure) if structure) end end threshold_discount_groups = SKIP unless hash.key?('threshold_discount_groups') # Create object from extracted values. MatrixWithThresholdDiscountsConfig.new(first_dimension: first_dimension, default_unit_amount: default_unit_amount, matrix_values: matrix_values, second_dimension: second_dimension, threshold_discount_groups: threshold_discount_groups) end |
.names ⇒ Object
A mapping from model property names to API property names.
36 37 38 39 40 41 42 43 44 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 36 def self.names @_hash = {} if @_hash.nil? @_hash['first_dimension'] = 'first_dimension' @_hash['second_dimension'] = 'second_dimension' @_hash['default_unit_amount'] = 'default_unit_amount' @_hash['matrix_values'] = 'matrix_values' @_hash['threshold_discount_groups'] = 'threshold_discount_groups' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 58 59 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 55 def self.nullables %w[ second_dimension ] end |
.optionals ⇒ Object
An array for optional fields
47 48 49 50 51 52 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 47 def self.optionals %w[ second_dimension threshold_discount_groups ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
122 123 124 125 126 127 128 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 122 def inspect class_name = self.class.name.split('::').last "<#{class_name} first_dimension: #{@first_dimension.inspect}, second_dimension:"\ " #{@second_dimension.inspect}, default_unit_amount: #{@default_unit_amount.inspect},"\ " matrix_values: #{@matrix_values.inspect}, threshold_discount_groups:"\ " #{@threshold_discount_groups.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
114 115 116 117 118 119 |
# File 'lib/api_reference/models/matrix_with_threshold_discounts_config.rb', line 114 def to_s class_name = self.class.name.split('::').last "<#{class_name} first_dimension: #{@first_dimension}, second_dimension:"\ " #{@second_dimension}, default_unit_amount: #{@default_unit_amount}, matrix_values:"\ " #{@matrix_values}, threshold_discount_groups: #{@threshold_discount_groups}>" end |