Class: ApiReference::Allocation
- Defined in:
- lib/api_reference/models/allocation.rb
Overview
Allocation Model.
Instance Attribute Summary collapse
-
#allows_rollover ⇒ TrueClass | FalseClass
TODO: Write general description for this method.
-
#currency ⇒ String
TODO: Write general description for this method.
-
#custom_expiration ⇒ CustomExpiration
TODO: Write general description for this method.
-
#filters ⇒ Array[PriceFilter]
TODO: Write general description for this method.
-
#license_type_id ⇒ String
TODO: Write general description for this method.
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(currency:, allows_rollover:, custom_expiration:, filters: SKIP, license_type_id: SKIP, additional_properties: nil) ⇒ Allocation
constructor
A new instance of Allocation.
-
#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(currency:, allows_rollover:, custom_expiration:, filters: SKIP, license_type_id: SKIP, additional_properties: nil) ⇒ Allocation
Returns a new instance of Allocation.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/api_reference/models/allocation.rb', line 59 def initialize(currency:, allows_rollover:, custom_expiration:, filters: SKIP, license_type_id: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @currency = currency @allows_rollover = allows_rollover @custom_expiration = custom_expiration @filters = filters unless filters == SKIP @license_type_id = license_type_id unless license_type_id == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#allows_rollover ⇒ TrueClass | FalseClass
TODO: Write general description for this method
18 19 20 |
# File 'lib/api_reference/models/allocation.rb', line 18 def allows_rollover @allows_rollover end |
#currency ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/allocation.rb', line 14 def currency @currency end |
#custom_expiration ⇒ CustomExpiration
TODO: Write general description for this method
22 23 24 |
# File 'lib/api_reference/models/allocation.rb', line 22 def custom_expiration @custom_expiration end |
#filters ⇒ Array[PriceFilter]
TODO: Write general description for this method
26 27 28 |
# File 'lib/api_reference/models/allocation.rb', line 26 def filters @filters end |
#license_type_id ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/api_reference/models/allocation.rb', line 30 def license_type_id @license_type_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 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 104 105 106 107 108 109 110 |
# File 'lib/api_reference/models/allocation.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. currency = hash.key?('currency') ? hash['currency'] : nil allows_rollover = hash.key?('allows_rollover') ? hash['allows_rollover'] : nil custom_expiration = CustomExpiration.from_hash(hash['custom_expiration']) if hash['custom_expiration'] # 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 = SKIP unless hash.key?('filters') license_type_id = hash.key?('license_type_id') ? hash['license_type_id'] : 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. Allocation.new(currency: currency, allows_rollover: allows_rollover, custom_expiration: custom_expiration, filters: filters, license_type_id: license_type_id, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/api_reference/models/allocation.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['currency'] = 'currency' @_hash['allows_rollover'] = 'allows_rollover' @_hash['custom_expiration'] = 'custom_expiration' @_hash['filters'] = 'filters' @_hash['license_type_id'] = 'license_type_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
52 53 54 55 56 57 |
# File 'lib/api_reference/models/allocation.rb', line 52 def self.nullables %w[ custom_expiration license_type_id ] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 |
# File 'lib/api_reference/models/allocation.rb', line 44 def self.optionals %w[ filters license_type_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/api_reference/models/allocation.rb', line 114 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.currency, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.allows_rollover, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.custom_expiration, ->(val) { CustomExpiration.validate(val) }, is_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['currency'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['allows_rollover'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['custom_expiration'], ->(val) { CustomExpiration.validate(val) }, is_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
149 150 151 152 153 154 155 |
# File 'lib/api_reference/models/allocation.rb', line 149 def inspect class_name = self.class.name.split('::').last "<#{class_name} currency: #{@currency.inspect}, allows_rollover:"\ " #{@allows_rollover.inspect}, custom_expiration: #{@custom_expiration.inspect}, filters:"\ " #{@filters.inspect}, license_type_id: #{@license_type_id.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
141 142 143 144 145 146 |
# File 'lib/api_reference/models/allocation.rb', line 141 def to_s class_name = self.class.name.split('::').last "<#{class_name} currency: #{@currency}, allows_rollover: #{@allows_rollover},"\ " custom_expiration: #{@custom_expiration}, filters: #{@filters}, license_type_id:"\ " #{@license_type_id}, additional_properties: #{@additional_properties}>" end |