/** * OpenAPI Petstore * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. * */ import ApiClient from "../ApiClient"; import ApiResponse from '../model/ApiResponse'; import Pet from '../model/Pet'; /** * Pet service. * @module api/PetApi * @version 1.0.0 */ export default class PetApi { /** * Constructs a new PetApi. * @alias module:api/PetApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ constructor(apiClient) { this.apiClient = apiClient || ApiClient.instance; } /** * Callback function to receive the result of the addPet operation. * @callback module:api/PetApi~addPetCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Add a new pet to the store * * @param {module:model/Pet} pet Pet object that needs to be added to the store * @param {module:api/PetApi~addPetCallback} callback The callback function, accepting three arguments: error, data, response */ addPet(pet, opts, callback) { opts = opts || {}; let postBody = pet; // verify the required parameter 'pet' is set if (pet === undefined || pet === null) { throw new Error("Missing the required parameter 'pet' when calling addPet"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['petstore_auth']; let contentTypes = ['application/json', 'application/xml']; let accepts = []; let returnType = null; let basePaths = ['http://petstore.swagger.io/v2', 'http://path-server-test.petstore.local/v2']; let basePath = basePaths[0]; // by default use the first one in "servers" defined in OpenAPI if (typeof opts['_base_path_index'] !== 'undefined') { if (opts['_base_path_index'] >= basePaths.length || opts['_base_path_index'] < 0) { throw new Error("Invalid index " + opts['_base_path_index'] + " when selecting the host settings. Must be less than " + basePaths.length); } basePath = basePaths[opts['_base_path_index']]; } return this.apiClient.callApi( '/pet', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, basePath, callback ); } /** * Callback function to receive the result of the deletePet operation. * @callback module:api/PetApi~deletePetCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Deletes a pet * * @param {Number} petId Pet id to delete * @param {Object} opts Optional parameters * @param {String} opts.apiKey * @param {module:api/PetApi~deletePetCallback} callback The callback function, accepting three arguments: error, data, response */ deletePet(petId, opts, callback) { opts = opts || {}; let postBody = null; // verify the required parameter 'petId' is set if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling deletePet"); } let pathParams = { 'petId': petId }; let queryParams = { }; let headerParams = { 'api_key': opts['apiKey'] }; let formParams = { }; let authNames = ['petstore_auth']; let contentTypes = []; let accepts = []; let returnType = null; return this.apiClient.callApi( '/pet/{petId}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } /** * Callback function to receive the result of the findPetsByStatus operation. * @callback module:api/PetApi~findPetsByStatusCallback * @param {String} error Error message, if any. * @param {Array.} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param {Array.} status Status values that need to be considered for filter * @param {module:api/PetApi~findPetsByStatusCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.} */ findPetsByStatus(status, callback) { let postBody = null; // verify the required parameter 'status' is set if (status === undefined || status === null) { throw new Error("Missing the required parameter 'status' when calling findPetsByStatus"); } let pathParams = { }; let queryParams = { 'status': this.apiClient.buildCollectionParam(status, 'csv') }; let headerParams = { }; let formParams = { }; let authNames = ['petstore_auth']; let contentTypes = []; let accepts = ['application/xml', 'application/json']; let returnType = [Pet]; return this.apiClient.callApi( '/pet/findByStatus', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } /** * Callback function to receive the result of the findPetsByTags operation. * @callback module:api/PetApi~findPetsByTagsCallback * @param {String} error Error message, if any. * @param {Array.} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param {Array.} tags Tags to filter by * @param {module:api/PetApi~findPetsByTagsCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.} */ findPetsByTags(tags, callback) { let postBody = null; // verify the required parameter 'tags' is set if (tags === undefined || tags === null) { throw new Error("Missing the required parameter 'tags' when calling findPetsByTags"); } let pathParams = { }; let queryParams = { 'tags': this.apiClient.buildCollectionParam(tags, 'csv') }; let headerParams = { }; let formParams = { }; let authNames = ['petstore_auth']; let contentTypes = []; let accepts = ['application/xml', 'application/json']; let returnType = [Pet]; return this.apiClient.callApi( '/pet/findByTags', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } /** * Callback function to receive the result of the getPetById operation. * @callback module:api/PetApi~getPetByIdCallback * @param {String} error Error message, if any. * @param {module:model/Pet} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Find pet by ID * Returns a single pet * @param {Number} petId ID of pet to return * @param {module:api/PetApi~getPetByIdCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Pet} */ getPetById(petId, callback) { let postBody = null; // verify the required parameter 'petId' is set if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling getPetById"); } let pathParams = { 'petId': petId }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['api_key']; let contentTypes = []; let accepts = ['application/xml', 'application/json']; let returnType = Pet; return this.apiClient.callApi( '/pet/{petId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } /** * Callback function to receive the result of the updatePet operation. * @callback module:api/PetApi~updatePetCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Update an existing pet * * @param {module:model/Pet} pet Pet object that needs to be added to the store * @param {module:api/PetApi~updatePetCallback} callback The callback function, accepting three arguments: error, data, response */ updatePet(pet, opts, callback) { opts = opts || {}; let postBody = pet; // verify the required parameter 'pet' is set if (pet === undefined || pet === null) { throw new Error("Missing the required parameter 'pet' when calling updatePet"); } let pathParams = { }; let queryParams = { }; let headerParams = { }; let formParams = { }; let authNames = ['petstore_auth']; let contentTypes = ['application/json', 'application/xml']; let accepts = []; let returnType = null; let basePaths = ['http://petstore.swagger.io/v2', 'http://path-server-test.petstore.local/v2']; let basePath = basePaths[0]; // by default use the first one in "servers" defined in OpenAPI if (typeof opts['_base_path_index'] !== 'undefined') { if (opts['_base_path_index'] >= basePaths.length || opts['_base_path_index'] < 0) { throw new Error("Invalid index " + opts['_base_path_index'] + " when selecting the host settings. Must be less than " + basePaths.length); } basePath = basePaths[opts['_base_path_index']]; } return this.apiClient.callApi( '/pet', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, basePath, callback ); } /** * Callback function to receive the result of the updatePetWithForm operation. * @callback module:api/PetApi~updatePetWithFormCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Updates a pet in the store with form data * * @param {Number} petId ID of pet that needs to be updated * @param {Object} opts Optional parameters * @param {String} opts.name Updated name of the pet * @param {String} opts.status Updated status of the pet * @param {module:api/PetApi~updatePetWithFormCallback} callback The callback function, accepting three arguments: error, data, response */ updatePetWithForm(petId, opts, callback) { opts = opts || {}; let postBody = null; // verify the required parameter 'petId' is set if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling updatePetWithForm"); } let pathParams = { 'petId': petId }; let queryParams = { }; let headerParams = { }; let formParams = { 'name': opts['name'], 'status': opts['status'] }; let authNames = ['petstore_auth']; let contentTypes = ['application/x-www-form-urlencoded']; let accepts = []; let returnType = null; return this.apiClient.callApi( '/pet/{petId}', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } /** * Callback function to receive the result of the uploadFile operation. * @callback module:api/PetApi~uploadFileCallback * @param {String} error Error message, if any. * @param {module:model/ApiResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * uploads an image * * @param {Number} petId ID of pet to update * @param {Object} opts Optional parameters * @param {String} opts.additionalMetadata Additional data to pass to server * @param {File} opts.file file to upload * @param {module:api/PetApi~uploadFileCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ApiResponse} */ uploadFile(petId, opts, callback) { opts = opts || {}; let postBody = null; // verify the required parameter 'petId' is set if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling uploadFile"); } let pathParams = { 'petId': petId }; let queryParams = { }; let headerParams = { }; let formParams = { 'additionalMetadata': opts['additionalMetadata'], 'file': opts['file'] }; let authNames = ['petstore_auth']; let contentTypes = ['multipart/form-data']; let accepts = ['application/json']; let returnType = ApiResponse; return this.apiClient.callApi( '/pet/{petId}/uploadImage', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } /** * Callback function to receive the result of the uploadFileWithRequiredFile operation. * @callback module:api/PetApi~uploadFileWithRequiredFileCallback * @param {String} error Error message, if any. * @param {module:model/ApiResponse} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * uploads an image (required) * * @param {Number} petId ID of pet to update * @param {File} requiredFile file to upload * @param {Object} opts Optional parameters * @param {String} opts.additionalMetadata Additional data to pass to server * @param {module:api/PetApi~uploadFileWithRequiredFileCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/ApiResponse} */ uploadFileWithRequiredFile(petId, requiredFile, opts, callback) { opts = opts || {}; let postBody = null; // verify the required parameter 'petId' is set if (petId === undefined || petId === null) { throw new Error("Missing the required parameter 'petId' when calling uploadFileWithRequiredFile"); } // verify the required parameter 'requiredFile' is set if (requiredFile === undefined || requiredFile === null) { throw new Error("Missing the required parameter 'requiredFile' when calling uploadFileWithRequiredFile"); } let pathParams = { 'petId': petId }; let queryParams = { }; let headerParams = { }; let formParams = { 'additionalMetadata': opts['additionalMetadata'], 'requiredFile': requiredFile }; let authNames = ['petstore_auth']; let contentTypes = ['multipart/form-data']; let accepts = ['application/json']; let returnType = ApiResponse; return this.apiClient.callApi( '/fake/{petId}/uploadImageWithRequiredFile', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback ); } }