@emilgroup/billing-sdk 1.0.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 (97) hide show
  1. package/.openapi-generator/FILES +37 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -0
  5. package/api/correction-invoices-api.ts +161 -0
  6. package/api/estimated-invoices-api.ts +264 -0
  7. package/api/initial-invoices-api.ts +161 -0
  8. package/api/invoices-api.ts +398 -0
  9. package/api/recurring-invoices-api.ts +161 -0
  10. package/api.ts +40 -0
  11. package/base.ts +247 -0
  12. package/common.ts +198 -0
  13. package/configuration.ts +101 -0
  14. package/dist/api/correction-invoices-api.d.ts +93 -0
  15. package/dist/api/correction-invoices-api.js +220 -0
  16. package/dist/api/estimated-invoices-api.d.ts +146 -0
  17. package/dist/api/estimated-invoices-api.js +309 -0
  18. package/dist/api/initial-invoices-api.d.ts +93 -0
  19. package/dist/api/initial-invoices-api.js +220 -0
  20. package/dist/api/invoices-api.d.ts +234 -0
  21. package/dist/api/invoices-api.js +369 -0
  22. package/dist/api/recurring-invoices-api.d.ts +93 -0
  23. package/dist/api/recurring-invoices-api.js +220 -0
  24. package/dist/api.d.ts +20 -0
  25. package/dist/api.js +40 -0
  26. package/dist/base.d.ts +72 -0
  27. package/dist/base.js +293 -0
  28. package/dist/common.d.ts +91 -0
  29. package/dist/common.js +276 -0
  30. package/dist/configuration.d.ts +83 -0
  31. package/dist/configuration.js +44 -0
  32. package/dist/index.d.ts +15 -0
  33. package/dist/index.js +35 -0
  34. package/dist/models/create-correction-invoices-response-class.d.ts +25 -0
  35. package/dist/models/create-correction-invoices-response-class.js +15 -0
  36. package/dist/models/create-custom-estimated-invoice-request-dto.d.ts +35 -0
  37. package/dist/models/create-custom-estimated-invoice-request-dto.js +20 -0
  38. package/dist/models/create-custom-estimated-invoice-response-class.d.ts +24 -0
  39. package/dist/models/create-custom-estimated-invoice-response-class.js +15 -0
  40. package/dist/models/create-estimated-invoice-request-dto.d.ts +31 -0
  41. package/dist/models/create-estimated-invoice-request-dto.js +15 -0
  42. package/dist/models/create-estimated-invoice-response-class.d.ts +31 -0
  43. package/dist/models/create-estimated-invoice-response-class.js +15 -0
  44. package/dist/models/create-invoice-request-dto.d.ts +75 -0
  45. package/dist/models/create-invoice-request-dto.js +24 -0
  46. package/dist/models/create-invoice-response-class.d.ts +25 -0
  47. package/dist/models/create-invoice-response-class.js +15 -0
  48. package/dist/models/index.d.ts +19 -0
  49. package/dist/models/index.js +35 -0
  50. package/dist/models/invoice-class.d.ts +121 -0
  51. package/dist/models/invoice-class.js +15 -0
  52. package/dist/models/invoice-item-class.d.ts +108 -0
  53. package/dist/models/invoice-item-class.js +15 -0
  54. package/dist/models/list-invoices-response-class.d.ts +31 -0
  55. package/dist/models/list-invoices-response-class.js +15 -0
  56. package/dist/models/list-policies-billing-dates-response-class.d.ts +30 -0
  57. package/dist/models/list-policies-billing-dates-response-class.js +15 -0
  58. package/dist/models/list-request-dto.d.ts +54 -0
  59. package/dist/models/list-request-dto.js +15 -0
  60. package/dist/models/policy-dto.d.ts +85 -0
  61. package/dist/models/policy-dto.js +15 -0
  62. package/dist/models/policy-object-dto.d.ts +42 -0
  63. package/dist/models/policy-object-dto.js +15 -0
  64. package/dist/models/policy-premium-dto.d.ts +43 -0
  65. package/dist/models/policy-premium-dto.js +15 -0
  66. package/dist/models/policy-premium-item-dto.d.ts +49 -0
  67. package/dist/models/policy-premium-item-dto.js +15 -0
  68. package/dist/models/policy-version-dto.d.ts +55 -0
  69. package/dist/models/policy-version-dto.js +15 -0
  70. package/dist/models/premium-formula-dto.d.ts +72 -0
  71. package/dist/models/premium-formula-dto.js +15 -0
  72. package/dist/models/timeslice-dto.d.ts +62 -0
  73. package/dist/models/timeslice-dto.js +15 -0
  74. package/git_push.sh +57 -0
  75. package/index.ts +19 -0
  76. package/models/create-correction-invoices-response-class.ts +31 -0
  77. package/models/create-custom-estimated-invoice-request-dto.ts +44 -0
  78. package/models/create-custom-estimated-invoice-response-class.ts +30 -0
  79. package/models/create-estimated-invoice-request-dto.ts +37 -0
  80. package/models/create-estimated-invoice-response-class.ts +37 -0
  81. package/models/create-invoice-request-dto.ts +84 -0
  82. package/models/create-invoice-response-class.ts +31 -0
  83. package/models/index.ts +19 -0
  84. package/models/invoice-class.ts +127 -0
  85. package/models/invoice-item-class.ts +114 -0
  86. package/models/list-invoices-response-class.ts +37 -0
  87. package/models/list-policies-billing-dates-response-class.ts +36 -0
  88. package/models/list-request-dto.ts +60 -0
  89. package/models/policy-dto.ts +91 -0
  90. package/models/policy-object-dto.ts +48 -0
  91. package/models/policy-premium-dto.ts +49 -0
  92. package/models/policy-premium-item-dto.ts +55 -0
  93. package/models/policy-version-dto.ts +61 -0
  94. package/models/premium-formula-dto.ts +78 -0
  95. package/models/timeslice-dto.ts +68 -0
  96. package/package.json +27 -0
  97. package/tsconfig.json +22 -0
package/dist/base.js ADDED
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL BillingService
6
+ * The EMIL BillingService API description
7
+ *
8
+ * The version of the OpenAPI document: 1.0
9
+ *
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 (_) 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 __importDefault = (this && this.__importDefault) || function (mod) {
78
+ return (mod && mod.__esModule) ? mod : { "default": mod };
79
+ };
80
+ Object.defineProperty(exports, "__esModule", { value: true });
81
+ exports.RequiredError = exports.BaseAPI = exports.resetRetry = exports.Environment = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
82
+ var configuration_1 = require("./configuration");
83
+ var common_1 = require("./common");
84
+ // Some imports not used depending on template conditions
85
+ // @ts-ignore
86
+ var axios_1 = __importDefault(require("axios"));
87
+ exports.BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
88
+ /**
89
+ *
90
+ * @export
91
+ */
92
+ exports.COLLECTION_FORMATS = {
93
+ csv: ",",
94
+ ssv: " ",
95
+ tsv: "\t",
96
+ pipes: "|",
97
+ };
98
+ var Environment;
99
+ (function (Environment) {
100
+ Environment["Production"] = "https://apiv2.emil.de";
101
+ Environment["Test"] = "https://apiv2-test.emil.de";
102
+ })(Environment = exports.Environment || (exports.Environment = {}));
103
+ var _retry_count = 0;
104
+ var _retry = null;
105
+ function resetRetry() {
106
+ _retry_count = 0;
107
+ }
108
+ exports.resetRetry = resetRetry;
109
+ var NETWORK_ERROR_MESSAGE = "Network Error";
110
+ var TOKEN_DATA = 'APP_TOKEN';
111
+ /**
112
+ *
113
+ * @export
114
+ * @class BaseAPI
115
+ */
116
+ var BaseAPI = /** @class */ (function () {
117
+ function BaseAPI(configuration, basePath, axios) {
118
+ if (basePath === void 0) { basePath = exports.BASE_PATH; }
119
+ if (axios === void 0) { axios = axios_1.default; }
120
+ this.basePath = basePath;
121
+ this.axios = axios;
122
+ this.loadTokenData();
123
+ if (configuration) {
124
+ this.configuration = configuration;
125
+ this.basePath = configuration.basePath || this.basePath;
126
+ }
127
+ else {
128
+ var _a = this.tokenData, accessToken = _a.accessToken, username = _a.username;
129
+ this.configuration = new configuration_1.Configuration({
130
+ basePath: this.basePath,
131
+ accessToken: accessToken ? "Bearer ".concat(accessToken) : '',
132
+ username: username,
133
+ });
134
+ }
135
+ this.attachInterceptor(axios);
136
+ }
137
+ BaseAPI.prototype.selectEnvironment = function (env) {
138
+ this.configuration.basePath = env;
139
+ };
140
+ BaseAPI.prototype.authorize = function (username, password) {
141
+ return __awaiter(this, void 0, void 0, function () {
142
+ var options, response, accessToken;
143
+ return __generator(this, function (_a) {
144
+ switch (_a.label) {
145
+ case 0:
146
+ options = {
147
+ method: 'POST',
148
+ url: "".concat(this.configuration.basePath, "/authservice/v1/login"),
149
+ headers: { 'Content-Type': 'application/json' },
150
+ data: {
151
+ username: username,
152
+ password: password,
153
+ },
154
+ withCredentials: true,
155
+ };
156
+ return [4 /*yield*/, axios_1.default.request(options)];
157
+ case 1:
158
+ response = _a.sent();
159
+ accessToken = response.data.accessToken;
160
+ this.configuration.username = username;
161
+ this.configuration.accessToken = "Bearer ".concat(accessToken);
162
+ this.tokenData.username = username;
163
+ this.tokenData.accessToken = accessToken;
164
+ this.storeTokenData(__assign({}, this.tokenData));
165
+ return [2 /*return*/];
166
+ }
167
+ });
168
+ });
169
+ };
170
+ BaseAPI.prototype.refreshToken = function () {
171
+ return __awaiter(this, void 0, void 0, function () {
172
+ var username, options, accessToken;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0:
176
+ username = this.configuration.username;
177
+ if (!username) {
178
+ return [2 /*return*/, ''];
179
+ }
180
+ options = {
181
+ method: 'POST',
182
+ url: "".concat(this.configuration.basePath, "/authservice/v1/refresh-token"),
183
+ headers: {
184
+ 'Content-Type': 'application/json',
185
+ },
186
+ data: { username: username },
187
+ withCredentials: true,
188
+ };
189
+ return [4 /*yield*/, axios_1.default.request(options)];
190
+ case 1:
191
+ accessToken = (_a.sent()).data.accessToken;
192
+ return [2 /*return*/, accessToken];
193
+ }
194
+ });
195
+ });
196
+ };
197
+ BaseAPI.prototype.storeTokenData = function (tokenData) {
198
+ if (typeof window !== 'undefined') {
199
+ (0, common_1.defaultStorage)().set(TOKEN_DATA, tokenData);
200
+ }
201
+ };
202
+ BaseAPI.prototype.loadTokenData = function () {
203
+ if (typeof window !== 'undefined') {
204
+ this.tokenData = (0, common_1.defaultStorage)().get(TOKEN_DATA) || {};
205
+ }
206
+ };
207
+ BaseAPI.prototype.cleanTokenData = function () {
208
+ this.storeTokenData(null);
209
+ };
210
+ BaseAPI.prototype.attachInterceptor = function (axios) {
211
+ var _this = this;
212
+ axios.interceptors.response.use(function (res) {
213
+ return res;
214
+ }, function (err) { return __awaiter(_this, void 0, void 0, function () {
215
+ var originalConfig, tokenString, accessToken, _error_1, tokenString, accessToken, _error_2;
216
+ return __generator(this, function (_a) {
217
+ switch (_a.label) {
218
+ case 0:
219
+ originalConfig = err.config;
220
+ if (!(err.response && !(err.response instanceof XMLHttpRequest))) return [3 /*break*/, 5];
221
+ if (!((err.response.status === 401 || err.response.status === 403)
222
+ && !originalConfig._retry)) return [3 /*break*/, 4];
223
+ originalConfig._retry = true;
224
+ _a.label = 1;
225
+ case 1:
226
+ _a.trys.push([1, 3, , 4]);
227
+ return [4 /*yield*/, this.refreshToken()];
228
+ case 2:
229
+ tokenString = _a.sent();
230
+ accessToken = "Bearer ".concat(tokenString);
231
+ delete originalConfig.headers['Authorization'];
232
+ originalConfig.headers['Authorization'] = accessToken;
233
+ this.configuration.accessToken = accessToken;
234
+ this.tokenData.accessToken = tokenString;
235
+ this.storeTokenData(this.tokenData);
236
+ return [2 /*return*/, axios(originalConfig)];
237
+ case 3:
238
+ _error_1 = _a.sent();
239
+ if (_error_1.response && _error_1.response.data) {
240
+ return [2 /*return*/, Promise.reject(_error_1.response.data)];
241
+ }
242
+ return [2 /*return*/, Promise.reject(_error_1)];
243
+ case 4: return [3 /*break*/, 9];
244
+ case 5:
245
+ if (!(err.message === NETWORK_ERROR_MESSAGE
246
+ && originalConfig.headers.hasOwnProperty('Authorization')
247
+ && _retry_count < 4)) return [3 /*break*/, 9];
248
+ _retry_count++;
249
+ _a.label = 6;
250
+ case 6:
251
+ _a.trys.push([6, 8, , 9]);
252
+ return [4 /*yield*/, this.refreshToken()];
253
+ case 7:
254
+ tokenString = _a.sent();
255
+ accessToken = "Bearer ".concat(tokenString);
256
+ _retry = true;
257
+ originalConfig.headers['Authorization'] = accessToken;
258
+ this.configuration.accessToken = accessToken;
259
+ this.tokenData.accessToken = tokenString;
260
+ this.storeTokenData(this.tokenData);
261
+ return [2 /*return*/, axios.request(__assign({}, originalConfig))];
262
+ case 8:
263
+ _error_2 = _a.sent();
264
+ if (_error_2.response && _error_2.response.data) {
265
+ return [2 /*return*/, Promise.reject(_error_2.response.data)];
266
+ }
267
+ return [2 /*return*/, Promise.reject(_error_2)];
268
+ case 9: return [2 /*return*/, Promise.reject(err)];
269
+ }
270
+ });
271
+ }); });
272
+ };
273
+ return BaseAPI;
274
+ }());
275
+ exports.BaseAPI = BaseAPI;
276
+ ;
277
+ /**
278
+ *
279
+ * @export
280
+ * @class RequiredError
281
+ * @extends {Error}
282
+ */
283
+ var RequiredError = /** @class */ (function (_super) {
284
+ __extends(RequiredError, _super);
285
+ function RequiredError(field, msg) {
286
+ var _this = _super.call(this, msg) || this;
287
+ _this.field = field;
288
+ _this.name = "RequiredError";
289
+ return _this;
290
+ }
291
+ return RequiredError;
292
+ }(Error));
293
+ exports.RequiredError = RequiredError;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * EMIL BillingService
3
+ * The EMIL BillingService API description
4
+ *
5
+ * The version of the OpenAPI document: 1.0
6
+ *
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>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
66
+ /**
67
+ * EMIL BillingService
68
+ * The EMIL BillingService API description
69
+ *
70
+ * The version of the OpenAPI document: 1.0
71
+ *
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;
package/dist/common.js ADDED
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL BillingService
6
+ * The EMIL BillingService API description
7
+ *
8
+ * The version of the OpenAPI document: 1.0
9
+ *
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 __assign = (this && this.__assign) || function () {
16
+ __assign = Object.assign || function(t) {
17
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
18
+ s = arguments[i];
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
+ t[p] = s[p];
21
+ }
22
+ return t;
23
+ };
24
+ return __assign.apply(this, arguments);
25
+ };
26
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
+ return new (P || (P = Promise))(function (resolve, reject) {
29
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
33
+ });
34
+ };
35
+ var __generator = (this && this.__generator) || function (thisArg, body) {
36
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
+ function verb(n) { return function (v) { return step([n, v]); }; }
39
+ function step(op) {
40
+ if (f) throw new TypeError("Generator is already executing.");
41
+ while (_) try {
42
+ 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;
43
+ if (y = 0, t) op = [op[0] & 2, t.value];
44
+ switch (op[0]) {
45
+ case 0: case 1: t = op; break;
46
+ case 4: _.label++; return { value: op[1], done: false };
47
+ case 5: _.label++; y = op[1]; op = [0]; continue;
48
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
+ default:
50
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
+ if (t[2]) _.ops.pop();
55
+ _.trys.pop(); continue;
56
+ }
57
+ op = body.call(thisArg, _);
58
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
+ }
61
+ };
62
+ Object.defineProperty(exports, "__esModule", { value: true });
63
+ exports.defaultStorage = exports.LocalStorage = exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setOAuthToObject = exports.setBearerAuthToObject = exports.setBasicAuthToObject = exports.setApiKeyToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
64
+ var base_1 = require("./base");
65
+ /**
66
+ *
67
+ * @export
68
+ */
69
+ exports.DUMMY_BASE_URL = 'https://example.com';
70
+ /**
71
+ *
72
+ * @throws {RequiredError}
73
+ * @export
74
+ */
75
+ var assertParamExists = function (functionName, paramName, paramValue) {
76
+ if (paramValue === null || paramValue === undefined) {
77
+ throw new base_1.RequiredError(paramName, "Required parameter ".concat(paramName, " was null or undefined when calling ").concat(functionName, "."));
78
+ }
79
+ };
80
+ exports.assertParamExists = assertParamExists;
81
+ /**
82
+ *
83
+ * @export
84
+ */
85
+ var setApiKeyToObject = function (object, keyParamName, configuration) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var localVarApiKeyValue, _a;
88
+ return __generator(this, function (_b) {
89
+ switch (_b.label) {
90
+ case 0:
91
+ if (!(configuration && configuration.apiKey)) return [3 /*break*/, 5];
92
+ if (!(typeof configuration.apiKey === 'function')) return [3 /*break*/, 2];
93
+ return [4 /*yield*/, configuration.apiKey(keyParamName)];
94
+ case 1:
95
+ _a = _b.sent();
96
+ return [3 /*break*/, 4];
97
+ case 2: return [4 /*yield*/, configuration.apiKey];
98
+ case 3:
99
+ _a = _b.sent();
100
+ _b.label = 4;
101
+ case 4:
102
+ localVarApiKeyValue = _a;
103
+ object[keyParamName] = localVarApiKeyValue;
104
+ _b.label = 5;
105
+ case 5: return [2 /*return*/];
106
+ }
107
+ });
108
+ });
109
+ };
110
+ exports.setApiKeyToObject = setApiKeyToObject;
111
+ /**
112
+ *
113
+ * @export
114
+ */
115
+ var setBasicAuthToObject = function (object, configuration) {
116
+ if (configuration && (configuration.username || configuration.password)) {
117
+ object["auth"] = { username: configuration.username, password: configuration.password };
118
+ }
119
+ };
120
+ exports.setBasicAuthToObject = setBasicAuthToObject;
121
+ /**
122
+ *
123
+ * @export
124
+ */
125
+ var setBearerAuthToObject = function (object, configuration) {
126
+ return __awaiter(this, void 0, void 0, function () {
127
+ var accessToken, _a;
128
+ return __generator(this, function (_b) {
129
+ switch (_b.label) {
130
+ case 0:
131
+ if (!(configuration && configuration.accessToken)) return [3 /*break*/, 5];
132
+ if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 2];
133
+ return [4 /*yield*/, configuration.accessToken()];
134
+ case 1:
135
+ _a = _b.sent();
136
+ return [3 /*break*/, 4];
137
+ case 2: return [4 /*yield*/, configuration.accessToken];
138
+ case 3:
139
+ _a = _b.sent();
140
+ _b.label = 4;
141
+ case 4:
142
+ accessToken = _a;
143
+ object["Authorization"] = "Bearer " + accessToken;
144
+ _b.label = 5;
145
+ case 5: return [2 /*return*/];
146
+ }
147
+ });
148
+ });
149
+ };
150
+ exports.setBearerAuthToObject = setBearerAuthToObject;
151
+ /**
152
+ *
153
+ * @export
154
+ */
155
+ var setOAuthToObject = function (object, name, scopes, configuration) {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ var localVarAccessTokenValue, _a;
158
+ return __generator(this, function (_b) {
159
+ switch (_b.label) {
160
+ case 0:
161
+ if (!(configuration && configuration.accessToken)) return [3 /*break*/, 5];
162
+ if (!(typeof configuration.accessToken === 'function')) return [3 /*break*/, 2];
163
+ return [4 /*yield*/, configuration.accessToken(name, scopes)];
164
+ case 1:
165
+ _a = _b.sent();
166
+ return [3 /*break*/, 4];
167
+ case 2: return [4 /*yield*/, configuration.accessToken];
168
+ case 3:
169
+ _a = _b.sent();
170
+ _b.label = 4;
171
+ case 4:
172
+ localVarAccessTokenValue = _a;
173
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
174
+ _b.label = 5;
175
+ case 5: return [2 /*return*/];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ exports.setOAuthToObject = setOAuthToObject;
181
+ /**
182
+ *
183
+ * @export
184
+ */
185
+ var setSearchParams = function (url) {
186
+ var objects = [];
187
+ for (var _i = 1; _i < arguments.length; _i++) {
188
+ objects[_i - 1] = arguments[_i];
189
+ }
190
+ var searchParams = new URLSearchParams(url.search);
191
+ for (var _a = 0, objects_1 = objects; _a < objects_1.length; _a++) {
192
+ var object = objects_1[_a];
193
+ for (var key in object) {
194
+ if (Array.isArray(object[key])) {
195
+ searchParams.delete(key);
196
+ for (var _b = 0, _c = object[key]; _b < _c.length; _b++) {
197
+ var item = _c[_b];
198
+ searchParams.append(key, item);
199
+ }
200
+ }
201
+ else {
202
+ searchParams.set(key, object[key]);
203
+ }
204
+ }
205
+ }
206
+ url.search = searchParams.toString();
207
+ };
208
+ exports.setSearchParams = setSearchParams;
209
+ /**
210
+ *
211
+ * @export
212
+ */
213
+ var serializeDataIfNeeded = function (value, requestOptions, configuration) {
214
+ var nonString = typeof value !== 'string';
215
+ var needsSerialization = nonString && configuration && configuration.isJsonMime
216
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
217
+ : nonString;
218
+ return needsSerialization
219
+ ? JSON.stringify(value !== undefined ? value : {})
220
+ : (value || "");
221
+ };
222
+ exports.serializeDataIfNeeded = serializeDataIfNeeded;
223
+ /**
224
+ *
225
+ * @export
226
+ */
227
+ var toPathString = function (url) {
228
+ return url.pathname + url.search + url.hash;
229
+ };
230
+ exports.toPathString = toPathString;
231
+ /**
232
+ *
233
+ * @export
234
+ */
235
+ var createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
236
+ return function (axios, basePath) {
237
+ if (axios === void 0) { axios = globalAxios; }
238
+ if (basePath === void 0) { basePath = BASE_PATH; }
239
+ var axiosRequestArgs = __assign(__assign({}, axiosArgs.options), { url: ((configuration === null || configuration === void 0 ? void 0 : configuration.basePath) || basePath) + axiosArgs.url });
240
+ return axios.request(axiosRequestArgs);
241
+ };
242
+ };
243
+ exports.createRequestFunction = createRequestFunction;
244
+ var LocalStorage = /** @class */ (function () {
245
+ function LocalStorage() {
246
+ this.storage = localStorage;
247
+ }
248
+ LocalStorage.prototype.get = function (key, converter) {
249
+ var jsonValue = this.storage.getItem(key);
250
+ if (jsonValue === null) {
251
+ return null;
252
+ }
253
+ var value = JSON.parse(jsonValue);
254
+ if (converter !== undefined) {
255
+ return converter.fromStorageData(value);
256
+ }
257
+ else {
258
+ return value;
259
+ }
260
+ };
261
+ LocalStorage.prototype.set = function (key, value, converter) {
262
+ var valueToStore = value;
263
+ if (converter !== undefined) {
264
+ valueToStore = converter.toStorageData(value);
265
+ }
266
+ var jsonValue = JSON.stringify(valueToStore);
267
+ this.storage.setItem(key, jsonValue);
268
+ };
269
+ return LocalStorage;
270
+ }());
271
+ exports.LocalStorage = LocalStorage;
272
+ var _defaultStorage = null;
273
+ var defaultStorage = function () {
274
+ return _defaultStorage || (_defaultStorage = new LocalStorage());
275
+ };
276
+ exports.defaultStorage = defaultStorage;