Class: PokeApiClient::PokemonDetail

Inherits:
ApiModelBase show all
Defined in:
lib/pokeapi_client/models/pokemon_detail.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ PokemonDetail

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 132

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `PokeApiClient::PokemonDetail` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `PokeApiClient::PokemonDetail`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  else
    self.name = nil
  end

  if attributes.key?(:'base_experience')
    self.base_experience = attributes[:'base_experience']
  end

  if attributes.key?(:'height')
    self.height = attributes[:'height']
  end

  if attributes.key?(:'is_default')
    self.is_default = attributes[:'is_default']
  end

  if attributes.key?(:'order')
    self.order = attributes[:'order']
  end

  if attributes.key?(:'weight')
    self.weight = attributes[:'weight']
  end

  if attributes.key?(:'abilities')
    if (value = attributes[:'abilities']).is_a?(Array)
      self.abilities = value
    end
  else
    self.abilities = nil
  end

  if attributes.key?(:'past_abilities')
    if (value = attributes[:'past_abilities']).is_a?(Array)
      self.past_abilities = value
    end
  else
    self.past_abilities = nil
  end

  if attributes.key?(:'forms')
    if (value = attributes[:'forms']).is_a?(Array)
      self.forms = value
    end
  else
    self.forms = nil
  end

  if attributes.key?(:'game_indices')
    if (value = attributes[:'game_indices']).is_a?(Array)
      self.game_indices = value
    end
  else
    self.game_indices = nil
  end

  if attributes.key?(:'held_items')
    self.held_items = attributes[:'held_items']
  else
    self.held_items = nil
  end

  if attributes.key?(:'location_area_encounters')
    self.location_area_encounters = attributes[:'location_area_encounters']
  else
    self.location_area_encounters = nil
  end

  if attributes.key?(:'moves')
    if (value = attributes[:'moves']).is_a?(Array)
      self.moves = value
    end
  else
    self.moves = nil
  end

  if attributes.key?(:'species')
    self.species = attributes[:'species']
  else
    self.species = nil
  end

  if attributes.key?(:'sprites')
    self.sprites = attributes[:'sprites']
  else
    self.sprites = nil
  end

  if attributes.key?(:'cries')
    self.cries = attributes[:'cries']
  else
    self.cries = nil
  end

  if attributes.key?(:'stats')
    if (value = attributes[:'stats']).is_a?(Array)
      self.stats = value
    end
  else
    self.stats = nil
  end

  if attributes.key?(:'types')
    if (value = attributes[:'types']).is_a?(Array)
      self.types = value
    end
  else
    self.types = nil
  end

  if attributes.key?(:'past_types')
    if (value = attributes[:'past_types']).is_a?(Array)
      self.past_types = value
    end
  else
    self.past_types = nil
  end
end

Instance Attribute Details

#abilitiesObject

Returns the value of attribute abilities.



32
33
34
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 32

def abilities
  @abilities
end

#base_experienceObject

Returns the value of attribute base_experience.



22
23
24
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 22

def base_experience
  @base_experience
end

#criesObject

Returns the value of attribute cries.



50
51
52
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 50

def cries
  @cries
end

#formsObject

Returns the value of attribute forms.



36
37
38
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 36

def forms
  @forms
end

#game_indicesObject

Returns the value of attribute game_indices.



38
39
40
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 38

def game_indices
  @game_indices
end

#heightObject

Returns the value of attribute height.



24
25
26
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 24

def height
  @height
end

#held_itemsObject

Returns the value of attribute held_items.



40
41
42
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 40

def held_items
  @held_items
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 18

def id
  @id
end

#is_defaultObject

Returns the value of attribute is_default.



26
27
28
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 26

def is_default
  @is_default
end

#location_area_encountersObject

Returns the value of attribute location_area_encounters.



42
43
44
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 42

def location_area_encounters
  @location_area_encounters
end

#movesObject

Returns the value of attribute moves.



44
45
46
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 44

def moves
  @moves
end

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 20

def name
  @name
end

#orderObject

Returns the value of attribute order.



28
29
30
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 28

def order
  @order
end

#past_abilitiesObject

Returns the value of attribute past_abilities.



34
35
36
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 34

def past_abilities
  @past_abilities
end

#past_typesObject

Returns the value of attribute past_types.



56
57
58
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 56

def past_types
  @past_types
end

#speciesObject

Returns the value of attribute species.



46
47
48
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 46

def species
  @species
end

#spritesObject

Returns the value of attribute sprites.



48
49
50
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 48

def sprites
  @sprites
end

#statsObject

Returns the value of attribute stats.



52
53
54
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 52

def stats
  @stats
end

#typesObject

Returns the value of attribute types.



54
55
56
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 54

def types
  @types
end

#weightObject

Returns the value of attribute weight.



30
31
32
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 30

def weight
  @weight
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



85
86
87
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 85

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



90
91
92
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 90

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 59

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'base_experience' => :'base_experience',
    :'height' => :'height',
    :'is_default' => :'is_default',
    :'order' => :'order',
    :'weight' => :'weight',
    :'abilities' => :'abilities',
    :'past_abilities' => :'past_abilities',
    :'forms' => :'forms',
    :'game_indices' => :'game_indices',
    :'held_items' => :'held_items',
    :'location_area_encounters' => :'location_area_encounters',
    :'moves' => :'moves',
    :'species' => :'species',
    :'sprites' => :'sprites',
    :'cries' => :'cries',
    :'stats' => :'stats',
    :'types' => :'types',
    :'past_types' => :'past_types'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 564

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



121
122
123
124
125
126
127
128
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 121

def self.openapi_nullable
  Set.new([
    :'base_experience',
    :'height',
    :'order',
    :'weight',
  ])
end

.openapi_typesObject

Attribute type mapping.



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 95

def self.openapi_types
  {
    :'id' => :'Integer',
    :'name' => :'String',
    :'base_experience' => :'Integer',
    :'height' => :'Integer',
    :'is_default' => :'Boolean',
    :'order' => :'Integer',
    :'weight' => :'Integer',
    :'abilities' => :'Array<PokemonDetailAbilitiesInner>',
    :'past_abilities' => :'Array<PokemonDetailPastAbilitiesInner>',
    :'forms' => :'Array<PokemonFormSummary>',
    :'game_indices' => :'Array<PokemonGameIndex>',
    :'held_items' => :'PokemonDetailHeldItems',
    :'location_area_encounters' => :'String',
    :'moves' => :'Array<PokemonDetailMovesInner>',
    :'species' => :'PokemonSpeciesSummary',
    :'sprites' => :'PokemonDetailSprites',
    :'cries' => :'PokemonDetailCries',
    :'stats' => :'Array<PokemonStat>',
    :'types' => :'Array<PokemonDetailTypesInner>',
    :'past_types' => :'Array<PokemonDetailPastTypesInner>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 524

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      base_experience == o.base_experience &&
      height == o.height &&
      is_default == o.is_default &&
      order == o.order &&
      weight == o.weight &&
      abilities == o.abilities &&
      past_abilities == o.past_abilities &&
      forms == o.forms &&
      game_indices == o.game_indices &&
      held_items == o.held_items &&
      location_area_encounters == o.location_area_encounters &&
      moves == o.moves &&
      species == o.species &&
      sprites == o.sprites &&
      cries == o.cries &&
      stats == o.stats &&
      types == o.types &&
      past_types == o.past_types
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


551
552
553
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 551

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



557
558
559
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 557

def hash
  [id, name, base_experience, height, is_default, order, weight, abilities, past_abilities, forms, game_indices, held_items, location_area_encounters, moves, species, sprites, cries, stats, types, past_types].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 275

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

  if @name.to_s.length > 100
    invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
  end

  if @abilities.nil?
    invalid_properties.push('invalid value for "abilities", abilities cannot be nil.')
  end

  if @past_abilities.nil?
    invalid_properties.push('invalid value for "past_abilities", past_abilities cannot be nil.')
  end

  if @forms.nil?
    invalid_properties.push('invalid value for "forms", forms cannot be nil.')
  end

  if @game_indices.nil?
    invalid_properties.push('invalid value for "game_indices", game_indices cannot be nil.')
  end

  if @held_items.nil?
    invalid_properties.push('invalid value for "held_items", held_items cannot be nil.')
  end

  if @location_area_encounters.nil?
    invalid_properties.push('invalid value for "location_area_encounters", location_area_encounters cannot be nil.')
  end

  if @moves.nil?
    invalid_properties.push('invalid value for "moves", moves cannot be nil.')
  end

  if @species.nil?
    invalid_properties.push('invalid value for "species", species cannot be nil.')
  end

  if @sprites.nil?
    invalid_properties.push('invalid value for "sprites", sprites cannot be nil.')
  end

  if @cries.nil?
    invalid_properties.push('invalid value for "cries", cries cannot be nil.')
  end

  if @stats.nil?
    invalid_properties.push('invalid value for "stats", stats cannot be nil.')
  end

  if @types.nil?
    invalid_properties.push('invalid value for "types", types cannot be nil.')
  end

  if @past_types.nil?
    invalid_properties.push('invalid value for "past_types", past_types cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 586

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/pokeapi_client/models/pokemon_detail.rb', line 347

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @name.nil?
  return false if @name.to_s.length > 100
  return false if @abilities.nil?
  return false if @past_abilities.nil?
  return false if @forms.nil?
  return false if @game_indices.nil?
  return false if @held_items.nil?
  return false if @location_area_encounters.nil?
  return false if @moves.nil?
  return false if @species.nil?
  return false if @sprites.nil?
  return false if @cries.nil?
  return false if @stats.nil?
  return false if @types.nil?
  return false if @past_types.nil?
  true
end