Class: SwaggerPetstore::PetRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/swagger_petstore/models/pet_request.rb

Overview

PetRequest 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 = SKIP, category = SKIP, tags = SKIP, status = SKIP) ⇒ PetRequest

Returns a new instance of PetRequest.



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/swagger_petstore/models/pet_request.rb', line 63

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

Instance Attribute Details

#categoryCategory2

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/swagger_petstore/models/pet_request.rb', line 18

def category
  @category
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/swagger_petstore/models/pet_request.rb', line 14

def id
  @id
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/swagger_petstore/models/pet_request.rb', line 22

def name
  @name
end

#photo_urlsArray[String]

TODO: Write general description for this method

Returns:

  • (Array[String])


26
27
28
# File 'lib/swagger_petstore/models/pet_request.rb', line 26

def photo_urls
  @photo_urls
end

#statusStatusEnum

TODO: Write general description for this method

Returns:



34
35
36
# File 'lib/swagger_petstore/models/pet_request.rb', line 34

def status
  @status
end

#tagsArray[Tag]

TODO: Write general description for this method

Returns:



30
31
32
# File 'lib/swagger_petstore/models/pet_request.rb', line 30

def tags
  @tags
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/swagger_petstore/models/pet_request.rb', line 78

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  photo_urls = hash.key?('photoUrls') ? hash['photoUrls'] : nil
  id = hash.key?('id') ? hash['id'] : SKIP
  category = Category2.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

  tags = SKIP unless hash.key?('tags')
  status = hash.key?('status') ? hash['status'] : SKIP

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

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
46
# File 'lib/swagger_petstore/models/pet_request.rb', line 37

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

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/swagger_petstore/models/pet_request.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
56
# File 'lib/swagger_petstore/models/pet_request.rb', line 49

def self.optionals
  %w[
    id
    category
    tags
    status
  ]
end