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.
@@ -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 (_h) {
87
- switch (_h.label) {
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
- _h.trys.push([0, 2, , 3]);
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 = _h.sent();
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 = _h.sent();
103
+ error_1 = _j.sent();
104
104
  if (axios_1.default.isAxiosError(error_1)) {
105
- message = "error" in ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data)
106
- ? (_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.message
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: ((_d = error_1.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
110
- mtsCode: ((_g = (_f = (_e = error_1.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
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 (_h) {
149
- switch (_h.label) {
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
- _h.trys.push([0, 2, , 3]);
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 = _h.sent();
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 = _h.sent();
165
+ error_2 = _j.sent();
166
166
  if (axios_1.default.isAxiosError(error_2)) {
167
- message = "error" in ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.data)
168
- ? (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data.error.message
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: ((_d = error_2.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
172
- mtsCode: ((_g = (_f = (_e = error_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
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 (_h) {
211
- switch (_h.label) {
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
- _h.trys.push([0, 2, , 3]);
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 = _h.sent();
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 = _h.sent();
227
+ error_3 = _j.sent();
228
228
  if (axios_1.default.isAxiosError(error_3)) {
229
- message = "error" in ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.data)
230
- ? (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data.error.message
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: ((_d = error_3.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
234
- mtsCode: ((_g = (_f = (_e = error_3.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
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 (_h) {
273
- switch (_h.label) {
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
- _h.trys.push([0, 2, , 3]);
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 = _h.sent();
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 = _h.sent();
289
+ error_4 = _j.sent();
290
290
  if (axios_1.default.isAxiosError(error_4)) {
291
- message = "error" in ((_a = error_4.response) === null || _a === void 0 ? void 0 : _a.data)
292
- ? (_b = error_4.response) === null || _b === void 0 ? void 0 : _b.data.error.message
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: ((_d = error_4.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
296
- mtsCode: ((_g = (_f = (_e = error_4.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",