Class: ApiReference::BulkTier
- Defined in:
- lib/api_reference/models/bulk_tier.rb
Overview
Configuration for a single bulk pricing tier
Instance Attribute Summary collapse
-
#maximum_units ⇒ Float
Upper bound for this tier.
-
#unit_amount ⇒ String
Amount per unit.
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(unit_amount:, maximum_units: SKIP) ⇒ BulkTier
constructor
A new instance of BulkTier.
-
#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(unit_amount:, maximum_units: SKIP) ⇒ BulkTier
Returns a new instance of BulkTier.
42 43 44 45 |
# File 'lib/api_reference/models/bulk_tier.rb', line 42 def initialize(unit_amount:, maximum_units: SKIP) @maximum_units = maximum_units unless maximum_units == SKIP @unit_amount = unit_amount end |
Instance Attribute Details
#maximum_units ⇒ Float
Upper bound for this tier
14 15 16 |
# File 'lib/api_reference/models/bulk_tier.rb', line 14 def maximum_units @maximum_units end |
#unit_amount ⇒ String
Amount per unit
18 19 20 |
# File 'lib/api_reference/models/bulk_tier.rb', line 18 def unit_amount @unit_amount end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/api_reference/models/bulk_tier.rb', line 48 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. unit_amount = hash.key?('unit_amount') ? hash['unit_amount'] : nil maximum_units = hash.key?('maximum_units') ? hash['maximum_units'] : SKIP # Create object from extracted values. BulkTier.new(unit_amount: unit_amount, maximum_units: maximum_units) end |
.names ⇒ Object
A mapping from model property names to API property names.
21 22 23 24 25 26 |
# File 'lib/api_reference/models/bulk_tier.rb', line 21 def self.names @_hash = {} if @_hash.nil? @_hash['maximum_units'] = 'maximum_units' @_hash['unit_amount'] = 'unit_amount' @_hash end |
.nullables ⇒ Object
An array for nullable fields
36 37 38 39 40 |
# File 'lib/api_reference/models/bulk_tier.rb', line 36 def self.nullables %w[ maximum_units ] end |
.optionals ⇒ Object
An array for optional fields
29 30 31 32 33 |
# File 'lib/api_reference/models/bulk_tier.rb', line 29 def self.optionals %w[ maximum_units ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/api_reference/models/bulk_tier.rb', line 62 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.unit_amount, ->(val) { val.instance_of? String }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['unit_amount'], ->(val) { val.instance_of? String }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
81 82 83 84 85 |
# File 'lib/api_reference/models/bulk_tier.rb', line 81 def inspect class_name = self.class.name.split('::').last "<#{class_name} maximum_units: #{@maximum_units.inspect}, unit_amount:"\ " #{@unit_amount.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
75 76 77 78 |
# File 'lib/api_reference/models/bulk_tier.rb', line 75 def to_s class_name = self.class.name.split('::').last "<#{class_name} maximum_units: #{@maximum_units}, unit_amount: #{@unit_amount}>" end |