All Downloads are FREE. Search and download functionalities are using the official Maven repository.

typescript-angularjs.api.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
{{>licenseInfo}}
{{^models.isEmpty}}
import * as models from '../model/models';
{{/models.isEmpty}}

/* tslint:disable:no-unused-variable member-ordering */

{{#operations}}
{{#description}}
/**
 * {{&description}}
 */
{{/description}}
export class {{classname}} {
    protected basePath = '{{{basePath}}}';
    public defaultHeaders : any = {};

    static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];

    constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
        if (basePath !== undefined) {
            this.basePath = basePath;
        }
    }

{{#operation}}
    /**
     * {{¬es}}
     {{#summary}}
     * @summary {{&summary}}
     {{/summary}}
     {{#allParams}}
     * @param {{paramName}} {{description}}
     {{/allParams}}
     */
    public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
        const localVarPath = this.basePath + '{{{path}}}'{{#pathParams}}
            .replace('{' + '{{baseName}}' + '}', encodeURIComponent(String({{paramName}}))){{/pathParams}};

        let queryParameters: any = {};
        let headerParams: any = (Object).assign({}, this.defaultHeaders);
{{#hasFormParams}}
        let formParams: any = {};

{{/hasFormParams}}
{{#allParams}}
{{#required}}
        // verify required parameter '{{paramName}}' is not null or undefined
        if ({{paramName}} === null || {{paramName}} === undefined) {
            throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
        }

{{/required}}
{{/allParams}}
{{#queryParams}}
        if ({{paramName}} !== undefined) {
            queryParameters['{{baseName}}'] = {{paramName}};
        }

{{/queryParams}}
{{#headerParams}}
        headerParams['{{baseName}}'] = {{paramName}};

{{/headerParams}}
{{#hasFormParams}}
        headerParams['Content-Type'] = 'application/x-www-form-urlencoded';

{{/hasFormParams}}
{{#formParams}}
        formParams['{{baseName}}'] = {{paramName}};

{{/formParams}}
        let httpRequestParams: ng.IRequestConfig = {
            method: '{{httpMethod}}',
            url: localVarPath,
            {{#bodyParam}}
            data: {{paramName}},
            {{/bodyParam}}
            {{#hasFormParams}}
            data: this.$httpParamSerializer(formParams),
            {{/hasFormParams}}
            params: queryParameters,
            headers: headerParams
        };

        if (extraHttpRequestParams) {
            httpRequestParams = (Object).assign(httpRequestParams, extraHttpRequestParams);
        }

        return this.$http(httpRequestParams);
    }
{{/operation}}
}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy