Class: SwaggerPetstoreOpenApi30::PetApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/swagger_petstore_open_api30/apis/pet_api.rb

Overview

PetApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SwaggerPetstoreOpenApi30::BaseApi

Instance Method Details

#add_pet(name, photo_urls, id: nil, category: nil, tags: nil, status: nil) ⇒ ApiResponse

Add a new pet to the store. description here here

Parameters:

  • name (String)

    Required parameter: TODO: type description here

  • photo_urls (Array[String])

    Required parameter: TODO: type

  • id (Integer) (defaults to: nil)

    Optional parameter: TODO: type description here

  • category (Category) (defaults to: nil)

    Optional parameter: TODO: type description

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

    Optional parameter: TODO: type description here

  • status (PetStatus) (defaults to: nil)

    Optional parameter: pet status in the store

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



69
70
71
72
73
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
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 69

def add_pet(name,
            photo_urls,
            id: nil,
            category: nil,
            tags: nil,
            status: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pet',
                                 Server::DEFAULT)
               .form_param(new_parameter(name, key: 'name')
                            .is_required(true))
               .form_param(new_parameter(photo_urls, key: 'photoUrls')
                            .is_required(true))
               .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(status, key: 'status'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Pet.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid input',
                             APIException)
                .local_error('422',
                             'Validation exception',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end

#delete_pet(pet_id, api_key: nil) ⇒ ApiResponse

Delete a pet.

Parameters:

  • pet_id (Integer)

    Required parameter: Pet id to delete

  • api_key (String) (defaults to: nil)

    Optional parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 226

def delete_pet(pet_id,
               api_key: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/pet/{petId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(api_key, key: 'api_key'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Invalid pet value',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end

#find_pets_by_status(status: nil) ⇒ ApiResponse

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

Parameters:

  • status (PetStatus) (defaults to: nil)

    Optional parameter: Status values that need to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 110

def find_pets_by_status(status: nil)
  @api_call
    .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'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Pet.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error('400',
                             'Invalid status value',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end

#find_pets_by_tags(tags: nil) ⇒ ApiResponse

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:

  • (ApiResponse)

    Complete http response with raw body and status code.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 136

def find_pets_by_tags(tags: nil)
  @api_call
    .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'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Pet.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error('400',
                             'Invalid tag value',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end

#get_pet_by_id(pet_id) ⇒ ApiResponse

Returns a single pet.

Parameters:

  • pet_id (Integer)

    Required parameter: ID of pet to return

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 161

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

#update_pet(name, photo_urls, id: nil, category: nil, tags: nil, status: nil) ⇒ ApiResponse

Update an existing pet by Id. description here here

Parameters:

  • name (String)

    Required parameter: TODO: type description here

  • photo_urls (Array[String])

    Required parameter: TODO: type

  • id (Integer) (defaults to: nil)

    Optional parameter: TODO: type description here

  • category (Category) (defaults to: nil)

    Optional parameter: TODO: type description

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

    Optional parameter: TODO: type description here

  • status (PetStatus) (defaults to: nil)

    Optional parameter: pet status in the store

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 19

def update_pet(name,
               photo_urls,
               id: nil,
               category: nil,
               tags: nil,
               status: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/pet',
                                 Server::DEFAULT)
               .form_param(new_parameter(name, key: 'name')
                            .is_required(true))
               .form_param(new_parameter(photo_urls, key: 'photoUrls')
                            .is_required(true))
               .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(status, key: 'status'))
               .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Pet.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid ID supplied',
                             APIException)
                .local_error('404',
                             'Pet not found',
                             APIException)
                .local_error('422',
                             'Validation exception',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end

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

Updates a pet resource based on the form data. 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

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 195

def update_pet_with_form(pet_id,
                         name: nil,
                         status: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pet/{petId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(name, key: 'name'))
               .query_param(new_parameter(status, key: 'status'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Pet.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid input',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end

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

Upload image of the pet. Metadata here

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: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/swagger_petstore_open_api30/apis/pet_api.rb', line 256

def upload_file(pet_id,
                additional_metadata: nil,
                body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/pet/{petId}/uploadImage',
                                 Server::DEFAULT)
               .template_param(new_parameter(pet_id, key: 'petId')
                                .is_required(true)
                                .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'))
               .auth(Single.new('petstore_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ApiResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'No file uploaded',
                             APIException)
                .local_error('404',
                             'Pet not found',
                             APIException)
                .local_error('default',
                             'Unexpected error',
                             APIException))
    .execute
end