Class: ApiReference::NewTieredPercentageDiscountTier
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::NewTieredPercentageDiscountTier
- Defined in:
- lib/api_reference/models/new_tiered_percentage_discount_tier.rb
Overview
NewTieredPercentageDiscountTier Model.
Instance Attribute Summary collapse
-
#lower_bound ⇒ Float
Exclusive lower bound of cumulative spend for this tier.
-
#percentage ⇒ Float
The percentage (0-1) discounted from spend in this tier.
-
#upper_bound ⇒ Float
Inclusive upper bound of cumulative spend; null for the final open-ended 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(lower_bound:, percentage:, upper_bound: SKIP, additional_properties: nil) ⇒ NewTieredPercentageDiscountTier
constructor
A new instance of NewTieredPercentageDiscountTier.
-
#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(lower_bound:, percentage:, upper_bound: SKIP, additional_properties: nil) ⇒ NewTieredPercentageDiscountTier
Returns a new instance of NewTieredPercentageDiscountTier.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 48 def initialize(lower_bound:, percentage:, upper_bound: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @lower_bound = lower_bound @upper_bound = upper_bound unless upper_bound == SKIP @percentage = percentage @additional_properties = additional_properties end |
Instance Attribute Details
#lower_bound ⇒ Float
Exclusive lower bound of cumulative spend for this tier.
14 15 16 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 14 def lower_bound @lower_bound end |
#percentage ⇒ Float
The percentage (0-1) discounted from spend in this tier.
23 24 25 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 23 def percentage @percentage end |
#upper_bound ⇒ Float
Inclusive upper bound of cumulative spend; null for the final open-ended tier.
19 20 21 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 19 def upper_bound @upper_bound end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. lower_bound = hash.key?('lower_bound') ? hash['lower_bound'] : nil percentage = hash.key?('percentage') ? hash['percentage'] : nil upper_bound = hash.key?('upper_bound') ? hash['upper_bound'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. NewTieredPercentageDiscountTier.new(lower_bound: lower_bound, percentage: percentage, upper_bound: upper_bound, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['lower_bound'] = 'lower_bound' @_hash['upper_bound'] = 'upper_bound' @_hash['percentage'] = 'percentage' @_hash end |
.nullables ⇒ Object
An array for nullable fields
42 43 44 45 46 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 42 def self.nullables %w[ upper_bound ] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 38 39 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 35 def self.optionals %w[ upper_bound ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 84 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.lower_bound, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.percentage, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['lower_bound'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['percentage'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
112 113 114 115 116 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 112 def inspect class_name = self.class.name.split('::').last "<#{class_name} lower_bound: #{@lower_bound.inspect}, upper_bound: #{@upper_bound.inspect},"\ " percentage: #{@percentage.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
105 106 107 108 109 |
# File 'lib/api_reference/models/new_tiered_percentage_discount_tier.rb', line 105 def to_s class_name = self.class.name.split('::').last "<#{class_name} lower_bound: #{@lower_bound}, upper_bound: #{@upper_bound}, percentage:"\ " #{@percentage}, additional_properties: #{@additional_properties}>" end |