@emilgroup/discount-sdk-node 1.12.1-beta.19 → 1.12.1-beta.20
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.
- package/.openapi-generator/FILES +1 -0
- package/README.md +2 -2
- package/api/campaigns-api.ts +88 -33
- package/api/health-api.ts +1 -1
- package/api/policy-vouchers-api.ts +257 -24
- package/api/vouchers-api.ts +40 -15
- package/base.ts +74 -6
- package/common.ts +3 -2
- package/dist/api/campaigns-api.d.ts +11 -11
- package/dist/api/campaigns-api.js +153 -85
- package/dist/api/health-api.d.ts +1 -1
- package/dist/api/health-api.js +1 -1
- package/dist/api/policy-vouchers-api.d.ts +118 -8
- package/dist/api/policy-vouchers-api.js +245 -62
- package/dist/api/vouchers-api.d.ts +5 -5
- package/dist/api/vouchers-api.js +67 -38
- package/dist/base.d.ts +8 -0
- package/dist/base.js +62 -4
- package/dist/common.d.ts +1 -1
- package/dist/common.js +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +1 -0
- package/dist/models/list-policy-voucher-transactions-response-class.d.ts +43 -0
- package/dist/models/list-policy-voucher-transactions-response-class.js +15 -0
- package/models/index.ts +1 -0
- package/models/list-policy-voucher-transactions-response-class.ts +49 -0
- package/package.json +2 -2
package/dist/api/vouchers-api.js
CHANGED
|
@@ -107,9 +107,10 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
107
107
|
createVoucher: function (createVoucherRequestDto, authorization, options) {
|
|
108
108
|
if (options === void 0) { options = {}; }
|
|
109
109
|
return __awaiter(_this, void 0, void 0, function () {
|
|
110
|
-
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
|
|
111
|
+
var _a;
|
|
112
|
+
return __generator(this, function (_b) {
|
|
113
|
+
switch (_b.label) {
|
|
113
114
|
case 0:
|
|
114
115
|
// verify required parameter 'createVoucherRequestDto' is not null or undefined
|
|
115
116
|
(0, common_1.assertParamExists)('createVoucher', 'createVoucherRequestDto', createVoucherRequestDto);
|
|
@@ -124,13 +125,19 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
124
125
|
localVarQueryParameter = {};
|
|
125
126
|
// authentication bearer required
|
|
126
127
|
// http bearer authentication required
|
|
127
|
-
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
|
|
128
|
+
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
|
|
129
|
+
// Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
|
|
130
|
+
// no token is stored, so a refused call still refreshes; a session call (account header) sends none.
|
|
131
|
+
];
|
|
128
132
|
case 1:
|
|
129
133
|
// authentication bearer required
|
|
130
134
|
// http bearer authentication required
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
_b.sent();
|
|
136
|
+
authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
|
|
137
|
+
authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
|
|
138
|
+
authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
|
|
139
|
+
if (authorizationValue || authorizationKeepEmpty) {
|
|
140
|
+
localVarHeaderParameter['Authorization'] = String(authorizationValue);
|
|
134
141
|
}
|
|
135
142
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
136
143
|
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
@@ -156,9 +163,10 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
156
163
|
deleteVoucher: function (code, authorization, options) {
|
|
157
164
|
if (options === void 0) { options = {}; }
|
|
158
165
|
return __awaiter(_this, void 0, void 0, function () {
|
|
159
|
-
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
|
|
160
|
-
|
|
161
|
-
|
|
166
|
+
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
|
|
167
|
+
var _a;
|
|
168
|
+
return __generator(this, function (_b) {
|
|
169
|
+
switch (_b.label) {
|
|
162
170
|
case 0:
|
|
163
171
|
// verify required parameter 'code' is not null or undefined
|
|
164
172
|
(0, common_1.assertParamExists)('deleteVoucher', 'code', code);
|
|
@@ -174,13 +182,19 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
174
182
|
localVarQueryParameter = {};
|
|
175
183
|
// authentication bearer required
|
|
176
184
|
// http bearer authentication required
|
|
177
|
-
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
|
|
185
|
+
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
|
|
186
|
+
// Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
|
|
187
|
+
// no token is stored, so a refused call still refreshes; a session call (account header) sends none.
|
|
188
|
+
];
|
|
178
189
|
case 1:
|
|
179
190
|
// authentication bearer required
|
|
180
191
|
// http bearer authentication required
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
192
|
+
_b.sent();
|
|
193
|
+
authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
|
|
194
|
+
authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
|
|
195
|
+
authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
|
|
196
|
+
if (authorizationValue || authorizationKeepEmpty) {
|
|
197
|
+
localVarHeaderParameter['Authorization'] = String(authorizationValue);
|
|
184
198
|
}
|
|
185
199
|
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
186
200
|
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
@@ -205,9 +219,10 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
205
219
|
getVoucher: function (code, authorization, expand, options) {
|
|
206
220
|
if (options === void 0) { options = {}; }
|
|
207
221
|
return __awaiter(_this, void 0, void 0, function () {
|
|
208
|
-
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
|
|
209
|
-
|
|
210
|
-
|
|
222
|
+
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
|
|
223
|
+
var _a;
|
|
224
|
+
return __generator(this, function (_b) {
|
|
225
|
+
switch (_b.label) {
|
|
211
226
|
case 0:
|
|
212
227
|
// verify required parameter 'code' is not null or undefined
|
|
213
228
|
(0, common_1.assertParamExists)('getVoucher', 'code', code);
|
|
@@ -227,12 +242,15 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
227
242
|
case 1:
|
|
228
243
|
// authentication bearer required
|
|
229
244
|
// http bearer authentication required
|
|
230
|
-
|
|
245
|
+
_b.sent();
|
|
231
246
|
if (expand !== undefined) {
|
|
232
247
|
localVarQueryParameter['expand'] = expand;
|
|
233
248
|
}
|
|
234
|
-
|
|
235
|
-
|
|
249
|
+
authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
|
|
250
|
+
authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
|
|
251
|
+
authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
|
|
252
|
+
if (authorizationValue || authorizationKeepEmpty) {
|
|
253
|
+
localVarHeaderParameter['Authorization'] = String(authorizationValue);
|
|
236
254
|
}
|
|
237
255
|
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
238
256
|
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
@@ -262,9 +280,10 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
262
280
|
listVouchers: function (authorization, pageSize, pageToken, filter, search, order, expand, filters, options) {
|
|
263
281
|
if (options === void 0) { options = {}; }
|
|
264
282
|
return __awaiter(_this, void 0, void 0, function () {
|
|
265
|
-
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
|
|
266
|
-
|
|
267
|
-
|
|
283
|
+
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
|
|
284
|
+
var _a;
|
|
285
|
+
return __generator(this, function (_b) {
|
|
286
|
+
switch (_b.label) {
|
|
268
287
|
case 0:
|
|
269
288
|
localVarPath = "/discountservice/v1/vouchers";
|
|
270
289
|
localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
@@ -281,7 +300,7 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
281
300
|
case 1:
|
|
282
301
|
// authentication bearer required
|
|
283
302
|
// http bearer authentication required
|
|
284
|
-
|
|
303
|
+
_b.sent();
|
|
285
304
|
if (pageSize !== undefined) {
|
|
286
305
|
localVarQueryParameter['pageSize'] = pageSize;
|
|
287
306
|
}
|
|
@@ -303,8 +322,11 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
303
322
|
if (filters !== undefined) {
|
|
304
323
|
localVarQueryParameter['filters'] = filters;
|
|
305
324
|
}
|
|
306
|
-
|
|
307
|
-
|
|
325
|
+
authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
|
|
326
|
+
authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
|
|
327
|
+
authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
|
|
328
|
+
if (authorizationValue || authorizationKeepEmpty) {
|
|
329
|
+
localVarHeaderParameter['Authorization'] = String(authorizationValue);
|
|
308
330
|
}
|
|
309
331
|
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
310
332
|
headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
@@ -329,9 +351,10 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
329
351
|
updateVoucher: function (code, updateVoucherRequestDto, authorization, options) {
|
|
330
352
|
if (options === void 0) { options = {}; }
|
|
331
353
|
return __awaiter(_this, void 0, void 0, function () {
|
|
332
|
-
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
|
|
333
|
-
|
|
334
|
-
|
|
354
|
+
var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, authorizationIsAuth, authorizationValue, authorizationKeepEmpty, headersFromBaseOptions;
|
|
355
|
+
var _a;
|
|
356
|
+
return __generator(this, function (_b) {
|
|
357
|
+
switch (_b.label) {
|
|
335
358
|
case 0:
|
|
336
359
|
// verify required parameter 'code' is not null or undefined
|
|
337
360
|
(0, common_1.assertParamExists)('updateVoucher', 'code', code);
|
|
@@ -349,13 +372,19 @@ var VouchersApiAxiosParamCreator = function (configuration) {
|
|
|
349
372
|
localVarQueryParameter = {};
|
|
350
373
|
// authentication bearer required
|
|
351
374
|
// http bearer authentication required
|
|
352
|
-
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
|
|
375
|
+
return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)
|
|
376
|
+
// Only Authorization falls back to the configured token. Without a session it is sent as before, empty when
|
|
377
|
+
// no token is stored, so a refused call still refreshes; a session call (account header) sends none.
|
|
378
|
+
];
|
|
353
379
|
case 1:
|
|
354
380
|
// authentication bearer required
|
|
355
381
|
// http bearer authentication required
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
382
|
+
_b.sent();
|
|
383
|
+
authorizationIsAuth = 'Authorization'.toLowerCase() === 'authorization';
|
|
384
|
+
authorizationValue = authorizationIsAuth ? (authorization || baseAccessToken) : authorization;
|
|
385
|
+
authorizationKeepEmpty = authorizationIsAuth && authorizationValue === '' && !((_a = baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.headers) === null || _a === void 0 ? void 0 : _a['X-Emil-Account']);
|
|
386
|
+
if (authorizationValue || authorizationKeepEmpty) {
|
|
387
|
+
localVarHeaderParameter['Authorization'] = String(authorizationValue);
|
|
359
388
|
}
|
|
360
389
|
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
361
390
|
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
@@ -590,7 +619,7 @@ var VouchersApi = /** @class */ (function (_super) {
|
|
|
590
619
|
*/
|
|
591
620
|
VouchersApi.prototype.createVoucher = function (requestParameters, options) {
|
|
592
621
|
var _this = this;
|
|
593
|
-
return (0, exports.VouchersApiFp)(this.configuration).createVoucher(requestParameters.createVoucherRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
622
|
+
return (0, exports.VouchersApiFp)(this.configuration).createVoucher(requestParameters.createVoucherRequestDto, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
594
623
|
};
|
|
595
624
|
/**
|
|
596
625
|
* This will delete a voucher.
|
|
@@ -602,7 +631,7 @@ var VouchersApi = /** @class */ (function (_super) {
|
|
|
602
631
|
*/
|
|
603
632
|
VouchersApi.prototype.deleteVoucher = function (requestParameters, options) {
|
|
604
633
|
var _this = this;
|
|
605
|
-
return (0, exports.VouchersApiFp)(this.configuration).deleteVoucher(requestParameters.code, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
634
|
+
return (0, exports.VouchersApiFp)(this.configuration).deleteVoucher(requestParameters.code, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
606
635
|
};
|
|
607
636
|
/**
|
|
608
637
|
* This will get a voucher.
|
|
@@ -614,7 +643,7 @@ var VouchersApi = /** @class */ (function (_super) {
|
|
|
614
643
|
*/
|
|
615
644
|
VouchersApi.prototype.getVoucher = function (requestParameters, options) {
|
|
616
645
|
var _this = this;
|
|
617
|
-
return (0, exports.VouchersApiFp)(this.configuration).getVoucher(requestParameters.code, requestParameters.authorization, requestParameters.expand, options).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
646
|
+
return (0, exports.VouchersApiFp)(this.configuration).getVoucher(requestParameters.code, requestParameters.authorization, requestParameters.expand, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
618
647
|
};
|
|
619
648
|
/**
|
|
620
649
|
* Returns a list of Vouchers you have previously created. The Vouchers are returned in sorted order, with the oldest one appearing first. For more information about pagination, read the Pagination documentation.
|
|
@@ -627,7 +656,7 @@ var VouchersApi = /** @class */ (function (_super) {
|
|
|
627
656
|
VouchersApi.prototype.listVouchers = function (requestParameters, options) {
|
|
628
657
|
var _this = this;
|
|
629
658
|
if (requestParameters === void 0) { requestParameters = {}; }
|
|
630
|
-
return (0, exports.VouchersApiFp)(this.configuration).listVouchers(requestParameters.authorization, requestParameters.pageSize, requestParameters.pageToken, requestParameters.filter, requestParameters.search, requestParameters.order, requestParameters.expand, requestParameters.filters, options).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
659
|
+
return (0, exports.VouchersApiFp)(this.configuration).listVouchers(requestParameters.authorization, requestParameters.pageSize, requestParameters.pageToken, requestParameters.filter, requestParameters.search, requestParameters.order, requestParameters.expand, requestParameters.filters, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
631
660
|
};
|
|
632
661
|
/**
|
|
633
662
|
* This will update a voucher.
|
|
@@ -639,7 +668,7 @@ var VouchersApi = /** @class */ (function (_super) {
|
|
|
639
668
|
*/
|
|
640
669
|
VouchersApi.prototype.updateVoucher = function (requestParameters, options) {
|
|
641
670
|
var _this = this;
|
|
642
|
-
return (0, exports.VouchersApiFp)(this.configuration).updateVoucher(requestParameters.code, requestParameters.updateVoucherRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
671
|
+
return (0, exports.VouchersApiFp)(this.configuration).updateVoucher(requestParameters.code, requestParameters.updateVoucherRequestDto, requestParameters.authorization, this.withOwner(options)).then(function (request) { return request(_this.axios, _this.basePath); });
|
|
643
672
|
};
|
|
644
673
|
return VouchersApi;
|
|
645
674
|
}(base_1.BaseAPI));
|
package/dist/base.d.ts
CHANGED
|
@@ -63,6 +63,10 @@ export declare class BaseAPI {
|
|
|
63
63
|
protected configuration: Configuration;
|
|
64
64
|
private username?;
|
|
65
65
|
private password?;
|
|
66
|
+
private static readonly REQUEST_OWNER;
|
|
67
|
+
private ownAccount;
|
|
68
|
+
protected withOwner(options?: AxiosRequestConfig): AxiosRequestConfig;
|
|
69
|
+
private sentByOtherAccount;
|
|
66
70
|
constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
|
|
67
71
|
initialize(env?: Environment, targetWorkspace?: string): Promise<void>;
|
|
68
72
|
private loadCredentials;
|
|
@@ -74,6 +78,10 @@ export declare class BaseAPI {
|
|
|
74
78
|
refreshTokenInternal(): Promise<string>;
|
|
75
79
|
private extractRefreshToken;
|
|
76
80
|
getConfiguration(): Configuration;
|
|
81
|
+
private sharedRefresh;
|
|
82
|
+
private refreshRunning;
|
|
83
|
+
private static shareRefresh;
|
|
84
|
+
private mayRefreshAfterNetworkError;
|
|
77
85
|
private attachInterceptor;
|
|
78
86
|
}
|
|
79
87
|
/**
|
package/dist/base.js
CHANGED
|
@@ -141,6 +141,8 @@ function resetRetry() {
|
|
|
141
141
|
}
|
|
142
142
|
exports.resetRetry = resetRetry;
|
|
143
143
|
var NETWORK_ERROR_MESSAGE = "Network Error";
|
|
144
|
+
// Refreshes in flight per configuration (BaseAPI.shareRefresh): SDK objects that share a configuration share its token.
|
|
145
|
+
var refreshesInFlight = new Map();
|
|
144
146
|
/**
|
|
145
147
|
*
|
|
146
148
|
* @export
|
|
@@ -163,6 +165,22 @@ var BaseAPI = /** @class */ (function () {
|
|
|
163
165
|
}
|
|
164
166
|
this.attachInterceptor(axios);
|
|
165
167
|
}
|
|
168
|
+
BaseAPI.prototype.ownAccount = function () {
|
|
169
|
+
return (this.configuration.username || '').toLowerCase();
|
|
170
|
+
};
|
|
171
|
+
BaseAPI.prototype.withOwner = function (options) {
|
|
172
|
+
var _a;
|
|
173
|
+
// An object without a username cannot refresh itself: its requests stay unmarked, as before.
|
|
174
|
+
if (!this.ownAccount()) {
|
|
175
|
+
return __assign({}, options);
|
|
176
|
+
}
|
|
177
|
+
return __assign(__assign({}, options), (_a = {}, _a[BaseAPI.REQUEST_OWNER] = this.ownAccount(), _a));
|
|
178
|
+
};
|
|
179
|
+
// Sent for another account: only that account's SDK objects handle it. Unmarked requests as before.
|
|
180
|
+
BaseAPI.prototype.sentByOtherAccount = function (config) {
|
|
181
|
+
var owner = config === null || config === void 0 ? void 0 : config[BaseAPI.REQUEST_OWNER];
|
|
182
|
+
return owner !== undefined && owner !== this.ownAccount();
|
|
183
|
+
};
|
|
166
184
|
BaseAPI.prototype.initialize = function (env, targetWorkspace) {
|
|
167
185
|
if (env === void 0) { env = Environment.Production; }
|
|
168
186
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -331,6 +349,7 @@ var BaseAPI = /** @class */ (function () {
|
|
|
331
349
|
},
|
|
332
350
|
data: { username: username },
|
|
333
351
|
withCredentials: true,
|
|
352
|
+
_retry: true,
|
|
334
353
|
};
|
|
335
354
|
return [4 /*yield*/, axios_1.default.request(options)];
|
|
336
355
|
case 1:
|
|
@@ -350,6 +369,39 @@ var BaseAPI = /** @class */ (function () {
|
|
|
350
369
|
BaseAPI.prototype.getConfiguration = function () {
|
|
351
370
|
return this.configuration;
|
|
352
371
|
};
|
|
372
|
+
BaseAPI.prototype.sharedRefresh = function () {
|
|
373
|
+
var _this = this;
|
|
374
|
+
return BaseAPI.shareRefresh(refreshesInFlight, this.configuration, function () { return _this.refreshTokenInternal(); });
|
|
375
|
+
};
|
|
376
|
+
BaseAPI.prototype.refreshRunning = function () {
|
|
377
|
+
return refreshesInFlight.has(this.configuration);
|
|
378
|
+
};
|
|
379
|
+
// Joins the refresh already in flight for this key, or starts one: calls refused at the same time wait for
|
|
380
|
+
// one refresh instead of each starting their own (a refresh token may be single-use). The entry is removed
|
|
381
|
+
// when the refresh settles.
|
|
382
|
+
BaseAPI.shareRefresh = function (inFlight, key, start) {
|
|
383
|
+
var running = inFlight.get(key);
|
|
384
|
+
if (running) {
|
|
385
|
+
return running;
|
|
386
|
+
}
|
|
387
|
+
var refresh = start();
|
|
388
|
+
inFlight.set(key, refresh);
|
|
389
|
+
var settled = function () { inFlight.delete(key); };
|
|
390
|
+
refresh.then(settled, settled);
|
|
391
|
+
return refresh;
|
|
392
|
+
};
|
|
393
|
+
// A refused call that joins a refresh already running is not a new try: only started refreshes count toward
|
|
394
|
+
// the limit, so every call refused at the same time is retried.
|
|
395
|
+
BaseAPI.prototype.mayRefreshAfterNetworkError = function () {
|
|
396
|
+
if (this.refreshRunning()) {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
if (_retry_count >= 4) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
_retry_count++;
|
|
403
|
+
return true;
|
|
404
|
+
};
|
|
353
405
|
BaseAPI.prototype.attachInterceptor = function (axios) {
|
|
354
406
|
var _this = this;
|
|
355
407
|
axios.interceptors.response.use(function (res) {
|
|
@@ -360,13 +412,16 @@ var BaseAPI = /** @class */ (function () {
|
|
|
360
412
|
switch (_a.label) {
|
|
361
413
|
case 0:
|
|
362
414
|
originalConfig = err.config;
|
|
415
|
+
if (this.sentByOtherAccount(originalConfig)) {
|
|
416
|
+
return [2 /*return*/, Promise.reject(err)];
|
|
417
|
+
}
|
|
363
418
|
if (!err.response) return [3 /*break*/, 5];
|
|
364
419
|
if (!(err.response.status === 401 && !originalConfig._retry)) return [3 /*break*/, 4];
|
|
365
420
|
originalConfig._retry = true;
|
|
366
421
|
_a.label = 1;
|
|
367
422
|
case 1:
|
|
368
423
|
_a.trys.push([1, 3, , 4]);
|
|
369
|
-
return [4 /*yield*/, this.
|
|
424
|
+
return [4 /*yield*/, this.sharedRefresh()];
|
|
370
425
|
case 2:
|
|
371
426
|
tokenString = _a.sent();
|
|
372
427
|
accessToken = "Bearer ".concat(tokenString);
|
|
@@ -387,13 +442,13 @@ var BaseAPI = /** @class */ (function () {
|
|
|
387
442
|
case 5:
|
|
388
443
|
if (!(err.message === NETWORK_ERROR_MESSAGE
|
|
389
444
|
&& err.isAxiosError
|
|
445
|
+
&& !originalConfig._retry
|
|
390
446
|
&& originalConfig.headers.hasOwnProperty('Authorization')
|
|
391
|
-
&&
|
|
392
|
-
_retry_count++;
|
|
447
|
+
&& this.mayRefreshAfterNetworkError())) return [3 /*break*/, 9];
|
|
393
448
|
_a.label = 6;
|
|
394
449
|
case 6:
|
|
395
450
|
_a.trys.push([6, 8, , 9]);
|
|
396
|
-
return [4 /*yield*/, this.
|
|
451
|
+
return [4 /*yield*/, this.sharedRefresh()];
|
|
397
452
|
case 7:
|
|
398
453
|
tokenString = _a.sent();
|
|
399
454
|
accessToken = "Bearer ".concat(tokenString);
|
|
@@ -412,6 +467,9 @@ var BaseAPI = /** @class */ (function () {
|
|
|
412
467
|
});
|
|
413
468
|
}); });
|
|
414
469
|
};
|
|
470
|
+
// Marks each request with the account (username) of the SDK object that sent it: only SDK objects of that
|
|
471
|
+
// account refresh and resend it, never an object of another account in the same app.
|
|
472
|
+
BaseAPI.REQUEST_OWNER = '_emilSdkOwner';
|
|
415
473
|
return BaseAPI;
|
|
416
474
|
}());
|
|
417
475
|
exports.BaseAPI = BaseAPI;
|
package/dist/common.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare const toPathString: (url: URL) => string;
|
|
|
63
63
|
*
|
|
64
64
|
* @export
|
|
65
65
|
*/
|
|
66
|
-
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
|
+
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>;
|
|
67
67
|
/**
|
|
68
68
|
* EMIL DiscountService
|
|
69
69
|
* The EMIL DiscountService API description
|
package/dist/common.js
CHANGED
|
@@ -234,6 +234,7 @@ exports.toPathString = toPathString;
|
|
|
234
234
|
* @export
|
|
235
235
|
*/
|
|
236
236
|
var createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
|
|
237
|
+
// Typed by hand: since axios 1.20, request() returns an internal axios type that SDK declarations cannot name.
|
|
237
238
|
return function (axios, basePath) {
|
|
238
239
|
if (axios === void 0) { axios = globalAxios; }
|
|
239
240
|
if (basePath === void 0) { basePath = BASE_PATH; }
|
package/dist/models/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './inline-response200';
|
|
|
20
20
|
export * from './inline-response503';
|
|
21
21
|
export * from './list-campaigns-response-class';
|
|
22
22
|
export * from './list-eligible-accounts-response-class';
|
|
23
|
+
export * from './list-policy-voucher-transactions-response-class';
|
|
23
24
|
export * from './list-policy-vouchers-response-class';
|
|
24
25
|
export * from './list-vouchers-response-class';
|
|
25
26
|
export * from './policy-voucher-class';
|
package/dist/models/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __exportStar(require("./inline-response200"), exports);
|
|
|
36
36
|
__exportStar(require("./inline-response503"), exports);
|
|
37
37
|
__exportStar(require("./list-campaigns-response-class"), exports);
|
|
38
38
|
__exportStar(require("./list-eligible-accounts-response-class"), exports);
|
|
39
|
+
__exportStar(require("./list-policy-voucher-transactions-response-class"), exports);
|
|
39
40
|
__exportStar(require("./list-policy-vouchers-response-class"), exports);
|
|
40
41
|
__exportStar(require("./list-vouchers-response-class"), exports);
|
|
41
42
|
__exportStar(require("./policy-voucher-class"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMIL DiscountService
|
|
3
|
+
* The EMIL DiscountService 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 { PolicyVoucherTransactionClass } from './policy-voucher-transaction-class';
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @export
|
|
16
|
+
* @interface ListPolicyVoucherTransactionsResponseClass
|
|
17
|
+
*/
|
|
18
|
+
export interface ListPolicyVoucherTransactionsResponseClass {
|
|
19
|
+
/**
|
|
20
|
+
* Next page token.
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
23
|
+
*/
|
|
24
|
+
'nextPageToken': string;
|
|
25
|
+
/**
|
|
26
|
+
* Total amount of items.
|
|
27
|
+
* @type {number}
|
|
28
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
29
|
+
*/
|
|
30
|
+
'totalItems': number;
|
|
31
|
+
/**
|
|
32
|
+
* Items per page.
|
|
33
|
+
* @type {number}
|
|
34
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
35
|
+
*/
|
|
36
|
+
'itemsPerPage': number;
|
|
37
|
+
/**
|
|
38
|
+
* policy voucher transactions
|
|
39
|
+
* @type {Array<PolicyVoucherTransactionClass>}
|
|
40
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
41
|
+
*/
|
|
42
|
+
'items': Array<PolicyVoucherTransactionClass>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/**
|
|
5
|
+
* EMIL DiscountService
|
|
6
|
+
* The EMIL DiscountService 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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/models/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export * from './inline-response200';
|
|
|
20
20
|
export * from './inline-response503';
|
|
21
21
|
export * from './list-campaigns-response-class';
|
|
22
22
|
export * from './list-eligible-accounts-response-class';
|
|
23
|
+
export * from './list-policy-voucher-transactions-response-class';
|
|
23
24
|
export * from './list-policy-vouchers-response-class';
|
|
24
25
|
export * from './list-vouchers-response-class';
|
|
25
26
|
export * from './policy-voucher-class';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL DiscountService
|
|
5
|
+
* The EMIL DiscountService 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 { PolicyVoucherTransactionClass } from './policy-voucher-transaction-class';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @export
|
|
21
|
+
* @interface ListPolicyVoucherTransactionsResponseClass
|
|
22
|
+
*/
|
|
23
|
+
export interface ListPolicyVoucherTransactionsResponseClass {
|
|
24
|
+
/**
|
|
25
|
+
* Next page token.
|
|
26
|
+
* @type {string}
|
|
27
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
28
|
+
*/
|
|
29
|
+
'nextPageToken': string;
|
|
30
|
+
/**
|
|
31
|
+
* Total amount of items.
|
|
32
|
+
* @type {number}
|
|
33
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
34
|
+
*/
|
|
35
|
+
'totalItems': number;
|
|
36
|
+
/**
|
|
37
|
+
* Items per page.
|
|
38
|
+
* @type {number}
|
|
39
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
40
|
+
*/
|
|
41
|
+
'itemsPerPage': number;
|
|
42
|
+
/**
|
|
43
|
+
* policy voucher transactions
|
|
44
|
+
* @type {Array<PolicyVoucherTransactionClass>}
|
|
45
|
+
* @memberof ListPolicyVoucherTransactionsResponseClass
|
|
46
|
+
*/
|
|
47
|
+
'items': Array<PolicyVoucherTransactionClass>;
|
|
48
|
+
}
|
|
49
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emilgroup/discount-sdk-node",
|
|
3
|
-
"version": "1.12.1-beta.
|
|
3
|
+
"version": "1.12.1-beta.20",
|
|
4
4
|
"description": "OpenAPI client for @emilgroup/discount-sdk-node",
|
|
5
5
|
"author": "OpenAPI-Generator Contributors",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"prepare": "npm run build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"axios": "1.
|
|
21
|
+
"axios": "1.21.1",
|
|
22
22
|
"form-data": "^4.0.0",
|
|
23
23
|
"url": "^0.11.0"
|
|
24
24
|
},
|