mts-booking-library 1.1.10 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,7 +58,7 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
58
58
  console.log("GetRequestData", url);
59
59
  }
60
60
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
61
- var response, error_1, resError;
61
+ var response_1, filteredResponse_1, error_1, resError, resError;
62
62
  var _a, _b, _c;
63
63
  return __generator(this, function (_d) {
64
64
  switch (_d.label) {
@@ -68,18 +68,24 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
68
68
  headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY }, ((0, config_1.getConfig)().ACCESS_TOKEN && { "Authorization": "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })),
69
69
  })];
70
70
  case 1:
71
- response = _d.sent();
71
+ response_1 = _d.sent();
72
+ filteredResponse_1 = {};
73
+ Object.keys(response_1.data).filter(function (key) { return key !== "error"; })
74
+ .map(function (key) {
75
+ var _a;
76
+ return filteredResponse_1 = __assign(__assign({}, filteredResponse_1), (_a = {}, _a[key] = response_1.data[key], _a));
77
+ });
72
78
  if (debug) {
73
- console.log("GetResponseData", url, response.data);
79
+ console.log("GetResponseData", url, filteredResponse_1);
74
80
  }
75
- resolve(response.data);
81
+ resolve(filteredResponse_1);
76
82
  return [3 /*break*/, 3];
77
83
  case 2:
78
84
  error_1 = _d.sent();
79
85
  if (axios_1.default.isAxiosError(error_1)) {
80
86
  resError = {
81
- httpStatus: ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.status) || 500,
82
- mtsCode: ((_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.code) || 500,
87
+ httpStatus: ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
88
+ mtsCode: ((_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.code) || 0,
83
89
  message: ((_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data.error.message) || "Unknown error",
84
90
  };
85
91
  if (debug) {
@@ -88,8 +94,8 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
88
94
  reject(resError);
89
95
  }
90
96
  else {
91
- // Not a axios error, return the error as is
92
- reject(error_1);
97
+ resError = __assign(__assign({}, error_1), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
98
+ reject(resError);
93
99
  }
94
100
  return [3 /*break*/, 3];
95
101
  case 3: return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.1.10",
3
+ "version": "1.2.0",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "license": "ISC",
16
16
  "devDependencies": {
17
- "@types/jest": "^29.5.5",
17
+ "@types/jest": "^29.5.7",
18
18
  "jest": "^29.7.0",
19
19
  "ts-jest": "^29.1.1",
20
20
  "typescript": "^5.2.2"
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "author": "M",
30
30
  "dependencies": {
31
- "axios": "^1.5.1",
31
+ "axios": "^1.6.0",
32
32
  "node-localstorage": "^3.0.5"
33
33
  }
34
34
  }