/** * @fileoverview AUTOMATICALLY GENERATED service for API.Client.PetApi. * Do not edit this file by hand or your changes will be lost next time it is * generated. * * This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters * Version: 1.0.0 * Generated at: 2016-01-27T23:51:03.092-07:00 * Generated by: class io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen */ /** * @license Apache 2.0 * http://www.apache.org/licenses/LICENSE-2.0.html */ goog.provide('API.Client.PetApi'); goog.require('API.Client.Pet'); goog.require('API.Client.binary'); /** * @constructor * @param {!angular.$http} $http * @param {!angular.$injector} $injector * @struct */ API.Client.PetApi = function($http, $injector) { /** @private {!string} */ this.basePath_ = $injector.has('PetApiBasePath') ? /** @type {!string} */ ($injector.get('PetApiBasePath')) : 'http://petstore.swagger.io/v2'; /** @private {!Object} */ this.defaultHeaders_ = $injector.has('PetApiDefaultHeaders') ? /** @type {!Object} */ ( $injector.get('PetApiDefaultHeaders')) : {}; /** @private {!angular.$http} */ this.http_ = $http; } API.Client.PetApi.$inject = ['$http', '$injector']; /** * Update an existing pet * * @param {!Pet=} opt_body Pet object that needs to be added to the store * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.updatePet = function(opt_body, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet'; /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, data: body, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('PUT') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Add a new pet to the store * * @param {!Pet=} opt_body Pet object that needs to be added to the store * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.addPet = function(opt_body, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet'; /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, data: body, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('POST') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Finds Pets by status * Multiple status values can be provided with comma seperated strings * @param {!Array=} opt_status Status values that need to be considered for filter * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise>} */ API.Client.PetApi.prototype.findPetsByStatus = function(opt_status, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/findByStatus'; /** @type {!Object} */ var queryParameters = {}; if (opt_status !== undefined) { queryParameters['status'] = String(opt_status); } /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('GET') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * @param {!Array=} opt_tags Tags to filter by * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise>} */ API.Client.PetApi.prototype.findPetsByTags = function(opt_tags, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/findByTags'; /** @type {!Object} */ var queryParameters = {}; if (opt_tags !== undefined) { queryParameters['tags'] = String(opt_tags); } /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('GET') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param {!number} petId ID of pet that needs to be fetched * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.getPetById = function(petId, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('GET') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Updates a pet in the store with form data * * @param {!string} petId ID of pet that needs to be updated * @param {!string=} opt_name Updated name of the pet * @param {!string=} opt_status Updated status of the pet * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.updatePetWithForm = function(petId, opt_name, opt_status, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!FormData} */ var formParams = new FormData(); if (opt_name !== undefined) { var name_ = /** @type {?} */ (opt_name); if (name_ instanceof Blob) { formParams.append('name', name_); } else if (typeof name_ === 'string') { formParams.append('name', name_); } else { throw new Error('Forms parameter opt_name is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)'); } } if (opt_status !== undefined) { var status_ = /** @type {?} */ (opt_status); if (status_ instanceof Blob) { formParams.append('status', status_); } else if (typeof status_ === 'string') { formParams.append('status', status_); } else { throw new Error('Forms parameter opt_status is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)'); } } /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: false, data: formParams, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('POST') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Deletes a pet * * @param {!number} petId Pet id to delete * @param {!string=} opt_apiKey * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.deletePet = function(petId, opt_apiKey, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/{petId}' .replace('{' + 'petId' + '}', String(petId)); /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); if (opt_apiKey !== undefined) { headerParams['api_key'] = opt_apiKey; } /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('DELETE') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * uploads an image * * @param {!number} petId ID of pet to update * @param {!string=} opt_additionalMetadata Additional data to pass to server * @param {!Object=} opt_file file to upload * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.uploadFile = function(petId, opt_additionalMetadata, opt_file, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/{petId}/uploadImage' .replace('{' + 'petId' + '}', String(petId)); /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!FormData} */ var formParams = new FormData(); if (opt_additionalMetadata !== undefined) { var additionalMetadata_ = /** @type {?} */ (opt_additionalMetadata); if (additionalMetadata_ instanceof Blob) { formParams.append('additionalMetadata', additionalMetadata_); } else if (typeof additionalMetadata_ === 'string') { formParams.append('additionalMetadata', additionalMetadata_); } else { throw new Error('Forms parameter opt_additionalMetadata is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)'); } } if (opt_file !== undefined) { var file_ = /** @type {?} */ (opt_file); if (file_ instanceof Blob) { formParams.append('file', file_); } else if (typeof file_ === 'string') { formParams.append('file', file_); } else { throw new Error('Forms parameter opt_file is required to be a string or a Blob (https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob)'); } } /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: false, data: formParams, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('POST') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Fake endpoint to test byte array return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions * @param {!number} petId ID of pet that needs to be fetched * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.getPetByIdWithByteArray = function(petId, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet/{petId}?testing_byte_array=true' .replace('{' + 'petId' + '}', String(petId)); /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('GET') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } } /** * Fake endpoint to test byte array in body parameter for adding a new pet to the store * * @param {!API.Client.binary=} opt_body Pet object in the form of byte array * @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send. * @return {!angular.$q.Promise} */ API.Client.PetApi.prototype.addPetUsingByteArray = function(opt_body, opt_extraHttpRequestParams) { /** @const {!string} */ var path = this.basePath_ + '/pet?testing_byte_array=true'; /** @type {!Object} */ var queryParameters = {}; /** @type {!Object} */ var headerParams = angular.copy(this.defaultHeaders_); /** @type {!angular.$http.Config} */ var httpRequestConfig = /** @type {!angular.$http.Config} */ ({ url: path, json: true, data: body, params: queryParameters, headers: headerParams }); if (opt_extraHttpRequestParams) { // If an opt_extraHttpRequestParams object is passed in, override values // set the generated config with the passed in values. httpRequestConfig = angular.merge(httpRequestConfig, opt_extraHttpRequestParams); } // This whole block is to work around a limitation in closure compiler. It // would be better to call the $http service directly as a function, but that // isn't permitted since it has methods attached to it. Manually confirmed to // compile down to just a single method even with only SIMPLE optimization on. // https://github.com/google/closure-compiler/blob/90769b826df65eabfb0211517b0d6d85c0c1c60b/contrib/externs/angular-1.4.js#L1393 switch ('POST') { case 'GET': return this.http_.get(path, httpRequestConfig); case 'HEAD': return this.http_.head(path, httpRequestConfig); case 'POST': return this.http_.post(path, {}, httpRequestConfig); case 'PUT': return this.http_.put(path, {}, httpRequestConfig); case 'DELETE': return this.http_.delete(path, httpRequestConfig); case 'PATCH': return this.http_.patch(path, {}, httpRequestConfig); } }