@mediusinc/mng-commons-data-api 5.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +14 -0
  2. package/esm2022/index.mjs +7 -0
  3. package/esm2022/lib/helpers/get-all-params.mjs +186 -0
  4. package/esm2022/lib/models/request-params.model.mjs +2 -0
  5. package/esm2022/lib/types/extract-get-all-params.type.mjs +2 -0
  6. package/esm2022/mediusinc-mng-commons-data-api.mjs +5 -0
  7. package/esm2022/tableview/index.mjs +2 -0
  8. package/esm2022/tableview/mediusinc-mng-commons-data-api-tableview.mjs +5 -0
  9. package/esm2022/tableview/tableview-get-all-params-create.mjs +18 -0
  10. package/fesm2022/mediusinc-mng-commons-data-api-tableview.mjs +25 -0
  11. package/fesm2022/mediusinc-mng-commons-data-api-tableview.mjs.map +1 -0
  12. package/fesm2022/mediusinc-mng-commons-data-api.mjs +195 -0
  13. package/fesm2022/mediusinc-mng-commons-data-api.mjs.map +1 -0
  14. package/index.d.ts +3 -0
  15. package/lib/helpers/get-all-params.d.ts +69 -0
  16. package/lib/models/request-params.model.d.ts +61 -0
  17. package/lib/types/extract-get-all-params.type.d.ts +14 -0
  18. package/openapi/README.mustache +226 -0
  19. package/openapi/api.module.mustache +39 -0
  20. package/openapi/api.service.mustache +253 -0
  21. package/openapi/apiInterface.mustache +47 -0
  22. package/openapi/apis.mustache +12 -0
  23. package/openapi/config.yaml +23 -0
  24. package/openapi/configuration.mustache +128 -0
  25. package/openapi/custom/base-api.service.mustache +14 -0
  26. package/openapi/custom/helpers.mustache +71 -0
  27. package/openapi/custom/modelSchema.mustache +46 -0
  28. package/openapi/custom/schema.mustache +18 -0
  29. package/openapi/encoder.mustache +20 -0
  30. package/openapi/git_push.sh.mustache +57 -0
  31. package/openapi/index.mustache +0 -0
  32. package/openapi/licenseInfo.mustache +11 -0
  33. package/openapi/model.mustache +16 -0
  34. package/openapi/modelAlias.mustache +1 -0
  35. package/openapi/modelEnum.mustache +21 -0
  36. package/openapi/modelGeneric.mustache +14 -0
  37. package/openapi/modelGenericAdditionalProperties.mustache +5 -0
  38. package/openapi/modelGenericEnums.mustache +30 -0
  39. package/openapi/modelOneOf.mustache +14 -0
  40. package/openapi/modelTaggedUnion.mustache +21 -0
  41. package/openapi/models.mustache +5 -0
  42. package/openapi/ng-package.mustache +6 -0
  43. package/openapi/package.mustache +39 -0
  44. package/openapi/param.mustache +69 -0
  45. package/openapi/tsconfig.mustache +28 -0
  46. package/openapi/variables.mustache +9 -0
  47. package/package.json +34 -0
  48. package/tableview/README.md +10 -0
  49. package/tableview/index.d.ts +1 -0
  50. package/tableview/tableview-get-all-params-create.d.ts +15 -0
@@ -0,0 +1,69 @@
1
+ import { Observable } from 'rxjs';
2
+ import { DataListFilter, DataListParams, DataListResult } from '@mediusinc/mng-commons/core';
3
+ import { GetAllParamsFilterMatchType, GetAllParamsType, GetAllParamsUrlQueryType } from '../models/request-params.model';
4
+ /**
5
+ * Converts a filter match mode to its corresponding enum value.
6
+ *
7
+ * @param {string} matchMode - The filter match mode from data list filter to convert.
8
+ * @returns {GetAllParamsFilterMatchType} - The converted enum value.
9
+ * @throws {CommonsInternalError} - If the filter match mode is not supported.
10
+ */
11
+ export declare function toGetAllParamsFilterMatchMode(matchMode: string): GetAllParamsFilterMatchType;
12
+ /**
13
+ * Converts given parameters of a DataListParams object into a get all request param object with values as URL query string representation.
14
+ *
15
+ * @param {DataListParams} params - The parameters to convert.
16
+ * @typeparam Sorts - The type of the sorting options for the data list.
17
+ * @typeparam Filters - The type of the filters for the data list.
18
+ * @returns {GetAllParamsUrlQueryType<Filters>} - Get all request param object with values as URL query string representation.
19
+ */
20
+ export declare function toGetAllParamsAsUrlQuery<Sorts, Filters extends keyof any>(params: DataListParams<Sorts, Filters>): GetAllParamsUrlQueryType<Filters>;
21
+ /**
22
+ * Converts given parameters of a DataListParams object into a get all request param object with values as objects for POST requests.
23
+ *
24
+ * @param {DataListParams} params - The parameters to convert.
25
+ * @typeparam Sorts - The type of the sorting options for the data list.
26
+ * @typeparam Filters - The type of the filters for the data list.
27
+ * @returns {GetAllParamsType<Sorts, Filters>} - Get all request param object with values as objects for POST requests.
28
+ */
29
+ export declare function toGetAllParams<Sorts, Filters extends keyof any>(params: DataListParams<Sorts, Filters>): GetAllParamsType<Sorts, Filters>;
30
+ /**
31
+ * Converts DataListParams to sort query URL representation.
32
+ *
33
+ * @param {DataListParams} params - The params object with sort property to convert.
34
+ * @returns {string | undefined} - The formatted sort query URL param or undefined.
35
+ */
36
+ export declare function toGetAllSortAsQueryUrl(params?: DataListParams<any, any>): string | undefined;
37
+ /**
38
+ * Converts a DataListFilter object to a query URL string.
39
+ *
40
+ * @param {DataListFilter} filter - The filter object from params to convert.
41
+ * @returns {string|undefined} - The formatted filter query URL param or undefined.
42
+ */
43
+ export declare function toGetAllFilterAsQueryUrl(filter?: DataListFilter): string | undefined;
44
+ /**
45
+ * Executes the "getAll" on API service with request parameters.
46
+ * Get all is expected to be executed via GET method using params as URL queries.
47
+ *
48
+ * @param {Service} service - The API service instance.
49
+ * @param {Function} getAllFn - The "getAll" function on provided service instance.
50
+ * @param {Object} params - The data list params.
51
+ * @returns {Observable<<DataListResult<Item>>>} An observable with data list result.
52
+ */
53
+ export declare function executeGetAll<Service, Item, Sorts, Filters extends keyof any>(service: Service, getAllFn: (requestParameters: GetAllParamsUrlQueryType<Filters>) => Observable<{
54
+ data?: Item[];
55
+ totalCount?: number;
56
+ }>, params: DataListParams<Sorts, Filters>): Observable<DataListResult<Item>>;
57
+ /**
58
+ * Executes the "getAll" on API service with request parameters.
59
+ * Get all is expected to be executed via POST method using params as object in body of request.
60
+ *
61
+ * @param {Service} service - The API service instance.
62
+ * @param {Function} getAllFn - The "getAll" function on provided service instance.
63
+ * @param {Object} params - The data list params.
64
+ * @returns {Observable<<DataListResult<Item>>>} An observable with data list result.
65
+ */
66
+ export declare function executeGetAllAsPost<Service, Item, Sorts, Filters extends keyof any>(service: Service, getAllFn: (requestParameters: GetAllParamsType<Sorts, Filters>) => Observable<{
67
+ data?: Item[];
68
+ totalCount?: number;
69
+ }>, params: DataListParams<Sorts, Filters>): Observable<DataListResult<Item>>;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Default (expected) type without filters, which are "dynamic" keys.
3
+ */
4
+ export type GetAllParamsDefaultWoFiltersType<Sort = GetAllParamsSortType[] | string, GlobalFilter = GetAllParamsGlobalFilterType | string> = {
5
+ offset?: number;
6
+ limit?: number;
7
+ globalFilter?: GlobalFilter;
8
+ sort?: Sort;
9
+ };
10
+ /**
11
+ * Represents the sort direction type for a get all request params (ascending or descending).
12
+ */
13
+ export type GetAllParamsSortDirectionType = 'ASCENDING' | 'DESCENDING';
14
+ /**
15
+ * Represents the sort type for a get all request params.
16
+ *
17
+ * @typeparam Property The type of the property to sort by.
18
+ * @typeparam Direction The type of the sort direction.
19
+ */
20
+ export type GetAllParamsSortType<Property = string, Direction = GetAllParamsSortDirectionType> = {
21
+ property: Property;
22
+ direction: Direction;
23
+ };
24
+ /**
25
+ * Represents the possible match types for filters in get all request params.
26
+ */
27
+ export type GetAllParamsFilterMatchType = 'EQUALS' | 'NOT_EQUALS' | 'BETWEEN' | 'CONTAINS' | 'NOT_CONTAINS' | 'STARTS_WITH' | 'ENDS_WITH' | 'IN' | 'NOT_IN' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL_TO' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL_TO' | 'EXISTS' | 'DOES_NOT_EXIST';
28
+ /**
29
+ * Describes the possible case sensitivity for filter in get all request params.
30
+ */
31
+ export type GetAllParamsFilterCaseSensitivityType = 'CASE_SENSITIVE' | 'CASE_INSENSITIVE';
32
+ /**
33
+ * Describes the global filter (search) in get all request params.
34
+ */
35
+ export type GetAllParamsGlobalFilterType<CaseSensitivity = GetAllParamsFilterCaseSensitivityType> = {
36
+ value: string;
37
+ caseSensitivity?: CaseSensitivity;
38
+ };
39
+ /**
40
+ * Describes the filters in get all request params.
41
+ */
42
+ export type GetAllParamsFiltersType<FilterType, FilterProperties extends keyof any> = {
43
+ [P in FilterProperties]: FilterType;
44
+ };
45
+ /**
46
+ * Represents a filter type for get all request params.
47
+ */
48
+ export type GetAllParamsFilterType<Value, CaseSensitivity = GetAllParamsFilterCaseSensitivityType, MatchType = GetAllParamsFilterMatchType> = {
49
+ value?: Value;
50
+ values?: Array<Value>;
51
+ caseSensitivity?: CaseSensitivity;
52
+ filterMatchType: MatchType;
53
+ };
54
+ /**
55
+ * Describes get all params with values as objects (for POST requests).
56
+ */
57
+ export type GetAllParamsType<Sorts = string, Filters extends keyof any = string> = GetAllParamsDefaultWoFiltersType<GetAllParamsSortType<Sorts>[], GetAllParamsGlobalFilterType> & GetAllParamsFiltersType<GetAllParamsFilterType<any>, Filters>;
58
+ /**
59
+ * Describes get all params with values as URL queries (for GET requests).
60
+ */
61
+ export type GetAllParamsUrlQueryType<Filters extends keyof any> = GetAllParamsDefaultWoFiltersType<string, string> & GetAllParamsFiltersType<string, Filters>;
@@ -0,0 +1,14 @@
1
+ import { GetAllParamsDefaultWoFiltersType, GetAllParamsSortType } from '../models/request-params.model';
2
+ /**
3
+ * Represents the type definition for the `GetAllParamsDefaultWoFiltersType` class - excludes offset, limit, search and sort properties.
4
+ * All other properties are expected to be filters.
5
+ *
6
+ * @typeparam Request - The type parameter representing the extended GetAllParamsDefaultWoFiltersType object.
7
+ */
8
+ export type ExtractGetAllParamsFilterType<Request extends GetAllParamsDefaultWoFiltersType> = keyof Omit<Request, 'offset' | 'limit' | 'globalFilter' | 'sort'>;
9
+ /**
10
+ * Represents the type definition for the `GetAllParamsDefaultWoFiltersType` class - extracts allowed sort properties (usually an enum) on property key within array type.
11
+ *
12
+ * @typeparam Request - The type parameter representing the extended GetAllParamsDefaultWoFiltersType object.
13
+ */
14
+ export type ExtractGetAllParamsSortType<Request extends GetAllParamsDefaultWoFiltersType<GetAllParamsSortType<any, any>[] | string, any>> = NonNullable<Request['sort']> extends Array<infer U> | string ? ('property' extends keyof U ? NonNullable<U['property']> : never) : never;
@@ -0,0 +1,226 @@
1
+ ## {{npmName}}@{{npmVersion}}
2
+
3
+ ### Building
4
+
5
+ To install the required dependencies and to build the typescript sources run:
6
+ ```
7
+ npm install
8
+ npm run build
9
+ ```
10
+
11
+ ### publishing
12
+
13
+ First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!)
14
+
15
+ ### consuming
16
+
17
+ Navigate to the folder of your consuming project and run one of next commands.
18
+
19
+ _published:_
20
+
21
+ ```
22
+ npm install {{npmName}}@{{npmVersion}} --save
23
+ ```
24
+
25
+ _without publishing (not recommended):_
26
+
27
+ ```
28
+ npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
29
+ ```
30
+
31
+ _It's important to take the tgz file, otherwise you'll get trouble with links on windows_
32
+
33
+ _using `npm link`:_
34
+
35
+ In PATH_TO_GENERATED_PACKAGE/dist:
36
+ ```
37
+ npm link
38
+ ```
39
+
40
+ In your project:
41
+ ```
42
+ npm link {{npmName}}
43
+ ```
44
+
45
+ __Note for Windows users:__ The Angular CLI has troubles to use linked npm packages.
46
+ Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround.
47
+ Published packages are not effected by this issue.
48
+
49
+
50
+ #### General usage
51
+
52
+ In your Angular project:
53
+
54
+
55
+ ```
56
+ // without configuring providers
57
+ import { {{apiModuleClassName}} } from '{{npmName}}';
58
+ import { HttpClientModule } from '@angular/common/http';
59
+
60
+ @NgModule({
61
+ imports: [
62
+ {{apiModuleClassName}},
63
+ // make sure to import the HttpClientModule in the AppModule only,
64
+ // see https://github.com/angular/angular/issues/20575
65
+ HttpClientModule
66
+ ],
67
+ declarations: [ AppComponent ],
68
+ providers: [],
69
+ bootstrap: [ AppComponent ]
70
+ })
71
+ export class AppModule {}
72
+ ```
73
+
74
+ ```
75
+ // configuring providers
76
+ import { {{apiModuleClassName}}, {{configurationClassName}}, {{configurationParametersInterfaceName}} } from '{{npmName}}';
77
+
78
+ export function apiConfigFactory (): {{configurationClassName}} {
79
+ const params: {{configurationParametersInterfaceName}} = {
80
+ // set configuration parameters here.
81
+ }
82
+ return new {{configurationClassName}}(params);
83
+ }
84
+
85
+ @NgModule({
86
+ imports: [ {{apiModuleClassName}}.forRoot(apiConfigFactory) ],
87
+ declarations: [ AppComponent ],
88
+ providers: [],
89
+ bootstrap: [ AppComponent ]
90
+ })
91
+ export class AppModule {}
92
+ ```
93
+
94
+ ```
95
+ // configuring providers with an authentication service that manages your access tokens
96
+ import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}';
97
+
98
+ @NgModule({
99
+ imports: [ {{apiModuleClassName}} ],
100
+ declarations: [ AppComponent ],
101
+ providers: [
102
+ {
103
+ provide: {{configurationClassName}},
104
+ useFactory: (authService: AuthService) => new {{configurationClassName}}(
105
+ {
106
+ basePath: environment.apiUrl,
107
+ accessToken: authService.getAccessToken.bind(authService)
108
+ }
109
+ ),
110
+ deps: [AuthService],
111
+ multi: false
112
+ }
113
+ ],
114
+ bootstrap: [ AppComponent ]
115
+ })
116
+ export class AppModule {}
117
+ ```
118
+
119
+ ```
120
+ import { DefaultApi } from '{{npmName}}';
121
+
122
+ export class AppComponent {
123
+ constructor(private apiGateway: DefaultApi) { }
124
+ }
125
+ ```
126
+
127
+ Note: The {{apiModuleClassName}} is restricted to being instantiated once app wide.
128
+ This is to ensure that all services are treated as singletons.
129
+
130
+ #### Using multiple OpenAPI files / APIs / {{apiModuleClassName}}s
131
+ In order to use multiple `{{apiModuleClassName}}s` generated from different OpenAPI files,
132
+ you can create an alias name when importing the modules
133
+ in order to avoid naming conflicts:
134
+ ```
135
+ import { {{apiModuleClassName}} } from 'my-api-path';
136
+ import { {{apiModuleClassName}} as OtherApiModule } from 'my-other-api-path';
137
+ import { HttpClientModule } from '@angular/common/http';
138
+
139
+ @NgModule({
140
+ imports: [
141
+ {{apiModuleClassName}},
142
+ OtherApiModule,
143
+ // make sure to import the HttpClientModule in the AppModule only,
144
+ // see https://github.com/angular/angular/issues/20575
145
+ HttpClientModule
146
+ ]
147
+ })
148
+ export class AppModule {
149
+
150
+ }
151
+ ```
152
+
153
+
154
+ ### Set service base path
155
+ If different than the generated base path, during app bootstrap, you can provide the base path to your service.
156
+
157
+ ```
158
+ import { BASE_PATH } from '{{npmName}}';
159
+
160
+ bootstrap(AppComponent, [
161
+ { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
162
+ ]);
163
+ ```
164
+ or
165
+
166
+ ```
167
+ import { BASE_PATH } from '{{npmName}}';
168
+
169
+ @NgModule({
170
+ imports: [],
171
+ declarations: [ AppComponent ],
172
+ providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
173
+ bootstrap: [ AppComponent ]
174
+ })
175
+ export class AppModule {}
176
+ ```
177
+
178
+
179
+ #### Using @angular/cli
180
+ First extend your `src/environments/*.ts` files by adding the corresponding base path:
181
+
182
+ ```
183
+ export const environment = {
184
+ production: false,
185
+ API_BASE_PATH: 'http://127.0.0.1:8080'
186
+ };
187
+ ```
188
+
189
+ In the src/app/app.module.ts:
190
+ ```
191
+ import { BASE_PATH } from '{{npmName}}';
192
+ import { environment } from '../environments/environment';
193
+
194
+ @NgModule({
195
+ declarations: [
196
+ AppComponent
197
+ ],
198
+ imports: [ ],
199
+ providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
200
+ bootstrap: [ AppComponent ]
201
+ })
202
+ export class AppModule { }
203
+ ```
204
+
205
+ ### Customizing path parameter encoding
206
+
207
+ Without further customization, only [path-parameters][parameter-locations-url] of [style][style-values-url] 'simple'
208
+ and Dates for format 'date-time' are encoded correctly.
209
+
210
+ Other styles (e.g. "matrix") are not that easy to encode
211
+ and thus are best delegated to other libraries (e.g.: [@honoluluhenk/http-param-expander]).
212
+
213
+ To implement your own parameter encoding (or call another library),
214
+ pass an arrow-function or method-reference to the `encodeParam` property of the Configuration-object
215
+ (see [General Usage](#general-usage) above).
216
+
217
+ Example value for use in your Configuration-Provider:
218
+ ```typescript
219
+ new Configuration({
220
+ encodeParam: (param: Param) => myFancyParamEncoder(param),
221
+ })
222
+ ```
223
+
224
+ [parameter-locations-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-locations
225
+ [style-values-url]: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-values
226
+ [@honoluluhenk/http-param-expander]: https://www.npmjs.com/package/@honoluluhenk/http-param-expander
@@ -0,0 +1,39 @@
1
+ import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
2
+ import { {{configurationClassName}} } from './configuration';
3
+ import { HttpClient } from '@angular/common/http';
4
+
5
+ {{#isProvidedInNone}}
6
+ {{#apiInfo}}
7
+ {{#apis}}
8
+ import { {{classname}} } from './{{importPath}}';
9
+ {{/apis}}
10
+ {{/apiInfo}}
11
+ {{/isProvidedInNone}}
12
+
13
+ @NgModule({
14
+ imports: [],
15
+ declarations: [],
16
+ exports: [],
17
+ providers: [{{#isProvidedInNone}}
18
+ {{#apiInfo}}{{#apis}}{{classname}}{{^-last}},
19
+ {{/-last}}{{/apis}}{{/apiInfo}} {{/isProvidedInNone}}]
20
+ })
21
+ export class {{apiModuleClassName}} {
22
+ public static forRoot(configurationFactory: () => {{configurationClassName}}): ModuleWithProviders{{#enforceGenericModuleWithProviders}}<{{apiModuleClassName}}>{{/enforceGenericModuleWithProviders}} {
23
+ return {
24
+ ngModule: {{apiModuleClassName}},
25
+ providers: [ { provide: {{configurationClassName}}, useFactory: configurationFactory } ]
26
+ };
27
+ }
28
+
29
+ constructor( @Optional() @SkipSelf() parentModule: {{apiModuleClassName}},
30
+ @Optional() http: HttpClient) {
31
+ if (parentModule) {
32
+ throw new Error('{{apiModuleClassName}} is already loaded. Import in your base AppModule only.');
33
+ }
34
+ if (!http) {
35
+ throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
36
+ 'See also https://github.com/angular/angular/issues/20575');
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,253 @@
1
+ {{>licenseInfo}}
2
+
3
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
4
+
5
+ import {Injectable} from '@angular/core';
6
+ import {HttpParams, HttpResponse} from '@angular/common/http';
7
+ import {Observable} from 'rxjs';
8
+
9
+ {{#imports}}
10
+ import { {{classname}} } from '{{filename}}';
11
+ {{/imports}}
12
+
13
+ import {BaseApiService} from './base-api.service';
14
+ import {COLLECTION_FORMATS} from '../variables';
15
+ import {addToHttpParams, getResponseType, selectHeaderAccept {{#hasSomeFormParams}}, canConsumeForm{{/hasSomeFormParams}}} from '../helpers';
16
+
17
+ {{#withInterfaces}}
18
+ import {
19
+ {{classname}}Interface{{#useSingleRequestParameter}}{{#operations}}{{#operation}}{{#allParams.0}},
20
+ {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams{{/allParams.0}}{{/operation}}{{/operations}}{{/useSingleRequestParameter}}
21
+ } from './{{classFilename}}Interface';
22
+ {{/withInterfaces}}
23
+
24
+ {{#operations}}
25
+
26
+ {{^withInterfaces}}
27
+ {{#useSingleRequestParameter}}
28
+ {{#operation}}
29
+ {{#allParams.0}}
30
+ export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams {
31
+ {{#allParams}}
32
+ {{#description}}/** {{.}} */
33
+ {{/description}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#isNullable}} | null{{/isNullable}};
34
+ {{/allParams}}
35
+ }
36
+
37
+ {{/allParams.0}}
38
+ {{/operation}}
39
+ {{/useSingleRequestParameter}}
40
+ {{/withInterfaces}}
41
+
42
+ {{#description}}
43
+ /**
44
+ * {{&description}}
45
+ */
46
+ {{/description}}
47
+ {{#isProvidedInNone}}
48
+ @Injectable()
49
+ {{/isProvidedInNone}}
50
+ {{^isProvidedInNone}}
51
+ @Injectable({
52
+ providedIn: '{{providedIn}}'
53
+ })
54
+ {{/isProvidedInNone}}
55
+ {{#withInterfaces}}
56
+ export class {{classname}} extends BaseApiService implements {{classname}}Interface {
57
+ {{/withInterfaces}}
58
+ {{^withInterfaces}}
59
+ export class {{classname}} extends BaseApiService {
60
+ {{/withInterfaces}}
61
+
62
+ {{#operation}}
63
+ /**
64
+ {{#summary}}
65
+ * {{.}}
66
+ {{/summary}}
67
+ {{#notes}}
68
+ * {{.}}
69
+ {{/notes}}
70
+ {{^useSingleRequestParameter}}
71
+ {{#allParams}}
72
+ * @param {{paramName}} {{description}}
73
+ {{/allParams}}
74
+ {{/useSingleRequestParameter}}
75
+ {{#useSingleRequestParameter}}
76
+ {{#allParams.0}}
77
+ * @param requestParameters
78
+ {{/allParams.0}}
79
+ {{/useSingleRequestParameter}}
80
+ * @param observe set whether or not to return the data Observable as the body or response. defaults to returning the body.
81
+ {{#isDeprecated}}
82
+ * @deprecated
83
+ {{/isDeprecated}}
84
+ */
85
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'body'): Observable<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>;
86
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe?: 'response'): Observable<HttpResponse<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>>;
87
+ public {{nickname}}({{^useSingleRequestParameter}}{{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}{{/useSingleRequestParameter}}{{#useSingleRequestParameter}}{{#allParams.0}}requestParameters: {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterInterfaces}}{{operationIdCamelCase}}RequestParams, {{/allParams.0}}{{/useSingleRequestParameter}}observe: 'body' | 'response' = 'body'): Observable<any> {
88
+ {{#allParams}}
89
+ {{#useSingleRequestParameter}}
90
+ const {{paramName}} = requestParameters.{{paramName}};
91
+ {{/useSingleRequestParameter}}
92
+ {{#required}}
93
+ if ({{paramName}} === null || {{paramName}} === undefined) {
94
+ throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
95
+ }
96
+ {{/required}}
97
+ {{/allParams}}
98
+
99
+ {{#hasQueryParamsOrAuth}}
100
+ let localVarQueryParameters = new HttpParams({encoder: this.encoder});
101
+ {{#queryParams}}
102
+ {{#isArray}}
103
+ if ({{paramName}}) {
104
+ {{#isQueryParamObjectFormatJson}}
105
+ localVarQueryParameters = addToHttpParams(localVarQueryParameters,
106
+ {{paramName}}, '{{baseName}}');
107
+ {{/isQueryParamObjectFormatJson}}
108
+ {{^isQueryParamObjectFormatJson}}
109
+ {{#isCollectionFormatMulti}}
110
+ {{paramName}}.forEach((element) => {
111
+ localVarQueryParameters = addToHttpParams(localVarQueryParameters,
112
+ element, '{{baseName}}');
113
+ })
114
+ {{/isCollectionFormatMulti}}
115
+ {{^isCollectionFormatMulti}}
116
+ localVarQueryParameters = addToHttpParams(localVarQueryParameters,
117
+ [...{{paramName}}].join(COLLECTION_FORMATS['{{collectionFormat}}']), '{{baseName}}');
118
+ {{/isCollectionFormatMulti}}
119
+ {{/isQueryParamObjectFormatJson}}
120
+ }
121
+ {{/isArray}}
122
+ {{^isArray}}
123
+ if ({{paramName}} !== undefined && {{paramName}} !== null) {
124
+ localVarQueryParameters = addToHttpParams(localVarQueryParameters,
125
+ {{paramName}}, '{{baseName}}');
126
+ }
127
+ {{/isArray}}
128
+ {{/queryParams}}
129
+
130
+ {{/hasQueryParamsOrAuth}}
131
+ let localVarHeaders = this.defaultHeaders;
132
+ {{#headerParams}}
133
+ {{#isArray}}
134
+ if ({{paramName}}) {
135
+ localVarHeaders = localVarHeaders.set('{{baseName}}', [...{{paramName}}].join(COLLECTION_FORMATS['{{collectionFormat}}']));
136
+ }
137
+ {{/isArray}}
138
+ {{^isArray}}
139
+ if ({{paramName}} !== undefined && {{paramName}} !== null) {
140
+ localVarHeaders = localVarHeaders.set('{{baseName}}', String({{paramName}}));
141
+ }
142
+ {{/isArray}}
143
+ {{/headerParams}}
144
+ const localVarHttpHeaderAcceptSelected = selectHeaderAccept([
145
+ {{#produces}}
146
+ '{{{mediaType}}}'{{^-last}},{{/-last}}
147
+ {{/produces}}
148
+ ], {}, this.configuration);
149
+ if (localVarHttpHeaderAcceptSelected !== undefined) {
150
+ localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
151
+ }
152
+
153
+ {{#bodyParam}}
154
+ {{- duplicated below, don't forget to change}}
155
+ // to determine the Content-Type header
156
+ const consumes: string[] = [
157
+ {{#consumes}}
158
+ '{{{mediaType}}}'{{^-last}},{{/-last}}
159
+ {{/consumes}}
160
+ ];
161
+ {{/bodyParam}}
162
+ {{#hasFormParams}}
163
+ {{^bodyParam}}
164
+ // to determine the Content-Type header
165
+ const consumes: string[] = [
166
+ {{#consumes}}
167
+ '{{{mediaType}}}'{{^-last}},{{/-last}}
168
+ {{/consumes}}
169
+ ];
170
+ {{/bodyParam}}
171
+ {{/hasFormParams}}
172
+ {{#bodyParam}}
173
+ const httpContentTypeSelected: string | undefined = this.configuration.selectHeaderContentType(consumes);
174
+ if (httpContentTypeSelected !== undefined) {
175
+ localVarHeaders = localVarHeaders.set('Content-Type', httpContentTypeSelected);
176
+ }
177
+ {{/bodyParam}}
178
+
179
+ {{#hasFormParams}}
180
+ const canConsumeForm = this.canConsumeForm(consumes);
181
+
182
+ let localVarFormParams: { append(param: string, value: any): any; };
183
+ let localVarUseForm = false;
184
+ let localVarConvertFormParamsToString = false;
185
+ {{#formParams}}
186
+ {{#isFile}}
187
+ // use FormData to transmit files using content-type "multipart/form-data"
188
+ // see https://stackoverflow.com/questions/4007969/application-x-www-form-urlencoded-or-multipart-form-data
189
+ localVarUseForm = canConsumeForm;
190
+ {{/isFile}}
191
+ {{/formParams}}
192
+ if (localVarUseForm) {
193
+ localVarFormParams = new FormData();
194
+ } else {
195
+ localVarFormParams = new HttpParams({encoder: this.encoder});
196
+ }
197
+
198
+ {{#formParams}}
199
+ {{#isArray}}
200
+ if ({{paramName}}) {
201
+ {{#isCollectionFormatMulti}}
202
+ {{paramName}}.forEach((element) => {
203
+ localVarFormParams = localVarFormParams.append('{{baseName}}', <any>element) as any || localVarFormParams;
204
+ })
205
+ {{/isCollectionFormatMulti}}
206
+ {{^isCollectionFormatMulti}}
207
+ if (localVarUseForm) {
208
+ {{paramName}}.forEach((element) => {
209
+ localVarFormParams = localVarFormParams.append('{{baseName}}', <any>element) as any || localVarFormParams;
210
+ })
211
+ } else {
212
+ localVarFormParams = localVarFormParams.append('{{baseName}}', [...{{paramName}}].join(COLLECTION_FORMATS['{{collectionFormat}}'])) as any || localVarFormParams;
213
+ }
214
+ {{/isCollectionFormatMulti}}
215
+ }
216
+ {{/isArray}}
217
+ {{^isArray}}
218
+ if ({{paramName}} !== undefined) {
219
+ localVarFormParams = localVarFormParams.append('{{baseName}}', {{^isModel}}<any>{{paramName}}{{/isModel}}{{#isModel}}localVarUseForm ? new Blob([JSON.stringify({{paramName}})], {type: 'application/json'}) : <any>{{paramName}}{{/isModel}}) as any || localVarFormParams;
220
+ }
221
+ {{/isArray}}
222
+ {{/formParams}}
223
+
224
+ {{/hasFormParams}}
225
+ let localVarPath = `{{{path}}}`;
226
+ return this.httpClient.request{{^isResponseFile}}<{{#returnType}}{{{returnType}}}{{#isResponseTypeFile}}|undefined{{/isResponseTypeFile}}{{/returnType}}{{^returnType}}any{{/returnType}}>{{/isResponseFile}}('{{httpMethod}}', `${this.configuration.basePath}${localVarPath}`,
227
+ {
228
+ {{#bodyParam}}
229
+ body: {{paramName}},
230
+ {{/bodyParam}}
231
+ {{^bodyParam}}
232
+ {{#hasFormParams}}
233
+ body: localVarConvertFormParamsToString ? localVarFormParams.toString() : localVarFormParams,
234
+ {{/hasFormParams}}
235
+ {{/bodyParam}}
236
+ {{#hasQueryParamsOrAuth}}
237
+ params: localVarQueryParameters,
238
+ {{/hasQueryParamsOrAuth}}
239
+ {{#isResponseFile}}
240
+ responseType: "blob",
241
+ {{/isResponseFile}}
242
+ {{^isResponseFile}}
243
+ responseType: <any>getResponseType(localVarHttpHeaderAcceptSelected, this.configuration),
244
+ {{/isResponseFile}}
245
+ withCredentials: this.configuration.withCredentials,
246
+ headers: localVarHeaders,
247
+ observe: <any>observe
248
+ }
249
+ );
250
+ }
251
+
252
+ {{/operation}}}
253
+ {{/operations}}