@emilgroup/financemanager-sdk 1.0.1-beta.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 (52) hide show
  1. package/.openapi-generator/FILES +22 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -0
  5. package/api/payout-matching-service-api.ts +232 -0
  6. package/api.ts +27 -0
  7. package/base.ts +465 -0
  8. package/common.ts +199 -0
  9. package/configuration.ts +130 -0
  10. package/dist/api/payout-matching-service-api.d.ts +141 -0
  11. package/dist/api/payout-matching-service-api.js +251 -0
  12. package/dist/api.d.ts +12 -0
  13. package/dist/api.js +30 -0
  14. package/dist/base.d.ts +111 -0
  15. package/dist/base.js +487 -0
  16. package/dist/common.d.ts +91 -0
  17. package/dist/common.js +277 -0
  18. package/dist/configuration.d.ts +106 -0
  19. package/dist/configuration.js +54 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.js +36 -0
  22. package/dist/models/any.d.ts +25 -0
  23. package/dist/models/any.js +15 -0
  24. package/dist/models/bank-order-payment-requests.d.ts +79 -0
  25. package/dist/models/bank-order-payment-requests.js +15 -0
  26. package/dist/models/bank-transaction-summary.d.ts +48 -0
  27. package/dist/models/bank-transaction-summary.js +15 -0
  28. package/dist/models/candidate-row.d.ts +32 -0
  29. package/dist/models/candidate-row.js +15 -0
  30. package/dist/models/counterparty.d.ts +30 -0
  31. package/dist/models/counterparty.js +15 -0
  32. package/dist/models/get-payment-request-candidates-response.d.ts +56 -0
  33. package/dist/models/get-payment-request-candidates-response.js +15 -0
  34. package/dist/models/index.d.ts +8 -0
  35. package/dist/models/index.js +24 -0
  36. package/dist/models/payment-request-candidate.d.ts +79 -0
  37. package/dist/models/payment-request-candidate.js +15 -0
  38. package/dist/models/status.d.ts +37 -0
  39. package/dist/models/status.js +15 -0
  40. package/git_push.sh +57 -0
  41. package/index.ts +19 -0
  42. package/models/any.ts +32 -0
  43. package/models/bank-order-payment-requests.ts +85 -0
  44. package/models/bank-transaction-summary.ts +54 -0
  45. package/models/candidate-row.ts +38 -0
  46. package/models/counterparty.ts +36 -0
  47. package/models/get-payment-request-candidates-response.ts +62 -0
  48. package/models/index.ts +8 -0
  49. package/models/payment-request-candidate.ts +85 -0
  50. package/models/status.ts +43 -0
  51. package/package.json +27 -0
  52. package/tsconfig.json +23 -0
package/dist/base.js ADDED
@@ -0,0 +1,487 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL Financemanager
6
+ * The EMIL Financemanager API description.
7
+ *
8
+ * The version of the OpenAPI document: 1.0
9
+ * Contact: kontakt@emil.de
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __extends = (this && this.__extends) || (function () {
16
+ var extendStatics = function (d, b) {
17
+ extendStatics = Object.setPrototypeOf ||
18
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
20
+ return extendStatics(d, b);
21
+ };
22
+ return function (d, b) {
23
+ if (typeof b !== "function" && b !== null)
24
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
+ extendStatics(d, b);
26
+ function __() { this.constructor = d; }
27
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28
+ };
29
+ })();
30
+ var __assign = (this && this.__assign) || function () {
31
+ __assign = Object.assign || function(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
35
+ t[p] = s[p];
36
+ }
37
+ return t;
38
+ };
39
+ return __assign.apply(this, arguments);
40
+ };
41
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
+ return new (P || (P = Promise))(function (resolve, reject) {
44
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+ var __generator = (this && this.__generator) || function (thisArg, body) {
51
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
52
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
53
+ function verb(n) { return function (v) { return step([n, v]); }; }
54
+ function step(op) {
55
+ if (f) throw new TypeError("Generator is already executing.");
56
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
57
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
+ if (y = 0, t) op = [op[0] & 2, t.value];
59
+ switch (op[0]) {
60
+ case 0: case 1: t = op; break;
61
+ case 4: _.label++; return { value: op[1], done: false };
62
+ case 5: _.label++; y = op[1]; op = [0]; continue;
63
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
64
+ default:
65
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
66
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
67
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
68
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
69
+ if (t[2]) _.ops.pop();
70
+ _.trys.pop(); continue;
71
+ }
72
+ op = body.call(thisArg, _);
73
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
74
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
75
+ }
76
+ };
77
+ var __rest = (this && this.__rest) || function (s, e) {
78
+ var t = {};
79
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
80
+ t[p] = s[p];
81
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
82
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
83
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
84
+ t[p[i]] = s[p[i]];
85
+ }
86
+ return t;
87
+ };
88
+ var __importDefault = (this && this.__importDefault) || function (mod) {
89
+ return (mod && mod.__esModule) ? mod : { "default": mod };
90
+ };
91
+ Object.defineProperty(exports, "__esModule", { value: true });
92
+ exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
93
+ var configuration_1 = require("./configuration");
94
+ var common_1 = require("./common");
95
+ // Some imports not used depending on template conditions
96
+ // @ts-ignore
97
+ var axios_1 = __importDefault(require("axios"));
98
+ exports.BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
99
+ /**
100
+ *
101
+ * @export
102
+ */
103
+ exports.COLLECTION_FORMATS = {
104
+ csv: ",",
105
+ ssv: " ",
106
+ tsv: "\t",
107
+ pipes: "|",
108
+ };
109
+ var Environment;
110
+ (function (Environment) {
111
+ Environment["Production"] = "https://apiv2.emil.de";
112
+ Environment["Test"] = "https://apiv2-test.emil.de";
113
+ Environment["Staging"] = "https://apiv2-staging.emil.de";
114
+ Environment["Development"] = "https://apiv2-dev.emil.de";
115
+ Environment["ProductionZurich"] = "https://eu-central-2.apiv2.emil.de";
116
+ Environment["StagingZurich"] = "https://eu-central-2.apiv2-staging.emil.de";
117
+ })(Environment = exports.Environment || (exports.Environment = {}));
118
+ var _retry_count = 0;
119
+ var _retry = null;
120
+ function resetRetry() {
121
+ _retry_count = 0;
122
+ }
123
+ exports.resetRetry = resetRetry;
124
+ var NETWORK_ERROR_MESSAGE = "Network Error";
125
+ var TOKEN_DATA = 'APP_TOKEN';
126
+ // Sent only to authservice, to ask for a server session.
127
+ var AUTH_MODE_HEADER = 'X-Emil-Auth-Mode';
128
+ // Names the account on every call; one browser session can hold several.
129
+ var ACCOUNT_HEADER = 'X-Emil-Account';
130
+ var SESSION_MODES = ['both', 'session'];
131
+ var RESEND_SAFE_METHODS = ['get', 'head', 'options'];
132
+ /**
133
+ *
134
+ * @export
135
+ * @class BaseAPI
136
+ */
137
+ var BaseAPI = /** @class */ (function () {
138
+ function BaseAPI(configuration, basePath, axios) {
139
+ if (basePath === void 0) { basePath = exports.BASE_PATH; }
140
+ if (axios === void 0) { axios = axios_1.default; }
141
+ this.basePath = basePath;
142
+ this.axios = axios;
143
+ this.loadTokenData();
144
+ if (configuration) {
145
+ var accessToken = this.tokenData.accessToken;
146
+ this.configuration = configuration;
147
+ this.basePath = configuration.basePath || this.basePath;
148
+ if (configuration.cookieAuth) {
149
+ this.configuration.username = this.configuration.username || this.tokenData.username;
150
+ }
151
+ if (this.usesSession()) {
152
+ this.useSessionAuth();
153
+ }
154
+ else {
155
+ // Use config token if provided, otherwise use tokenData token
156
+ var configToken = this.configuration.accessToken;
157
+ var storedToken = accessToken ? "Bearer ".concat(accessToken) : '';
158
+ this.configuration.accessToken = configToken || storedToken;
159
+ }
160
+ }
161
+ else {
162
+ var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
163
+ this.configuration = new configuration_1.Configuration({
164
+ basePath: this.basePath,
165
+ accessToken: accessToken ? "Bearer ".concat(accessToken) : '',
166
+ username: username,
167
+ });
168
+ }
169
+ this.attachInterceptor(axios);
170
+ }
171
+ // The app's own account wins over APP_TOKEN, which holds whichever tab wrote last.
172
+ BaseAPI.prototype.sessionAccount = function () {
173
+ return this.configuration.account || this.tokenData.sub;
174
+ };
175
+ // Apps may pass the address as the second argument only; authservice is on the same host.
176
+ BaseAPI.prototype.authBasePath = function () {
177
+ return this.configuration.basePath || this.basePath;
178
+ };
179
+ BaseAPI.prototype.usesSession = function () {
180
+ return !!this.configuration.cookieAuth && SESSION_MODES.indexOf(this.tokenData.authMode) !== -1 && !!this.sessionAccount();
181
+ };
182
+ BaseAPI.prototype.useSessionAuth = function () {
183
+ var _a;
184
+ var _b = this.configuration.baseOptions || {}, headers = _b.headers, baseOptions = __rest(_b, ["headers"]);
185
+ this.configuration.accessToken = '';
186
+ this.configuration.baseOptions = __assign(__assign({}, baseOptions), { withCredentials: true, headers: __assign(__assign({}, headers), (_a = {}, _a[ACCOUNT_HEADER] = this.sessionAccount(), _a)) });
187
+ };
188
+ BaseAPI.prototype.useHeaderAuth = function (accessToken) {
189
+ this.configuration.accessToken = accessToken ? "Bearer ".concat(accessToken) : '';
190
+ this.tokenData.accessToken = accessToken;
191
+ delete this.tokenData.authMode;
192
+ delete this.tokenData.sub;
193
+ if (this.configuration.cookieAuth) {
194
+ var _a = this.configuration.baseOptions || {}, withCredentials = _a.withCredentials, headers = _a.headers, baseOptions = __rest(_a, ["withCredentials", "headers"]);
195
+ var _b = headers || {}, _c = ACCOUNT_HEADER, account = _b[_c], otherHeaders = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
196
+ this.configuration.baseOptions = __assign(__assign({}, baseOptions), { headers: otherHeaders });
197
+ }
198
+ };
199
+ BaseAPI.prototype.applyTokenReply = function (_a) {
200
+ var accessToken = _a.accessToken, authMode = _a.authMode, session = _a.session;
201
+ if (this.configuration.cookieAuth && SESSION_MODES.indexOf(authMode) !== -1 && (session === null || session === void 0 ? void 0 : session.sub)) {
202
+ this.tokenData.authMode = authMode;
203
+ this.tokenData.sub = session.sub;
204
+ if (this.configuration.account) {
205
+ // A workspace switch moves the app to another account.
206
+ this.configuration.account = session.sub;
207
+ }
208
+ // Both keeps the token for apps not moved yet; session mode keeps no token at all.
209
+ if (authMode === 'both' && accessToken) {
210
+ this.tokenData.accessToken = accessToken;
211
+ }
212
+ else {
213
+ delete this.tokenData.accessToken;
214
+ }
215
+ this.useSessionAuth();
216
+ }
217
+ else {
218
+ this.useHeaderAuth(accessToken);
219
+ }
220
+ };
221
+ BaseAPI.prototype.sessionHeaders = function () {
222
+ var _a, _b;
223
+ if (!this.configuration.cookieAuth) {
224
+ return {};
225
+ }
226
+ return __assign((_a = {}, _a[AUTH_MODE_HEADER] = 'session', _a), (this.usesSession() && (_b = {}, _b[ACCOUNT_HEADER] = this.sessionAccount(), _b)));
227
+ };
228
+ BaseAPI.prototype.withCurrentAuth = function (config) {
229
+ delete config.headers['Authorization'];
230
+ delete config.headers[ACCOUNT_HEADER];
231
+ if (this.usesSession()) {
232
+ config.headers[ACCOUNT_HEADER] = this.sessionAccount();
233
+ config.withCredentials = true;
234
+ }
235
+ else if (this.configuration.accessToken) {
236
+ config.headers['Authorization'] = this.configuration.accessToken;
237
+ }
238
+ return config;
239
+ };
240
+ // Both keeps the token, so a session call the browser could not complete can be sent again with it.
241
+ BaseAPI.prototype.canRetryWithToken = function (config) {
242
+ var _a;
243
+ return !!config.withCredentials && !!((_a = config.headers) === null || _a === void 0 ? void 0 : _a[ACCOUNT_HEADER])
244
+ && !!this.tokenData.accessToken && this.tokenData.authMode !== 'session';
245
+ };
246
+ // A network error can come after the server ran the call, so only a call that is safe to repeat is sent again.
247
+ BaseAPI.prototype.canResend = function (config) {
248
+ return RESEND_SAFE_METHODS.indexOf((config.method || 'get').toLowerCase()) !== -1
249
+ || Object.keys(config.headers || {}).some(function (name) { return name.toLowerCase() === 'idempotency-key'; });
250
+ };
251
+ BaseAPI.prototype.switchToToken = function () {
252
+ this.useHeaderAuth(this.tokenData.accessToken);
253
+ this.storeTokenData(this.tokenData);
254
+ };
255
+ BaseAPI.prototype.retryWithToken = function (axios, config) {
256
+ this.switchToToken();
257
+ config.withCredentials = false;
258
+ return axios(this.withCurrentAuth(config));
259
+ };
260
+ BaseAPI.prototype.selectEnvironment = function (env) {
261
+ this.selectBasePath(env);
262
+ };
263
+ BaseAPI.prototype.selectBasePath = function (path) {
264
+ this.configuration.basePath = path;
265
+ };
266
+ BaseAPI.prototype.getPermissions = function () {
267
+ var _a;
268
+ if (!((_a = this.tokenData) === null || _a === void 0 ? void 0 : _a.permissions)) {
269
+ return [];
270
+ }
271
+ return this.tokenData.permissions.split(',');
272
+ };
273
+ BaseAPI.prototype.authorize = function (username, password, targetWorkspace) {
274
+ return __awaiter(this, void 0, void 0, function () {
275
+ var options, response;
276
+ var _a;
277
+ return __generator(this, function (_b) {
278
+ switch (_b.label) {
279
+ case 0:
280
+ options = {
281
+ method: 'POST',
282
+ url: "".concat(this.authBasePath(), "/authservice/v1/login"),
283
+ headers: __assign({ 'Content-Type': 'application/json' }, (this.configuration.cookieAuth && (_a = {}, _a[AUTH_MODE_HEADER] = 'session', _a))),
284
+ data: {
285
+ username: username,
286
+ password: password,
287
+ },
288
+ withCredentials: true,
289
+ };
290
+ return [4 /*yield*/, axios_1.default.request(options)];
291
+ case 1:
292
+ response = _b.sent();
293
+ this.configuration.username = username;
294
+ this.tokenData.username = username;
295
+ this.tokenData.permissions = response.data.permissions;
296
+ this.applyTokenReply(response.data);
297
+ if (!targetWorkspace) return [3 /*break*/, 3];
298
+ return [4 /*yield*/, this.switchWorkspace(targetWorkspace)];
299
+ case 2:
300
+ _b.sent();
301
+ return [3 /*break*/, 4];
302
+ case 3:
303
+ // Only store if no workspace switch (since switchWorkspace will store after switching)
304
+ this.storeTokenData(__assign({}, this.tokenData));
305
+ _b.label = 4;
306
+ case 4:
307
+ this.storeTokenData(__assign({}, this.tokenData));
308
+ return [2 /*return*/];
309
+ }
310
+ });
311
+ });
312
+ };
313
+ BaseAPI.prototype.switchWorkspace = function (targetWorkspace) {
314
+ return __awaiter(this, void 0, void 0, function () {
315
+ var options, response;
316
+ return __generator(this, function (_a) {
317
+ switch (_a.label) {
318
+ case 0:
319
+ options = {
320
+ method: 'POST',
321
+ url: "".concat(this.authBasePath(), "/authservice/v1/workspaces/switch"),
322
+ headers: __assign(__assign({ 'Content-Type': 'application/json' }, this.sessionHeaders()), (!this.usesSession() && !!this.configuration.accessToken && { 'Authorization': this.configuration.accessToken })),
323
+ data: {
324
+ username: this.configuration.username,
325
+ targetWorkspace: targetWorkspace,
326
+ },
327
+ withCredentials: true,
328
+ };
329
+ return [4 /*yield*/, axios_1.default.request(options)];
330
+ case 1:
331
+ response = _a.sent();
332
+ this.tokenData.permissions = response.data.permissions;
333
+ this.applyTokenReply(response.data);
334
+ this.storeTokenData(__assign({}, this.tokenData));
335
+ return [2 /*return*/];
336
+ }
337
+ });
338
+ });
339
+ };
340
+ BaseAPI.prototype.refreshTokenInternal = function () {
341
+ return __awaiter(this, void 0, void 0, function () {
342
+ var username, refreshTokenAxios, options, response;
343
+ var _this = this;
344
+ return __generator(this, function (_a) {
345
+ switch (_a.label) {
346
+ case 0:
347
+ username = this.configuration.username;
348
+ if (!username) {
349
+ throw new Error('Failed to refresh token.');
350
+ }
351
+ refreshTokenAxios = axios_1.default.create();
352
+ refreshTokenAxios.interceptors.response.use(function (response) {
353
+ var permissions = response.data.permissions;
354
+ _this.tokenData.permissions = permissions;
355
+ _this.storeTokenData(_this.tokenData);
356
+ return response;
357
+ });
358
+ options = {
359
+ method: 'POST',
360
+ url: "".concat(this.authBasePath(), "/authservice/v1/refresh-token"),
361
+ headers: __assign({ 'Content-Type': 'application/json' }, this.sessionHeaders()),
362
+ data: { username: username },
363
+ withCredentials: true,
364
+ };
365
+ return [4 /*yield*/, refreshTokenAxios.request(options)];
366
+ case 1:
367
+ response = _a.sent();
368
+ return [2 /*return*/, response.data];
369
+ }
370
+ });
371
+ });
372
+ };
373
+ BaseAPI.prototype.storeTokenData = function (tokenData) {
374
+ if (typeof window !== 'undefined') {
375
+ (0, common_1.defaultStorage)().set(TOKEN_DATA, tokenData);
376
+ }
377
+ };
378
+ BaseAPI.prototype.loadTokenData = function () {
379
+ if (typeof window !== 'undefined') {
380
+ this.tokenData = (0, common_1.defaultStorage)().get(TOKEN_DATA) || {};
381
+ }
382
+ else {
383
+ this.tokenData = {};
384
+ }
385
+ };
386
+ BaseAPI.prototype.cleanTokenData = function () {
387
+ this.storeTokenData(null);
388
+ };
389
+ BaseAPI.prototype.attachInterceptor = function (axios) {
390
+ var _this = this;
391
+ axios.interceptors.response.use(function (res) {
392
+ return res;
393
+ }, function (err) { return __awaiter(_this, void 0, void 0, function () {
394
+ var originalConfig, reply, _error_1, reply, _error_2;
395
+ var _this = this;
396
+ return __generator(this, function (_a) {
397
+ switch (_a.label) {
398
+ case 0:
399
+ originalConfig = err.config;
400
+ if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
401
+ if (!((err.response.status === 401 || err.response.status === 403)
402
+ && !originalConfig._retry)) return [3 /*break*/, 4];
403
+ originalConfig._retry = true;
404
+ _a.label = 1;
405
+ case 1:
406
+ _a.trys.push([1, 3, , 4]);
407
+ return [4 /*yield*/, this.refreshTokenInternal()];
408
+ case 2:
409
+ reply = _a.sent();
410
+ this.tokenData.permissions = reply.permissions;
411
+ this.applyTokenReply(reply);
412
+ this.storeTokenData(this.tokenData);
413
+ if (!this.usesSession()) {
414
+ return [2 /*return*/, axios(this.withCurrentAuth(originalConfig))];
415
+ }
416
+ // Both mode: if the browser does not send the session cookie (another site), use the token.
417
+ return [2 /*return*/, axios(this.withCurrentAuth(originalConfig)).catch(function (retryError) {
418
+ var _a;
419
+ if (((_a = retryError === null || retryError === void 0 ? void 0 : retryError.response) === null || _a === void 0 ? void 0 : _a.status) !== 401 || !_this.tokenData.accessToken) {
420
+ return Promise.reject(retryError);
421
+ }
422
+ return _this.retryWithToken(axios, originalConfig);
423
+ })];
424
+ case 3:
425
+ _error_1 = _a.sent();
426
+ if (_error_1.response && _error_1.response.data) {
427
+ return [2 /*return*/, Promise.reject(_error_1.response.data)];
428
+ }
429
+ return [2 /*return*/, Promise.reject(_error_1)];
430
+ case 4: return [3 /*break*/, 10];
431
+ case 5:
432
+ if (!(err.message === NETWORK_ERROR_MESSAGE && this.canRetryWithToken(originalConfig))) return [3 /*break*/, 6];
433
+ // Both mode: the browser blocked the session call or hid its reply; later calls use the token.
434
+ if (!this.canResend(originalConfig)) {
435
+ this.switchToToken();
436
+ return [2 /*return*/, Promise.reject(err)];
437
+ }
438
+ return [2 /*return*/, this.retryWithToken(axios, originalConfig)];
439
+ case 6:
440
+ if (!(err.message === NETWORK_ERROR_MESSAGE
441
+ && (originalConfig.headers.hasOwnProperty('Authorization')
442
+ || (this.configuration.cookieAuth && originalConfig.withCredentials && this.canResend(originalConfig)))
443
+ && _retry_count < 4)) return [3 /*break*/, 10];
444
+ _retry_count++;
445
+ _a.label = 7;
446
+ case 7:
447
+ _a.trys.push([7, 9, , 10]);
448
+ return [4 /*yield*/, this.refreshTokenInternal()];
449
+ case 8:
450
+ reply = _a.sent();
451
+ this.tokenData.permissions = reply.permissions;
452
+ _retry = true;
453
+ this.applyTokenReply(reply);
454
+ this.storeTokenData(this.tokenData);
455
+ return [2 /*return*/, axios.request(__assign({}, this.withCurrentAuth(originalConfig)))];
456
+ case 9:
457
+ _error_2 = _a.sent();
458
+ if (_error_2.response && _error_2.response.data) {
459
+ return [2 /*return*/, Promise.reject(_error_2.response.data)];
460
+ }
461
+ return [2 /*return*/, Promise.reject(_error_2)];
462
+ case 10: return [2 /*return*/, Promise.reject(err)];
463
+ }
464
+ });
465
+ }); });
466
+ };
467
+ return BaseAPI;
468
+ }());
469
+ exports.BaseAPI = BaseAPI;
470
+ ;
471
+ /**
472
+ *
473
+ * @export
474
+ * @class RequiredError
475
+ * @extends {Error}
476
+ */
477
+ var RequiredError = /** @class */ (function (_super) {
478
+ __extends(RequiredError, _super);
479
+ function RequiredError(field, msg) {
480
+ var _this = _super.call(this, msg) || this;
481
+ _this.field = field;
482
+ _this.name = "RequiredError";
483
+ return _this;
484
+ }
485
+ return RequiredError;
486
+ }(Error));
487
+ exports.RequiredError = RequiredError;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * EMIL Financemanager
3
+ * The EMIL Financemanager API description.
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ * Contact: kontakt@emil.de
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ import { Configuration } from "./configuration";
13
+ import { RequestArgs } from "./base";
14
+ import { AxiosInstance, AxiosResponse } from 'axios';
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const DUMMY_BASE_URL = "https://example.com";
20
+ /**
21
+ *
22
+ * @throws {RequiredError}
23
+ * @export
24
+ */
25
+ export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
26
+ /**
27
+ *
28
+ * @export
29
+ */
30
+ export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
31
+ /**
32
+ *
33
+ * @export
34
+ */
35
+ export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
36
+ /**
37
+ *
38
+ * @export
39
+ */
40
+ export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
41
+ /**
42
+ *
43
+ * @export
44
+ */
45
+ export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
46
+ /**
47
+ *
48
+ * @export
49
+ */
50
+ export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
51
+ /**
52
+ *
53
+ * @export
54
+ */
55
+ export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
56
+ /**
57
+ *
58
+ * @export
59
+ */
60
+ export declare const toPathString: (url: URL) => string;
61
+ /**
62
+ *
63
+ * @export
64
+ */
65
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T, any, {}, any>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
66
+ /**
67
+ * EMIL Financemanager
68
+ * The EMIL Financemanager API description.
69
+ *
70
+ * The version of the OpenAPI document: 1.0
71
+ * Contact: kontakt@emil.de
72
+ *
73
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
74
+ * https://openapi-generator.tech
75
+ * Do not edit the class manually.
76
+ */
77
+ export interface IStorageConverter<D, SD> {
78
+ toStorageData(data: D): SD;
79
+ fromStorageData(storageData: SD): D;
80
+ }
81
+ export interface IStorage {
82
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
83
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
84
+ }
85
+ export declare class LocalStorage implements IStorage {
86
+ readonly storage: Storage;
87
+ constructor();
88
+ get<T>(key: string, converter?: IStorageConverter<T, any>): T | null;
89
+ set<T>(key: string, value: T, converter?: IStorageConverter<T, any>): void;
90
+ }
91
+ export declare const defaultStorage: () => IStorage;