Javascript-Closure-Angular.api.mustache Maven / Gradle / Ivy
/**
* @fileoverview AUTOMATICALLY GENERATED service for {{package}}.{{classname}}.
* Do not edit this file by hand or your changes will be lost next time it is
* generated.{{#appDescription}}
*
* {{ appDescription }}{{/appDescription}}{{#version}}
* Version: {{.}}{{/version}}{{#appContact}}
* Contact: {{.}}{{/appContact}}
{{^hideGenerationTimestamp}}
* Generated at: {{generatedDate}}
{{/hideGenerationTimestamp}}
* Generated by: {{generatorClass}}
*/{{#licenseInfo}}
/**
* @license {{licenseInfo}}{{#licenseUrl}}
* {{.}}{{/licenseUrl}}
*/
{{/licenseInfo}}
goog.provide('{{package}}.{{classname}}');
{{#imports}}
goog.require('{{import}}');
{{/imports}}
{{#operations}}
/**
{{#description}}
* {{&description}}
{{/description}}
* @constructor
* @param {!angular.$http} $http
* @param {!Object} $httpParamSerializer
* @param {!angular.$injector} $injector
* @struct
*/
{{package}}.{{classname}} = function($http, $httpParamSerializer, $injector) {
/** @private {!string} */
this.basePath_ = $injector.has('{{classname}}BasePath') ?
/** @type {!string} */ ($injector.get('{{classname}}BasePath')) :
'{{{basePath}}}';
/** @private {!Object} */
this.defaultHeaders_ = $injector.has('{{classname}}DefaultHeaders') ?
/** @type {!Object} */ (
$injector.get('{{classname}}DefaultHeaders')) :
{};
/** @private {!angular.$http} */
this.http_ = $http;
/** @package {!Object} */
this.httpParamSerializer = $injector.get('$httpParamSerializer');
}
{{package}}.{{classname}}.$inject = ['$http', '$httpParamSerializer', '$injector'];
{{#operation}}
/**
* {{summary}}
* {{notes}}{{#allParams}}
* @param {!{{{dataType}}}{{^required}}={{/required}}} {{^required}}opt_{{/required}}{{paramName}} {{description}}{{/allParams}}
* @param {!angular.$http.Config=} opt_extraHttpRequestParams Extra HTTP parameters to send.
* @return {!angular.$q.Promise{{#returnType}}{{/returnType}}}
*/
{{package}}.{{classname}}.prototype.{{nickname}} = function({{#allParams}}{{^required}}opt_{{/required}}{{paramName}}, {{/allParams}}opt_extraHttpRequestParams) {
/** @const {string} */
var path = this.basePath_ + '{{{path}}}'{{#pathParams}}
.replace('{' + '{{baseName}}' + '}', String({{^required}}opt_{{/required}}{{paramName}})){{/pathParams}};
/** @type {!Object} */
var queryParameters = {};
/** @type {!Object} */
var headerParams = angular.extend({}, this.defaultHeaders_);
{{#hasFormParams}}
/** @type {!Object} */
var formParams = {};
{{/hasFormParams}}
{{#allParams}}
{{#required}}
// verify required parameter '{{^required}}opt_{{/required}}{{paramName}}' is set
if (!{{^required}}opt_{{/required}}{{paramName}}) {
throw new Error('Missing required parameter {{^required}}opt_{{/required}}{{paramName}} when calling {{nickname}}');
}
{{/required}}
{{/allParams}}
{{#queryParams}}
if ({{^required}}opt_{{/required}}{{paramName}} !== undefined) {
queryParameters['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
}
{{/queryParams}}
{{#headerParams}}
headerParams['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
{{/headerParams}}
{{#hasFormParams}}
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
{{/hasFormParams}}
{{#formParams}}
formParams['{{baseName}}'] = {{^required}}opt_{{/required}}{{paramName}};
{{/formParams}}
/** @type {!Object} */
var httpRequestParams = {
method: '{{httpMethod}}',
url: path,
json: {{#hasFormParams}}false{{/hasFormParams}}{{^hasFormParams}}true{{/hasFormParams}},
{{#bodyParam}}data: {{^required}}opt_{{/required}}{{paramName}},
{{/bodyParam}}
{{#hasFormParams}}data: this.httpParamSerializer(formParams),
{{/hasFormParams}}
params: queryParameters,
headers: headerParams
};
if (opt_extraHttpRequestParams) {
httpRequestParams = angular.extend(httpRequestParams, opt_extraHttpRequestParams);
}
return (/** @type {?} */ (this.http_))(httpRequestParams);
}
{{/operation}}
{{/operations}}