Class: ApiReference::TieredConfig
- Defined in:
- lib/api_reference/models/tiered_config.rb
Overview
Configuration for tiered pricing
Instance Attribute Summary collapse
-
#prorated ⇒ TrueClass | FalseClass
If true, subtotals from this price are prorated based on the service period.
-
#tiers ⇒ Array[Tier]
Tiers for rating based on total usage quantities into the specified tier.
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(tiers:, prorated: false) ⇒ TieredConfig
constructor
A new instance of TieredConfig.
-
#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(tiers:, prorated: false) ⇒ TieredConfig
Returns a new instance of TieredConfig.
41 42 43 44 |
# File 'lib/api_reference/models/tiered_config.rb', line 41 def initialize(tiers:, prorated: false) @tiers = tiers @prorated = prorated unless prorated == SKIP end |
Instance Attribute Details
#prorated ⇒ TrueClass | FalseClass
If true, subtotals from this price are prorated based on the service period
19 20 21 |
# File 'lib/api_reference/models/tiered_config.rb', line 19 def prorated @prorated end |
#tiers ⇒ Array[Tier]
Tiers for rating based on total usage quantities into the specified tier
14 15 16 |
# File 'lib/api_reference/models/tiered_config.rb', line 14 def tiers @tiers end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/api_reference/models/tiered_config.rb', line 47 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 << (Tier.from_hash(structure) if structure) end end tiers = nil unless hash.key?('tiers') prorated = hash['prorated'] ||= false # Create object from extracted values. TieredConfig.new(tiers: tiers, prorated: prorated) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 27 |
# File 'lib/api_reference/models/tiered_config.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['tiers'] = 'tiers' @_hash['prorated'] = 'prorated' @_hash end |
.nullables ⇒ Object
An array for nullable fields
37 38 39 |
# File 'lib/api_reference/models/tiered_config.rb', line 37 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
30 31 32 33 34 |
# File 'lib/api_reference/models/tiered_config.rb', line 30 def self.optionals %w[ prorated ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/api_reference/models/tiered_config.rb', line 70 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.tiers, ->(val) { Tier.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) { Tier.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.
93 94 95 96 |
# File 'lib/api_reference/models/tiered_config.rb', line 93 def inspect class_name = self.class.name.split('::').last "<#{class_name} tiers: #{@tiers.inspect}, prorated: #{@prorated.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
87 88 89 90 |
# File 'lib/api_reference/models/tiered_config.rb', line 87 def to_s class_name = self.class.name.split('::').last "<#{class_name} tiers: #{@tiers}, prorated: #{@prorated}>" end |