mts-booking-library 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/utils/apiCall.js +44 -44
- package/package.json +1 -1
package/lib/utils/apiCall.js
CHANGED
@@ -82,17 +82,17 @@ var makeGet = function (url, options) { return __awaiter(void 0, void 0, void 0,
|
|
82
82
|
}
|
83
83
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
84
84
|
var response, filteredResponse, error_1, message, resError, resError;
|
85
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
86
|
-
return __generator(this, function (
|
87
|
-
switch (
|
85
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
86
|
+
return __generator(this, function (_j) {
|
87
|
+
switch (_j.label) {
|
88
88
|
case 0:
|
89
|
-
|
89
|
+
_j.trys.push([0, 2, , 3]);
|
90
90
|
return [4 /*yield*/, axios_1.default.get(url, {
|
91
91
|
headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID })),
|
92
92
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
93
93
|
})];
|
94
94
|
case 1:
|
95
|
-
response =
|
95
|
+
response = _j.sent();
|
96
96
|
filteredResponse = removeNullError(response.data);
|
97
97
|
if (debug) {
|
98
98
|
console.log("GET_ResponseData", url, filteredResponse);
|
@@ -100,14 +100,14 @@ var makeGet = function (url, options) { return __awaiter(void 0, void 0, void 0,
|
|
100
100
|
resolve(filteredResponse);
|
101
101
|
return [3 /*break*/, 3];
|
102
102
|
case 2:
|
103
|
-
error_1 =
|
103
|
+
error_1 = _j.sent();
|
104
104
|
if (axios_1.default.isAxiosError(error_1)) {
|
105
|
-
message =
|
106
|
-
?
|
107
|
-
: (_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
105
|
+
message = ((_b = (_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
106
|
+
? error_1.response.data.error.message
|
107
|
+
: (_d = (_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
108
108
|
resError = {
|
109
|
-
httpStatus: ((
|
110
|
-
mtsCode: ((
|
109
|
+
httpStatus: ((_e = error_1.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
110
|
+
mtsCode: ((_h = (_g = (_f = error_1.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
111
111
|
message: message || "Unknown error"
|
112
112
|
};
|
113
113
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
@@ -144,17 +144,17 @@ var makePost = function (url, data, options) { return __awaiter(void 0, void 0,
|
|
144
144
|
}
|
145
145
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
146
146
|
var response, filteredResponse, error_2, message, resError, resError;
|
147
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
148
|
-
return __generator(this, function (
|
149
|
-
switch (
|
147
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
148
|
+
return __generator(this, function (_j) {
|
149
|
+
switch (_j.label) {
|
150
150
|
case 0:
|
151
|
-
|
151
|
+
_j.trys.push([0, 2, , 3]);
|
152
152
|
return [4 /*yield*/, axios_1.default.post(url, data, {
|
153
153
|
headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID })),
|
154
154
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
155
155
|
})];
|
156
156
|
case 1:
|
157
|
-
response =
|
157
|
+
response = _j.sent();
|
158
158
|
filteredResponse = removeNullError(response.data);
|
159
159
|
if (debug) {
|
160
160
|
console.log("POST_ResponseData", url, filteredResponse);
|
@@ -162,14 +162,14 @@ var makePost = function (url, data, options) { return __awaiter(void 0, void 0,
|
|
162
162
|
resolve(filteredResponse);
|
163
163
|
return [3 /*break*/, 3];
|
164
164
|
case 2:
|
165
|
-
error_2 =
|
165
|
+
error_2 = _j.sent();
|
166
166
|
if (axios_1.default.isAxiosError(error_2)) {
|
167
|
-
message =
|
168
|
-
?
|
169
|
-
: (_c = error_2.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
167
|
+
message = ((_b = (_a = error_2.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
168
|
+
? error_2.response.data.error.message
|
169
|
+
: (_d = (_c = error_2.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
170
170
|
resError = {
|
171
|
-
httpStatus: ((
|
172
|
-
mtsCode: ((
|
171
|
+
httpStatus: ((_e = error_2.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
172
|
+
mtsCode: ((_h = (_g = (_f = error_2.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
173
173
|
message: message || "Unknown error"
|
174
174
|
};
|
175
175
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
@@ -206,17 +206,17 @@ var makePut = function (url, data, options) { return __awaiter(void 0, void 0, v
|
|
206
206
|
}
|
207
207
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
208
208
|
var response, filteredResponse, error_3, message, resError, resError;
|
209
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
210
|
-
return __generator(this, function (
|
211
|
-
switch (
|
209
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
210
|
+
return __generator(this, function (_j) {
|
211
|
+
switch (_j.label) {
|
212
212
|
case 0:
|
213
|
-
|
213
|
+
_j.trys.push([0, 2, , 3]);
|
214
214
|
return [4 /*yield*/, axios_1.default.put(url, data, {
|
215
215
|
headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID })),
|
216
216
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
217
217
|
})];
|
218
218
|
case 1:
|
219
|
-
response =
|
219
|
+
response = _j.sent();
|
220
220
|
filteredResponse = removeNullError(response.data);
|
221
221
|
if (debug) {
|
222
222
|
console.log("PUT_ResponseData", url, filteredResponse);
|
@@ -224,14 +224,14 @@ var makePut = function (url, data, options) { return __awaiter(void 0, void 0, v
|
|
224
224
|
resolve(filteredResponse);
|
225
225
|
return [3 /*break*/, 3];
|
226
226
|
case 2:
|
227
|
-
error_3 =
|
227
|
+
error_3 = _j.sent();
|
228
228
|
if (axios_1.default.isAxiosError(error_3)) {
|
229
|
-
message =
|
230
|
-
?
|
231
|
-
: (_c = error_3.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
229
|
+
message = ((_b = (_a = error_3.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
230
|
+
? error_3.response.data.error.message
|
231
|
+
: (_d = (_c = error_3.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
232
232
|
resError = {
|
233
|
-
httpStatus: ((
|
234
|
-
mtsCode: ((
|
233
|
+
httpStatus: ((_e = error_3.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
234
|
+
mtsCode: ((_h = (_g = (_f = error_3.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
235
235
|
message: message || "Unknown error"
|
236
236
|
};
|
237
237
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
@@ -268,17 +268,17 @@ var makeDelete = function (url, options) { return __awaiter(void 0, void 0, void
|
|
268
268
|
}
|
269
269
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
270
270
|
var response, filteredResponse, error_4, message, resError, resError;
|
271
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
272
|
-
return __generator(this, function (
|
273
|
-
switch (
|
271
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
272
|
+
return __generator(this, function (_j) {
|
273
|
+
switch (_j.label) {
|
274
274
|
case 0:
|
275
|
-
|
275
|
+
_j.trys.push([0, 2, , 3]);
|
276
276
|
return [4 /*yield*/, axios_1.default.delete(url, {
|
277
277
|
headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID })),
|
278
278
|
signal: options === null || options === void 0 ? void 0 : options.signal
|
279
279
|
})];
|
280
280
|
case 1:
|
281
|
-
response =
|
281
|
+
response = _j.sent();
|
282
282
|
filteredResponse = removeNullError(response.data);
|
283
283
|
if (debug) {
|
284
284
|
console.log("DELETE_ResponseData", url, filteredResponse);
|
@@ -286,14 +286,14 @@ var makeDelete = function (url, options) { return __awaiter(void 0, void 0, void
|
|
286
286
|
resolve(filteredResponse);
|
287
287
|
return [3 /*break*/, 3];
|
288
288
|
case 2:
|
289
|
-
error_4 =
|
289
|
+
error_4 = _j.sent();
|
290
290
|
if (axios_1.default.isAxiosError(error_4)) {
|
291
|
-
message =
|
292
|
-
?
|
293
|
-
: (_c = error_4.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
291
|
+
message = ((_b = (_a = error_4.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
292
|
+
? error_4.response.data.error.message
|
293
|
+
: (_d = (_c = error_4.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
294
294
|
resError = {
|
295
|
-
httpStatus: ((
|
296
|
-
mtsCode: ((
|
295
|
+
httpStatus: ((_e = error_4.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
296
|
+
mtsCode: ((_h = (_g = (_f = error_4.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
297
297
|
message: message || "Unknown error"
|
298
298
|
};
|
299
299
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|