@emilgroup/commission-sdk 1.0.0-beta.1

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 (106) hide show
  1. package/.openapi-generator/FILES +40 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -0
  5. package/api/commission-agreement-versions-api.ts +531 -0
  6. package/api/commission-agreements-api.ts +638 -0
  7. package/api/commissions-api.ts +637 -0
  8. package/api/default-api.ts +124 -0
  9. package/api.ts +33 -0
  10. package/base.ts +331 -0
  11. package/common.ts +198 -0
  12. package/configuration.ts +110 -0
  13. package/dist/api/commission-agreement-versions-api.d.ts +300 -0
  14. package/dist/api/commission-agreement-versions-api.js +527 -0
  15. package/dist/api/commission-agreements-api.d.ts +357 -0
  16. package/dist/api/commission-agreements-api.js +620 -0
  17. package/dist/api/commissions-api.d.ts +357 -0
  18. package/dist/api/commissions-api.js +620 -0
  19. package/dist/api/default-api.d.ts +70 -0
  20. package/dist/api/default-api.js +200 -0
  21. package/dist/api.d.ts +15 -0
  22. package/dist/api.js +33 -0
  23. package/dist/base.d.ts +86 -0
  24. package/dist/base.js +367 -0
  25. package/dist/common.d.ts +91 -0
  26. package/dist/common.js +276 -0
  27. package/dist/configuration.d.ts +89 -0
  28. package/dist/configuration.js +52 -0
  29. package/dist/index.d.ts +15 -0
  30. package/dist/index.js +36 -0
  31. package/dist/models/commission-agreement-class.d.ts +89 -0
  32. package/dist/models/commission-agreement-class.js +25 -0
  33. package/dist/models/commission-agreement-version-class.d.ts +79 -0
  34. package/dist/models/commission-agreement-version-class.js +15 -0
  35. package/dist/models/commission-class.d.ts +103 -0
  36. package/dist/models/commission-class.js +15 -0
  37. package/dist/models/commission-item-class.d.ts +84 -0
  38. package/dist/models/commission-item-class.js +21 -0
  39. package/dist/models/create-commission-agreement-request-dto.d.ts +71 -0
  40. package/dist/models/create-commission-agreement-request-dto.js +25 -0
  41. package/dist/models/create-commission-agreement-response-class.d.ts +25 -0
  42. package/dist/models/create-commission-agreement-response-class.js +15 -0
  43. package/dist/models/create-commission-agreement-version-request-dto.d.ts +42 -0
  44. package/dist/models/create-commission-agreement-version-request-dto.js +15 -0
  45. package/dist/models/create-commission-agreement-version-response-class.d.ts +25 -0
  46. package/dist/models/create-commission-agreement-version-response-class.js +15 -0
  47. package/dist/models/create-commission-item-request-dto.d.ts +48 -0
  48. package/dist/models/create-commission-item-request-dto.js +21 -0
  49. package/dist/models/create-commission-request-dto.d.ts +55 -0
  50. package/dist/models/create-commission-request-dto.js +15 -0
  51. package/dist/models/create-commission-response-class.d.ts +25 -0
  52. package/dist/models/create-commission-response-class.js +15 -0
  53. package/dist/models/get-commission-agreement-response-class.d.ts +25 -0
  54. package/dist/models/get-commission-agreement-response-class.js +15 -0
  55. package/dist/models/get-commission-agreement-version-response-class.d.ts +25 -0
  56. package/dist/models/get-commission-agreement-version-response-class.js +15 -0
  57. package/dist/models/get-commission-response-class.d.ts +25 -0
  58. package/dist/models/get-commission-response-class.js +15 -0
  59. package/dist/models/index.d.ts +23 -0
  60. package/dist/models/index.js +39 -0
  61. package/dist/models/inline-response200.d.ts +54 -0
  62. package/dist/models/inline-response200.js +15 -0
  63. package/dist/models/inline-response503.d.ts +54 -0
  64. package/dist/models/inline-response503.js +15 -0
  65. package/dist/models/list-commission-agreement-versions-response-class.d.ts +43 -0
  66. package/dist/models/list-commission-agreement-versions-response-class.js +15 -0
  67. package/dist/models/list-commission-agreements-response-class.d.ts +43 -0
  68. package/dist/models/list-commission-agreements-response-class.js +15 -0
  69. package/dist/models/list-commissions-response-class.d.ts +43 -0
  70. package/dist/models/list-commissions-response-class.js +15 -0
  71. package/dist/models/update-commission-agreement-request-dto.d.ts +48 -0
  72. package/dist/models/update-commission-agreement-request-dto.js +21 -0
  73. package/dist/models/update-commission-agreement-response-class.d.ts +25 -0
  74. package/dist/models/update-commission-agreement-response-class.js +15 -0
  75. package/dist/models/update-commission-request-dto.d.ts +53 -0
  76. package/dist/models/update-commission-request-dto.js +20 -0
  77. package/dist/models/update-commission-response-class.d.ts +25 -0
  78. package/dist/models/update-commission-response-class.js +15 -0
  79. package/git_push.sh +57 -0
  80. package/index.ts +19 -0
  81. package/models/commission-agreement-class.ts +99 -0
  82. package/models/commission-agreement-version-class.ts +85 -0
  83. package/models/commission-class.ts +109 -0
  84. package/models/commission-item-class.ts +93 -0
  85. package/models/create-commission-agreement-request-dto.ts +81 -0
  86. package/models/create-commission-agreement-response-class.ts +31 -0
  87. package/models/create-commission-agreement-version-request-dto.ts +48 -0
  88. package/models/create-commission-agreement-version-response-class.ts +31 -0
  89. package/models/create-commission-item-request-dto.ts +57 -0
  90. package/models/create-commission-request-dto.ts +61 -0
  91. package/models/create-commission-response-class.ts +31 -0
  92. package/models/get-commission-agreement-response-class.ts +31 -0
  93. package/models/get-commission-agreement-version-response-class.ts +31 -0
  94. package/models/get-commission-response-class.ts +31 -0
  95. package/models/index.ts +23 -0
  96. package/models/inline-response200.ts +48 -0
  97. package/models/inline-response503.ts +48 -0
  98. package/models/list-commission-agreement-versions-response-class.ts +49 -0
  99. package/models/list-commission-agreements-response-class.ts +49 -0
  100. package/models/list-commissions-response-class.ts +49 -0
  101. package/models/update-commission-agreement-request-dto.ts +57 -0
  102. package/models/update-commission-agreement-response-class.ts +31 -0
  103. package/models/update-commission-request-dto.ts +62 -0
  104. package/models/update-commission-response-class.ts +31 -0
  105. package/package.json +26 -0
  106. package/tsconfig.json +23 -0
@@ -0,0 +1,124 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CommissionService
5
+ * The EMIL CommissionService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
17
+ import { Configuration } from '../configuration';
18
+ // Some imports not used depending on template conditions
19
+ // @ts-ignore
20
+ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
21
+ // @ts-ignore
22
+ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from '../base';
23
+ // @ts-ignore
24
+ import { InlineResponse200 } from '../models';
25
+ // @ts-ignore
26
+ import { InlineResponse503 } from '../models';
27
+ /**
28
+ * DefaultApi - axios parameter creator
29
+ * @export
30
+ */
31
+ export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
32
+ return {
33
+ /**
34
+ * Returns the health status of the CommissionService service. This endpoint is used to monitor the operational status of the CommissionService service. It typically returns a simple status indicator, such as \'UP\' or \'OK\', confirming that the service is operational and available.
35
+ * @summary Health Check
36
+ * @param {*} [options] Override http request option.
37
+ * @throws {RequiredError}
38
+ */
39
+ check: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
40
+ const localVarPath = `/commissionservice/health`;
41
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
42
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
43
+ let baseOptions;
44
+ let baseAccessToken;
45
+ if (configuration) {
46
+ baseOptions = configuration.baseOptions;
47
+ baseAccessToken = configuration.accessToken;
48
+ }
49
+
50
+ const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
51
+ const localVarHeaderParameter = {} as any;
52
+ const localVarQueryParameter = {} as any;
53
+
54
+
55
+
56
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
57
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
58
+ localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
59
+
60
+ return {
61
+ url: toPathString(localVarUrlObj),
62
+ options: localVarRequestOptions,
63
+ };
64
+ },
65
+ }
66
+ };
67
+
68
+ /**
69
+ * DefaultApi - functional programming interface
70
+ * @export
71
+ */
72
+ export const DefaultApiFp = function(configuration?: Configuration) {
73
+ const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration)
74
+ return {
75
+ /**
76
+ * Returns the health status of the CommissionService service. This endpoint is used to monitor the operational status of the CommissionService service. It typically returns a simple status indicator, such as \'UP\' or \'OK\', confirming that the service is operational and available.
77
+ * @summary Health Check
78
+ * @param {*} [options] Override http request option.
79
+ * @throws {RequiredError}
80
+ */
81
+ async check(options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<InlineResponse200>> {
82
+ const localVarAxiosArgs = await localVarAxiosParamCreator.check(options);
83
+ return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
84
+ },
85
+ }
86
+ };
87
+
88
+ /**
89
+ * DefaultApi - factory interface
90
+ * @export
91
+ */
92
+ export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
93
+ const localVarFp = DefaultApiFp(configuration)
94
+ return {
95
+ /**
96
+ * Returns the health status of the CommissionService service. This endpoint is used to monitor the operational status of the CommissionService service. It typically returns a simple status indicator, such as \'UP\' or \'OK\', confirming that the service is operational and available.
97
+ * @summary Health Check
98
+ * @param {*} [options] Override http request option.
99
+ * @throws {RequiredError}
100
+ */
101
+ check(options?: any): AxiosPromise<InlineResponse200> {
102
+ return localVarFp.check(options).then((request) => request(axios, basePath));
103
+ },
104
+ };
105
+ };
106
+
107
+ /**
108
+ * DefaultApi - object-oriented interface
109
+ * @export
110
+ * @class DefaultApi
111
+ * @extends {BaseAPI}
112
+ */
113
+ export class DefaultApi extends BaseAPI {
114
+ /**
115
+ * Returns the health status of the CommissionService service. This endpoint is used to monitor the operational status of the CommissionService service. It typically returns a simple status indicator, such as \'UP\' or \'OK\', confirming that the service is operational and available.
116
+ * @summary Health Check
117
+ * @param {*} [options] Override http request option.
118
+ * @throws {RequiredError}
119
+ * @memberof DefaultApi
120
+ */
121
+ public check(options?: AxiosRequestConfig) {
122
+ return DefaultApiFp(this.configuration).check(options).then((request) => request(this.axios, this.basePath));
123
+ }
124
+ }
package/api.ts ADDED
@@ -0,0 +1,33 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CommissionService
5
+ * The EMIL CommissionService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { Configuration } from './configuration';
17
+ import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
18
+ // Some imports not used depending on template conditions
19
+ // @ts-ignore
20
+ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
21
+ // @ts-ignore
22
+ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';
23
+ import { CommissionAgreementVersionsApi } from './api';
24
+ import { CommissionAgreementsApi } from './api';
25
+ import { CommissionsApi } from './api';
26
+ import { DefaultApi } from './api';
27
+
28
+
29
+ export * from './api/commission-agreement-versions-api';
30
+ export * from './api/commission-agreements-api';
31
+ export * from './api/commissions-api';
32
+ export * from './api/default-api';
33
+
package/base.ts ADDED
@@ -0,0 +1,331 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CommissionService
5
+ * The EMIL CommissionService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { Configuration } from "./configuration";
17
+ import { defaultStorage } from "./common";
18
+ // Some imports not used depending on template conditions
19
+ // @ts-ignore
20
+ import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
21
+
22
+
23
+ export const BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
24
+ /**
25
+ *
26
+ * @export
27
+ */
28
+ export const COLLECTION_FORMATS = {
29
+ csv: ",",
30
+ ssv: " ",
31
+ tsv: "\t",
32
+ pipes: "|",
33
+ };
34
+
35
+ export interface LoginClass {
36
+ accessToken: string;
37
+ permissions: string;
38
+ }
39
+
40
+ export interface SwitchWorkspaceRequest {
41
+ username: string;
42
+ targetWorkspace: string;
43
+ }
44
+
45
+ export interface SwitchWorkspaceResponseClass {
46
+ accessToken: string;
47
+ permissions: string;
48
+ }
49
+
50
+ export enum Environment {
51
+ Production = 'https://apiv2.emil.de',
52
+ Test = 'https://apiv2-test.emil.de',
53
+ Staging = 'https://apiv2-staging.emil.de',
54
+ Development = 'https://apiv2-dev.emil.de',
55
+ ProductionZurich = 'https://eu-central-2.apiv2.emil.de',
56
+ }
57
+
58
+ let _retry_count = 0
59
+ let _retry = null
60
+
61
+ export function resetRetry() {
62
+ _retry_count = 0
63
+ }
64
+
65
+ /**
66
+ *
67
+ * @export
68
+ * @interface RequestArgs
69
+ */
70
+ export interface RequestArgs {
71
+ url: string;
72
+ options: AxiosRequestConfig;
73
+ }
74
+
75
+ interface TokenData {
76
+ accessToken?: string;
77
+ username?: string;
78
+ permissions?: string;
79
+ }
80
+
81
+ const NETWORK_ERROR_MESSAGE = "Network Error";
82
+ const TOKEN_DATA = 'APP_TOKEN';
83
+
84
+ /**
85
+ *
86
+ * @export
87
+ * @class BaseAPI
88
+ */
89
+ export class BaseAPI {
90
+ protected configuration: Configuration | undefined;
91
+ private tokenData?: TokenData;
92
+
93
+ constructor(configuration?: Configuration,
94
+ protected basePath: string = BASE_PATH,
95
+ protected axios: AxiosInstance = globalAxios) {
96
+
97
+ this.loadTokenData();
98
+
99
+ if (configuration) {
100
+ const { accessToken } = this.tokenData;
101
+ this.configuration = configuration;
102
+ this.basePath = configuration.basePath || this.basePath;
103
+
104
+ // Use config token if provided, otherwise use tokenData token
105
+ const configToken = this.configuration.accessToken;
106
+ const storedToken = accessToken ? `Bearer ${accessToken}` : '';
107
+ this.configuration.accessToken = configToken || storedToken;
108
+ } else {
109
+ const { accessToken, username } = this.tokenData;
110
+
111
+ this.configuration = new Configuration({
112
+ basePath: this.basePath,
113
+ accessToken: accessToken ? `Bearer ${accessToken}` : '',
114
+ username,
115
+ });
116
+ }
117
+
118
+ this.attachInterceptor(axios);
119
+ }
120
+
121
+ selectEnvironment(env: Environment) {
122
+ this.selectBasePath(env);
123
+ }
124
+
125
+ selectBasePath(path: string) {
126
+ this.configuration.basePath = path;
127
+ }
128
+
129
+ getPermissions(): Array<string> {
130
+ if (!this.tokenData?.permissions) {
131
+ return [];
132
+ }
133
+
134
+ return this.tokenData.permissions.split(',');
135
+ }
136
+
137
+ async authorize(username: string, password: string, targetWorkspace?: string): Promise<void> {
138
+ const options: AxiosRequestConfig = {
139
+ method: 'POST',
140
+ url: `${this.configuration.basePath}/authservice/v1/login`,
141
+ headers: { 'Content-Type': 'application/json' },
142
+ data: {
143
+ username,
144
+ password,
145
+ },
146
+ withCredentials: true,
147
+ };
148
+
149
+ const response = await globalAxios.request<LoginClass>(options);
150
+
151
+ const { data: { accessToken, permissions } } = response;
152
+
153
+ this.configuration.username = username;
154
+ this.configuration.accessToken = `Bearer ${accessToken}`;
155
+ this.tokenData.username = username;
156
+ this.tokenData.accessToken = accessToken;
157
+ this.tokenData.permissions = permissions;
158
+
159
+ // Switch workspace if provided
160
+ if (targetWorkspace) {
161
+ await this.switchWorkspace(targetWorkspace);
162
+ } else {
163
+ // Only store if no workspace switch (since switchWorkspace will store after switching)
164
+ this.storeTokenData({
165
+ ...this.tokenData
166
+ });
167
+ }
168
+
169
+ this.storeTokenData({
170
+ ...this.tokenData
171
+ });
172
+ }
173
+
174
+ async switchWorkspace(targetWorkspace: string): Promise<void> {
175
+ const options: AxiosRequestConfig = {
176
+ method: 'POST',
177
+ url: `${this.configuration.basePath}/authservice/v1/workspaces/switch`,
178
+ headers: {
179
+ 'Content-Type': 'application/json',
180
+ 'Authorization': `Bearer ${this.configuration.accessToken}`,
181
+ },
182
+ data: {
183
+ username: this.configuration.username,
184
+ targetWorkspace,
185
+ } as SwitchWorkspaceRequest,
186
+ withCredentials: true,
187
+ };
188
+
189
+ const response = await globalAxios.request<SwitchWorkspaceResponseClass>(options);
190
+
191
+ const { data: { accessToken, permissions } } = response;
192
+
193
+ this.configuration.accessToken = `Bearer ${accessToken}`;
194
+ this.tokenData.accessToken = accessToken;
195
+ this.tokenData.permissions = permissions;
196
+
197
+ this.storeTokenData({
198
+ ...this.tokenData
199
+ });
200
+ }
201
+
202
+ async refreshTokenInternal(): Promise<LoginClass> {
203
+ const { username } = this.configuration;
204
+
205
+ if (!username) {
206
+ throw new Error('Failed to refresh token.');
207
+ }
208
+
209
+ const refreshTokenAxios = globalAxios.create()
210
+ refreshTokenAxios.interceptors.response.use(response => {
211
+ const { permissions } = response.data;
212
+
213
+ this.tokenData.permissions = permissions;
214
+ this.storeTokenData(this.tokenData);
215
+
216
+ return response;
217
+ })
218
+
219
+ const options: AxiosRequestConfig = {
220
+ method: 'POST',
221
+ url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
222
+ headers: {
223
+ 'Content-Type': 'application/json',
224
+ },
225
+ data: { username: username },
226
+ withCredentials: true,
227
+ };
228
+
229
+ const response = await refreshTokenAxios.request<LoginClass>(options);
230
+ return response.data;
231
+ }
232
+
233
+ private storeTokenData(tokenData?: TokenData) {
234
+ if (typeof window !== 'undefined') {
235
+ defaultStorage().set<TokenData>(TOKEN_DATA, tokenData);
236
+ }
237
+ }
238
+
239
+ public loadTokenData() {
240
+ if (typeof window !== 'undefined') {
241
+ this.tokenData = defaultStorage().get<TokenData>(TOKEN_DATA) || {};
242
+ } else {
243
+ this.tokenData = {};
244
+ }
245
+ }
246
+
247
+ public cleanTokenData() {
248
+ this.storeTokenData(null);
249
+ }
250
+
251
+ private attachInterceptor(axios: AxiosInstance) {
252
+ axios.interceptors.response.use(
253
+ (res) => {
254
+ return res;
255
+ },
256
+ async (err) => {
257
+ let originalConfig = err.config;
258
+ if (err.response && !(err.response instanceof XMLHttpRequest)) { // sometimes buggy and is of type request
259
+ // Access Token was expired
260
+ if ((err.response.status === 401 || err.response.status === 403)
261
+ && !originalConfig._retry) {
262
+ originalConfig._retry = true;
263
+ try {
264
+ const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
265
+ const accessToken = `Bearer ${tokenString}`;
266
+ this.tokenData.permissions = permissions;
267
+
268
+ delete originalConfig.headers['Authorization']
269
+
270
+ originalConfig.headers['Authorization'] = accessToken;
271
+
272
+ this.configuration.accessToken = accessToken;
273
+ this.tokenData.accessToken = tokenString;
274
+
275
+ this.storeTokenData(this.tokenData);
276
+
277
+ return axios(originalConfig);
278
+ } catch (_error) {
279
+ if (_error.response && _error.response.data) {
280
+ return Promise.reject(_error.response.data);
281
+ }
282
+ return Promise.reject(_error);
283
+ }
284
+ }
285
+ } else if (err.message === NETWORK_ERROR_MESSAGE
286
+ && originalConfig.headers.hasOwnProperty('Authorization')
287
+ && _retry_count < 4
288
+ ) {
289
+ _retry_count++;
290
+ try {
291
+ const { accessToken: tokenString, permissions } = await this.refreshTokenInternal();
292
+ const accessToken = `Bearer ${tokenString}`;
293
+ this.tokenData.permissions = permissions;
294
+
295
+ _retry = true;
296
+ originalConfig.headers['Authorization'] = accessToken;
297
+
298
+ this.configuration.accessToken = accessToken;
299
+ this.tokenData.accessToken = tokenString;
300
+
301
+ this.storeTokenData(this.tokenData);
302
+
303
+ return axios.request({
304
+ ...originalConfig,
305
+ });
306
+ } catch (_error) {
307
+ if (_error.response && _error.response.data) {
308
+ return Promise.reject(_error.response.data);
309
+ }
310
+ return Promise.reject(_error);
311
+ }
312
+ }
313
+ return Promise.reject(err);
314
+ }
315
+ );
316
+ }
317
+ };
318
+
319
+ /**
320
+ *
321
+ * @export
322
+ * @class RequiredError
323
+ * @extends {Error}
324
+ */
325
+ export class RequiredError extends Error {
326
+ override name: "RequiredError" = "RequiredError";
327
+ constructor(public field: string, msg?: string) {
328
+ super(msg);
329
+ }
330
+ }
331
+
package/common.ts ADDED
@@ -0,0 +1,198 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CommissionService
5
+ * The EMIL CommissionService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { Configuration } from "./configuration";
17
+ import { RequiredError, RequestArgs } from "./base";
18
+ import { AxiosInstance, AxiosResponse } from 'axios';
19
+ /**
20
+ *
21
+ * @export
22
+ */
23
+ export const DUMMY_BASE_URL = 'https://example.com'
24
+
25
+ /**
26
+ *
27
+ * @throws {RequiredError}
28
+ * @export
29
+ */
30
+ export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
31
+ if (paramValue === null || paramValue === undefined) {
32
+ throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
33
+ }
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @export
39
+ */
40
+ export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
41
+ if (configuration && configuration.apiKey) {
42
+ const localVarApiKeyValue = typeof configuration.apiKey === 'function'
43
+ ? await configuration.apiKey(keyParamName)
44
+ : await configuration.apiKey;
45
+ object[keyParamName] = localVarApiKeyValue;
46
+ }
47
+ }
48
+
49
+ /**
50
+ *
51
+ * @export
52
+ */
53
+ export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
54
+ if (configuration && (configuration.username || configuration.password)) {
55
+ object["auth"] = { username: configuration.username, password: configuration.password };
56
+ }
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @export
62
+ */
63
+ export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
64
+ if (configuration && configuration.accessToken) {
65
+ const accessToken = typeof configuration.accessToken === 'function'
66
+ ? await configuration.accessToken()
67
+ : await configuration.accessToken;
68
+ object["Authorization"] = configuration.getBearerToken(accessToken);
69
+ }
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @export
75
+ */
76
+ export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
77
+ if (configuration && configuration.accessToken) {
78
+ const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
79
+ ? await configuration.accessToken(name, scopes)
80
+ : await configuration.accessToken;
81
+ object["Authorization"] = configuration.getBearerToken(localVarAccessTokenValue);
82
+ }
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @export
88
+ */
89
+ export const setSearchParams = function (url: URL, ...objects: any[]) {
90
+ const searchParams = new URLSearchParams(url.search);
91
+ for (const object of objects) {
92
+ for (const key in object) {
93
+ if (Array.isArray(object[key])) {
94
+ searchParams.delete(key);
95
+ for (const item of object[key]) {
96
+ searchParams.append(key, item);
97
+ }
98
+ } else {
99
+ searchParams.set(key, object[key]);
100
+ }
101
+ }
102
+ }
103
+ url.search = searchParams.toString();
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @export
109
+ */
110
+ export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
111
+ const nonString = typeof value !== 'string';
112
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
113
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
114
+ : nonString;
115
+ return needsSerialization
116
+ ? JSON.stringify(value !== undefined ? value : {})
117
+ : (value || "");
118
+ }
119
+
120
+ /**
121
+ *
122
+ * @export
123
+ */
124
+ export const toPathString = function (url: URL) {
125
+ return url.pathname + url.search + url.hash
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @export
131
+ */
132
+ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
133
+ return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
134
+ const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
135
+ return axios.request<T, R>(axiosRequestArgs);
136
+ };
137
+ }
138
+
139
+ /* tslint:disable */
140
+ /* eslint-disable */
141
+ /**
142
+ * EMIL CommissionService
143
+ * The EMIL CommissionService API description
144
+ *
145
+ * The version of the OpenAPI document: 1.0
146
+ * Contact: kontakt@emil.de
147
+ *
148
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
149
+ * https://openapi-generator.tech
150
+ * Do not edit the class manually.
151
+ */
152
+
153
+
154
+ export interface IStorageConverter<D, SD> {
155
+ toStorageData( data: D ): SD;
156
+ fromStorageData( storageData: SD ): D;
157
+ }
158
+
159
+ export interface IStorage {
160
+ get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null;
161
+ set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void;
162
+ }
163
+
164
+ export class LocalStorage implements IStorage {
165
+ readonly storage: Storage;
166
+
167
+ constructor() {
168
+ this.storage = localStorage;
169
+ }
170
+
171
+ get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null {
172
+ const jsonValue = this.storage.getItem( key );
173
+ if ( jsonValue === null ) {
174
+ return null;
175
+ }
176
+ const value = JSON.parse( jsonValue );
177
+ if ( converter !== undefined ) {
178
+ return converter.fromStorageData( value );
179
+ } else {
180
+ return value as T;
181
+ }
182
+ }
183
+
184
+ set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void {
185
+ let valueToStore: any = value;
186
+ if ( converter !== undefined ) {
187
+ valueToStore = converter.toStorageData( value );
188
+ }
189
+ const jsonValue = JSON.stringify( valueToStore );
190
+ this.storage.setItem( key, jsonValue );
191
+ }
192
+ }
193
+
194
+ let _defaultStorage: IStorage = null;
195
+
196
+ export const defaultStorage = (): IStorage => {
197
+ return _defaultStorage || (_defaultStorage = new LocalStorage());
198
+ };