Class: SwaggerPetstore::PetController
- Inherits:
-
BaseController
- Object
- BaseController
- SwaggerPetstore::PetController
- Defined in:
- lib/swagger_petstore/controllers/pet_controller.rb
Overview
PetController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#add_pet(body) ⇒ void
Add a new pet to the store the store.
-
#delete_pet(pet_id, api_key: nil) ⇒ void
Deletes a pet.
-
#find_pets_by_status(status) ⇒ List of Pet
Multiple status values can be provided with comma separated strings need to be considered for filter.
-
#find_pets_by_tags(tags) ⇒ List of Pet
Multiple tags can be provided with comma separated strings.
-
#get_pet_by_id(pet_id) ⇒ Pet
Returns a single pet.
-
#update_pet(body) ⇒ void
Update an existing pet the store.
-
#update_pet_with_form(pet_id, name: nil, status: nil) ⇒ void
Updates a pet in the store with form data updated.
-
#upload_file(pet_id, additional_metadata: nil, file: nil) ⇒ ApiResponse
uploads an image pass to server.
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 SwaggerPetstore::BaseController
Instance Method Details
#add_pet(body) ⇒ void
This method returns an undefined value.
Add a new pet to the store the store
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 39 def add_pet(body) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/pet', Server::SERVER1) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .is_response_void(true) .local_error('405', 'Invalid input', APIException)) .execute end |
#delete_pet(pet_id, api_key: nil) ⇒ void
This method returns an undefined value.
Deletes a pet
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 183 def delete_pet(pet_id, api_key: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/pet/{petId}', Server::SERVER1) .template_param(new_parameter(pet_id, key: 'petId') .should_encode(true)) .header_param(new_parameter(api_key, key: 'api_key')) .auth(Single.new('global'))) .response(new_response_handler .is_response_void(true) .local_error('400', 'Invalid ID supplied', APIException) .local_error('404', 'Pet not found', APIException)) .execute end |
#find_pets_by_status(status) ⇒ List of Pet
Multiple status values can be provided with comma separated strings need to be considered for filter
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 87 def find_pets_by_status(status) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/pet/findByStatus', Server::SERVER1) .query_param(new_parameter(status, key: 'status')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .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) ⇒ List of Pet
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 109 def () warn 'Endpoint find_pets_by_tags in PetController is deprecated' new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/pet/findByTags', Server::SERVER1) .query_param(new_parameter(, key: 'tags')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .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
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 131 def get_pet_by_id(pet_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/pet/{petId}', Server::SERVER1) .template_param(new_parameter(pet_id, key: 'petId') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .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(body) ⇒ void
This method returns an undefined value.
Update an existing pet the store
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 60 def update_pet(body) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/pet', Server::SERVER1) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .is_response_void(true) .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.
Updates a pet in the store with form data updated
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 158 def update_pet_with_form(pet_id, name: nil, status: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/pet/{petId}', Server::SERVER1) .template_param(new_parameter(pet_id, key: 'petId') .should_encode(true)) .form_param(new_parameter(name, key: 'name')) .form_param(new_parameter(status, key: 'status')) .header_param(new_parameter('application/x-www-form-urlencoded', key: 'content-type')) .auth(Single.new('global'))) .response(new_response_handler .is_response_void(true) .local_error('405', 'Invalid input', APIException)) .execute end |
#upload_file(pet_id, additional_metadata: nil, file: nil) ⇒ ApiResponse
uploads an image pass to server
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/swagger_petstore/controllers/pet_controller.rb', line 15 def upload_file(pet_id, additional_metadata: nil, file: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/pet/{petId}/uploadImage', Server::SERVER1) .template_param(new_parameter(pet_id, key: 'petId') .should_encode(true)) .form_param(new_parameter(, key: 'additionalMetadata')) .multipart_param(new_parameter(file, key: 'file') .default_content_type('application/octet-stream')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ApiResponse.method(:from_hash))) .execute end |