Class: ApiReference::Minimum
- Defined in:
- lib/api_reference/models/minimum.rb
Overview
Minimum Model.
Instance Attribute Summary collapse
-
#applies_to_price_ids ⇒ Array[String]
List of price_ids that this minimum amount applies to.
-
#filters ⇒ Array[PriceFilter]
The filters that determine which prices to apply this minimum to.
-
#minimum_amount ⇒ String
Minimum amount applied.
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(minimum_amount:, filters:, applies_to_price_ids:, additional_properties: nil) ⇒ Minimum
constructor
A new instance of Minimum.
-
#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(minimum_amount:, filters:, applies_to_price_ids:, additional_properties: nil) ⇒ Minimum
Returns a new instance of Minimum.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/api_reference/models/minimum.rb', line 44 def initialize(minimum_amount:, filters:, applies_to_price_ids:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @minimum_amount = minimum_amount @filters = filters @applies_to_price_ids = applies_to_price_ids @additional_properties = additional_properties end |
Instance Attribute Details
#applies_to_price_ids ⇒ Array[String]
List of price_ids that this minimum amount applies to. For plan/plan phase minimums, this can be a subset of prices.
23 24 25 |
# File 'lib/api_reference/models/minimum.rb', line 23 def applies_to_price_ids @applies_to_price_ids end |
#filters ⇒ Array[PriceFilter]
The filters that determine which prices to apply this minimum to.
18 19 20 |
# File 'lib/api_reference/models/minimum.rb', line 18 def filters @filters end |
#minimum_amount ⇒ String
Minimum amount applied
14 15 16 |
# File 'lib/api_reference/models/minimum.rb', line 14 def minimum_amount @minimum_amount end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/api_reference/models/minimum.rb', line 56 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. minimum_amount = hash.key?('minimum_amount') ? hash['minimum_amount'] : nil # Parameter is an array, so we need to iterate through it filters = nil unless hash['filters'].nil? filters = [] hash['filters'].each do |structure| filters << (PriceFilter.from_hash(structure) if structure) end end filters = nil unless hash.key?('filters') applies_to_price_ids = hash.key?('applies_to_price_ids') ? hash['applies_to_price_ids'] : nil # 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. Minimum.new(minimum_amount: minimum_amount, filters: filters, applies_to_price_ids: applies_to_price_ids, 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/minimum.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['minimum_amount'] = 'minimum_amount' @_hash['filters'] = 'filters' @_hash['applies_to_price_ids'] = 'applies_to_price_ids' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/api_reference/models/minimum.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/api_reference/models/minimum.rb', line 35 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/api_reference/models/minimum.rb', line 91 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.minimum_amount, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.filters, ->(val) { PriceFilter.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value.applies_to_price_ids, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['minimum_amount'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['filters'], ->(val) { PriceFilter.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and APIHelper.valid_type?(value['applies_to_price_ids'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
128 129 130 131 132 133 |
# File 'lib/api_reference/models/minimum.rb', line 128 def inspect class_name = self.class.name.split('::').last "<#{class_name} minimum_amount: #{@minimum_amount.inspect}, filters: #{@filters.inspect},"\ " applies_to_price_ids: #{@applies_to_price_ids.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
120 121 122 123 124 125 |
# File 'lib/api_reference/models/minimum.rb', line 120 def to_s class_name = self.class.name.split('::').last "<#{class_name} minimum_amount: #{@minimum_amount}, filters: #{@filters},"\ " applies_to_price_ids: #{@applies_to_price_ids}, additional_properties:"\ " #{@additional_properties}>" end |