Class: SwaggerPetstoreOpenApi30::PetController

Inherits:
BaseController show all
Defined in:
lib/swagger_petstore_open_api30/controllers/pet_controller.rb

Overview

PetController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from SwaggerPetstoreOpenApi30::BaseController

Instance Method Details

#add_pet(name, photo_urls, id: nil, category: nil, tags: nil, pet_status: nil) ⇒ Pet

Add a new pet to the store store

Parameters:

  • name (String)

    Required parameter: Example:

  • photo_urls (Array[String])

    Required parameter: Example:

  • id (Integer) (defaults to: nil)

    Optional parameter: Example:

  • category (Category) (defaults to: nil)

    Optional parameter: Example:

  • tags (Array[Tag]) (defaults to: nil)

    Optional parameter: Example:

  • pet_status (PetStatusEnum) (defaults to: nil)

    Optional parameter: pet status in the

Returns:

  • (Pet)

    response from the API call



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 18

def add_pet(name,
            photo_urls,
            id: nil,
            category: nil,
            tags: nil,
            pet_status: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pet',
                                 Server::DEFAULT)
               .form_param(new_parameter(name, key: 'name'))
               .form_param(new_parameter(photo_urls, key: 'photoUrls'))
               .form_param(new_parameter(id, key: 'id'))
               .form_param(new_parameter(category, key: 'category'))
               .form_param(new_parameter(tags, key: 'tags'))
               .form_param(new_parameter(pet_status, key: 'petStatus'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Pet.method(:from_hash))
               .local_error('405',
                            'Invalid input',
                            APIException))
    .execute
end

#delete_pet(pet_id, api_key: nil) ⇒ void

This method returns an undefined value.

delete a pet

Parameters:

  • pet_id (Integer)

    Required parameter: Pet id to delete

  • api_key (String) (defaults to: nil)

    Optional parameter: Example:



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 70

def delete_pet(pet_id,
               api_key: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/pet/{petId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .should_encode(true))
               .header_param(new_parameter(api_key, key: 'api_key')))
    .response(new_response_handler
               .is_response_void(true)
               .local_error('400',
                            'Invalid pet value',
                            APIException))
    .execute
end

#find_pets_by_status(status: StatusEnum::AVAILABLE) ⇒ Array[Pet]

Multiple status values can be provided with comma separated strings be considered for filter

Parameters:

  • status (StatusEnum) (defaults to: StatusEnum::AVAILABLE)

    Optional parameter: Status values that need to

Returns:

  • (Array[Pet])

    response from the API call



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 209

def find_pets_by_status(status: StatusEnum::AVAILABLE)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/pet/findByStatus',
                                 Server::DEFAULT)
               .query_param(new_parameter(status, key: 'status'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Pet.method(:from_hash))
               .is_response_array(true)
               .local_error('400',
                            'Invalid status value',
                            APIException))
    .execute
end

#find_pets_by_tags(tags: nil) ⇒ Array[Pet]

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Parameters:

  • tags (Array[String]) (defaults to: nil)

    Optional parameter: Tags to filter by

Returns:

  • (Array[Pet])

    response from the API call



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 49

def find_pets_by_tags(tags: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/pet/findByTags',
                                 Server::DEFAULT)
               .query_param(new_parameter(tags, key: 'tags'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Pet.method(:from_hash))
               .is_response_array(true)
               .local_error('400',
                            'Invalid tag value',
                            APIException))
    .execute
end

#get_pet_by_id(pet_id) ⇒ Pet

Returns a single pet

Parameters:

  • pet_id (Integer)

    Required parameter: ID of pet to return

Returns:

  • (Pet)

    response from the API call



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 90

def get_pet_by_id(pet_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/pet/{petId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('api_key')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Pet.method(:from_hash))
               .local_error('400',
                            'Invalid ID supplied',
                            APIException)
               .local_error('404',
                            'Pet not found',
                            APIException))
    .execute
end

#update_pet(name, photo_urls, id: nil, category: nil, tags: nil, pet_status: nil) ⇒ Pet

Update an existing pet by Id store

Parameters:

  • name (String)

    Required parameter: Example:

  • photo_urls (Array[String])

    Required parameter: Example:

  • id (Integer) (defaults to: nil)

    Optional parameter: Example:

  • category (Category) (defaults to: nil)

    Optional parameter: Example:

  • tags (Array[Tag]) (defaults to: nil)

    Optional parameter: Example:

  • pet_status (PetStatusEnum) (defaults to: nil)

    Optional parameter: pet status in the

Returns:

  • (Pet)

    response from the API call



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
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 172

def update_pet(name,
               photo_urls,
               id: nil,
               category: nil,
               tags: nil,
               pet_status: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/pet',
                                 Server::DEFAULT)
               .form_param(new_parameter(name, key: 'name'))
               .form_param(new_parameter(photo_urls, key: 'photoUrls'))
               .form_param(new_parameter(id, key: 'id'))
               .form_param(new_parameter(category, key: 'category'))
               .form_param(new_parameter(tags, key: 'tags'))
               .form_param(new_parameter(pet_status, key: 'petStatus'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Pet.method(:from_hash))
               .local_error('400',
                            'Invalid ID supplied',
                            APIException)
               .local_error('404',
                            'Pet not found',
                            APIException)
               .local_error('405',
                            'Validation exception',
                            APIException))
    .execute
end

#update_pet_with_form(pet_id, name: nil, status: nil) ⇒ void

This method returns an undefined value.

TODO: type endpoint description here updated updated updated

Parameters:

  • pet_id (Integer)

    Required parameter: ID of pet that needs to be

  • name (String) (defaults to: nil)

    Optional parameter: Name of pet that needs to be

  • status (String) (defaults to: nil)

    Optional parameter: Status of pet that needs to be



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 119

def update_pet_with_form(pet_id,
                         name: nil,
                         status: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pet/{petId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .should_encode(true))
               .query_param(new_parameter(name, key: 'name'))
               .query_param(new_parameter(status, key: 'status')))
    .response(new_response_handler
               .is_response_void(true)
               .local_error('405',
                            'Invalid input',
                            APIException))
    .execute
end

#upload_file(pet_id, additional_metadata: nil, body: nil) ⇒ PetImage

TODO: type endpoint description here Metadata

Parameters:

  • pet_id (Integer)

    Required parameter: ID of pet to update

  • additional_metadata (String) (defaults to: nil)

    Optional parameter: Additional

  • body (File | UploadIO) (defaults to: nil)

    Optional parameter: Example:

Returns:

  • (PetImage)

    response from the API call



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/swagger_petstore_open_api30/controllers/pet_controller.rb', line 144

def upload_file(pet_id,
                additional_metadata: nil,
                body: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pet/{petId}/uploadImage',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .should_encode(true))
               .query_param(new_parameter(, key: 'additionalMetadata'))
               .multipart_param(new_parameter(body, key: 'body')
                                 .default_content_type('application/octet-stream'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(PetImage.method(:from_hash)))
    .execute
end