Class: ApiReference::CumulativeGroupedAllocationConfig1

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

Overview

Configuration for cumulative_grouped_allocation 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(grouping_key:, group_allocation:, cumulative_allocation:, unit_amount:) ⇒ CumulativeGroupedAllocationConfig1

Returns a new instance of CumulativeGroupedAllocationConfig1.



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

def initialize(grouping_key:, group_allocation:, cumulative_allocation:,
               unit_amount:)
  @grouping_key = grouping_key
  @group_allocation = group_allocation
  @cumulative_allocation = cumulative_allocation
  @unit_amount = unit_amount
end

Instance Attribute Details

#cumulative_allocationString

The overall allocation across all groups

Returns:

  • (String)


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

def cumulative_allocation
  @cumulative_allocation
end

#group_allocationString

The allocation per individual group

Returns:

  • (String)


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

def group_allocation
  @group_allocation
end

#grouping_keyString

The event property used to group usage before applying allocations

Returns:

  • (String)


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

def grouping_key
  @grouping_key
end

#unit_amountString

The amount to charge for each unit outside of the allocation

Returns:

  • (String)


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

def unit_amount
  @unit_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/api_reference/models/cumulative_grouped_allocation_config1.rb', line 57

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  grouping_key = hash.key?('grouping_key') ? hash['grouping_key'] : nil
  group_allocation =
    hash.key?('group_allocation') ? hash['group_allocation'] : nil
  cumulative_allocation =
    hash.key?('cumulative_allocation') ? hash['cumulative_allocation'] : nil
  unit_amount = hash.key?('unit_amount') ? hash['unit_amount'] : nil

  # Create object from extracted values.
  CumulativeGroupedAllocationConfig1.new(grouping_key: grouping_key,
                                         group_allocation: group_allocation,
                                         cumulative_allocation: cumulative_allocation,
                                         unit_amount: unit_amount)
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/cumulative_grouped_allocation_config1.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['grouping_key'] = 'grouping_key'
  @_hash['group_allocation'] = 'group_allocation'
  @_hash['cumulative_allocation'] = 'cumulative_allocation'
  @_hash['unit_amount'] = 'unit_amount'
  @_hash
end

.nullablesObject

An array for nullable fields



44
45
46
# File 'lib/api_reference/models/cumulative_grouped_allocation_config1.rb', line 44

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
# File 'lib/api_reference/models/cumulative_grouped_allocation_config1.rb', line 39

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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/cumulative_grouped_allocation_config1.rb', line 77

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.grouping_key,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.group_allocation,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.cumulative_allocation,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.unit_amount,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['grouping_key'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['group_allocation'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['cumulative_allocation'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['unit_amount'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



113
114
115
116
117
118
# File 'lib/api_reference/models/cumulative_grouped_allocation_config1.rb', line 113

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} grouping_key: #{@grouping_key.inspect}, group_allocation:"\
  " #{@group_allocation.inspect}, cumulative_allocation: #{@cumulative_allocation.inspect},"\
  " unit_amount: #{@unit_amount.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



106
107
108
109
110
# File 'lib/api_reference/models/cumulative_grouped_allocation_config1.rb', line 106

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} grouping_key: #{@grouping_key}, group_allocation: #{@group_allocation},"\
  " cumulative_allocation: #{@cumulative_allocation}, unit_amount: #{@unit_amount}>"
end