Class: TestAsdasdasd::Pet

Inherits:
BaseModel show all
Defined in:
lib/test_asdasdasd/models/pet.rb

Overview

Pet Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name = nil, photo_urls = nil, id = nil, category = nil, tags = nil, status = nil) ⇒ Pet

Returns a new instance of Pet.



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/test_asdasdasd/models/pet.rb', line 45

def initialize(name = nil,
               photo_urls = nil,
               id = nil,
               category = nil,
               tags = nil,
               status = nil)
  @id = id
  @category = category
  @name = name
  @photo_urls = photo_urls
  @tags = tags
  @status = status
end

Instance Attribute Details

#categoryCategory

TODO: Write general description for this method

Returns:



15
16
17
# File 'lib/test_asdasdasd/models/pet.rb', line 15

def category
  @category
end

#idLong

TODO: Write general description for this method

Returns:

  • (Long)


11
12
13
# File 'lib/test_asdasdasd/models/pet.rb', line 11

def id
  @id
end

#nameString

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/test_asdasdasd/models/pet.rb', line 19

def name
  @name
end

#photo_urlsList of String

TODO: Write general description for this method

Returns:



23
24
25
# File 'lib/test_asdasdasd/models/pet.rb', line 23

def photo_urls
  @photo_urls
end

#statusStatus1Enum

pet status in the store

Returns:



31
32
33
# File 'lib/test_asdasdasd/models/pet.rb', line 31

def status
  @status
end

#tagsList of Tag

TODO: Write general description for this method

Returns:

  • (List of Tag)


27
28
29
# File 'lib/test_asdasdasd/models/pet.rb', line 27

def tags
  @tags
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
81
82
83
84
85
# File 'lib/test_asdasdasd/models/pet.rb', line 60

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash['name']
  photo_urls = hash['photoUrls']
  id = hash['id']
  category = Category.from_hash(hash['category']) if hash['category']
  # Parameter is an array, so we need to iterate through it
  tags = nil
  unless hash['tags'].nil?
    tags = []
    hash['tags'].each do |structure|
      tags << (Tag.from_hash(structure) if structure)
    end
  end
  status = hash['status']

  # Create object from extracted values.
  Pet.new(name,
          photo_urls,
          id,
          category,
          tags,
          status)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
43
# File 'lib/test_asdasdasd/models/pet.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['category'] = 'category'
  @_hash['name'] = 'name'
  @_hash['photo_urls'] = 'photoUrls'
  @_hash['tags'] = 'tags'
  @_hash['status'] = 'status'
  @_hash
end