1+ { {#withSeparateModelsAndApi} }
2+ // tslint:disable
3+ import { Observable } from "rxjs";
4+ import { APIHandler, APIURLTypes, HttpOptions{{#operations} }{ {#operation} }{ {#-first} }{ {#authMethods} }{ {#isBasic} }, HttpBasicAuth{ {/isBasic} }{ {#isApiKey} }, ApiKeyAuth{ {/isApiKey} }{ {#isBasicBearer} }, OAuth{ {/isBasicBearer} }{ {#isOAuth} }, OAuth{ {/isOAuth} }{ {/authMethods} }{ {/-first} }{ {/operation} }{ {/operations} } } from "{ {apiRelativeToRoot} }base";
5+ import { {{#imports} }{ {classname} }{ {^-last} }, { {/-last} }{ {/imports} } } from "{ {apiRelativeToRoot} }{ {tsModelPackage} }";
6+ { {/withSeparateModelsAndApi} }
7+
8+ { {#operations} }
9+ export class { {classname} } extends APIHandler {
10+ static urls: APIURLTypes.{{classname} } = {
11+ {{#operation} }{ {nickname} }: "{ {path} }"{ {#hasMore} },
12+ { {/hasMore} }{ {/operation} }
13+ };
14+
15+ constructor() {
16+ super(" {{classname}}" );{{#operation} }{ {#-first} }{ {#authMethods} }
17+ this.authentications.push({ {#isBasic} }new HttpBasicAuth(){ {/isBasic} }{ {#isApiKey} }new ApiKeyAuth({ {#isKeyInHeader} }'header', { {/isKeyInHeader} }{ {^isKeyInHeader} }'query', { {/isKeyInHeader} }'{ {keyParamName} }'){ {/isApiKey} }{ {#isBasicBearer} }new OAuth(){ {/isBasicBearer} }{ {#isOAuth} }new OAuth(){ {/isOAuth} });{ {/authMethods} }{ {/-first} }{ {/operation} }
18+ }
19+
20+ { {#operation} }
21+ { {#-first} }
22+ { {#authMethods} }
23+ // authentication { {name} } required
24+ { {#isApiKey} }
25+ private _apiKey: string;
26+ get apiKey() {
27+ return this._apiKey;
28+ }
29+ { {#isKeyInHeader} }
30+ set apiKey(key: string | Function) {
31+ const localApiKey: string = typeof key === ' function'
32+ ? key(" {{keyParamName}}" )
33+ : key;
34+ this._apiKey = localApiKey;
35+ }
36+ { {/isKeyInHeader} }
37+ { {#isKeyInQuery} }
38+ set apiKey(key: string | Function) {
39+ const localApiKey: string = typeof key === ' function'
40+ ? key(" {{keyParamName}}" )
41+ : key;
42+ this._apiKey = localApiKey;
43+ }
44+ { {/isKeyInQuery} }
45+ { {/isApiKey} }
46+ { {#isBasicBasic} }
47+ private _username: string;
48+ get username() {
49+ return this._username;
50+ }
51+ set username(username: string) {
52+ this._username = username;
53+ }
54+ private _password: string;
55+ get password() {
56+ return this._password;
57+ }
58+ set password(password: string) {
59+ this._password = password;
60+ }
61+ { {/isBasicBasic} }
62+ { {#isBasicBearer} }
63+ private _accessToken: string;
64+ get accessToken() {
65+ return this._accessToken;
66+ }
67+ // http bearer authentication required
68+ set accessToken(accessToken: string | Function) {
69+ const bearerToken: string = typeof accessToken === ' function'
70+ ? accessToken()
71+ : accessToken;
72+ this._accessToken = bearerToken;
73+ }
74+ { {/isBasicBearer} }
75+ { {#isOAuth} }
76+ private _accessToken: string;
77+ get accessToken() {
78+ return this._accessToken;
79+ }
80+ set accessToken(token: string) {
81+ this._accessToken = token;
82+ }
83+ { {/isOAuth} }
84+ { {/authMethods} }
85+ { {/-first} }
86+ /**{ {#summary} }
87+ * { {summary} }{ {/summary} }{ {#notes} }
88+ * { {notes} }{ {/notes} }{ {#allParams} }
89+ * @param { {paramName} } { {description} }{ {/allParams} }
90+ */
91+ public { {nickname} }(params: {
92+ {{#allParams} }{ {paramName} }{ {^required} }?{ {/required} }: { {^isPrimitiveType} }{ {^isFile} }{ {/isFile} }{ {/isPrimitiveType} }{ {{dataType} }};{ {#hasMore} }
93+ { {/hasMore} }{ {/allParams} }
94+ }{ {^hasRequiredParams} } = { } { {/hasRequiredParams} }, options?: HttpOptions): Observable<{ {#imports} }{ {#.} }{ {.} }{ {^-last} } | { {/-last} }{ {/.} }{ {/imports} }> {
95+ const acceptTypes: Array< string> = [{{#produces} }"{ {mediaType} }"{ {#hasMore} }, { {/hasMore} }{ {/produces} }];
96+ this.initAuth({ {#hasAuthMethods} }{ {#cookieAuth} }false{ {/cookieAuth} }{ {#authMethods} }true, { {#isApiKey} }{ {#isKeyInHeader} }{ token: this.apiKey as string, contentTypes: acceptTypes, key: " Authentication" } { {/isKeyInHeader} }{ {/isApiKey} }{ {#isBasicBasic} }{ username: this.username, password: this.password, key: " Basic" } { {/isBasicBasic} }{ {#isBasicBearer} }{ token: this.accessToken, contentTypes: acceptTypes, key: " Authentication" } { {/isBasicBearer} }{ {#isOAuth} }{ token: this.accessToken, contentTypes: acceptTypes, key: " Authentication" } { {/isOAuth} }{ {/authMethods} }{ {/hasAuthMethods} }{ {^hasAuthMethods} }false{ {/hasAuthMethods} });
97+ const apiURL: string = this.initAPIURL({ {classname} }.urls.{ {nickname} }{ {#hasPathParams} }, { {{/hasPathParams} }{ {#pathParams} }{ {baseName} }: params.{ {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/pathParams} }{ {#hasPathParams} } } { {/hasPathParams} }{ {^pathParams} }, null{ {/pathParams} });
98+ options = this.initOptions(options, { {{#queryParams} }{ {paramName} }: params.{ {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/queryParams} } }, { {{#headerParams} }{ {paramName} }: params.{ {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/headerParams} } });{ {#formParams} }{ {#isFile} }
99+ const formData: FormData = new FormData();
100+ formData.append("file", params.{ {paramName} } as any);{ {/isFile} }{ {/formParams} }
101+ const body: any = { {#formParams} }{ {#-first} }{ {{/-first} }{ {#isFile} }formData{ {/isFile} }{ {^isFile} }{ {paramName} }: params.{ {paramName} }{ {/isFile} }{ {#-last} } }{ {/-last} }{ {^-last} }, { {/-last} }{ {/formParams} }{ {^formParams} }{ {#bodyParam} }params.{ {paramName} }{ {/bodyParam} }{ {/formParams} }{ {^formParams} }{ {^bodyParam} }null{ {/bodyParam} }{ {/formParams} };
102+ return this.makeCall<{ {#imports} }{ {#.} }{ {.} }{ {^-last} } | { {/-last} }{ {/.} }{ {/imports} }>("{ {httpMethod} }".toLowerCase(), apiURL, options, body);
103+ }
104+
105+ { {/operation} }
106+ }
107+ { {/operations} }
0 commit comments