mts-booking-library 1.1.10 → 1.2.1
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/lib/booking/booking.d.ts +61 -10
- package/lib/booking/booking.js +174 -12
- package/lib/booking/journeyBooking.d.ts +51 -18
- package/lib/booking/journeyBooking.js +200 -48
- package/lib/booking/serviceBooking.d.ts +5 -4
- package/lib/booking/serviceBooking.js +45 -12
- package/lib/booking/subscriptionBooking.d.ts +30 -7
- package/lib/booking/subscriptionBooking.js +154 -15
- package/lib/index.d.ts +6 -2
- package/lib/index.js +8 -2
- package/lib/types/ErrorResponse.d.ts +1 -0
- package/lib/types/ErrorResponse.js +5 -0
- package/lib/types/common/Cart.d.ts +14 -26
- package/lib/types/common/Extra.d.ts +20 -0
- package/lib/types/common/Extra.js +2 -0
- package/lib/types/common/Payment.d.ts +63 -0
- package/lib/types/common/Payment.js +24 -0
- package/lib/types/common/Person.d.ts +29 -7
- package/lib/types/common/Person.js +8 -1
- package/lib/types/common/Reduction.d.ts +31 -0
- package/lib/types/common/Reduction.js +2 -0
- package/lib/types/common/Tariffs.d.ts +21 -0
- package/lib/types/journeys/BusMatrix.d.ts +34 -0
- package/lib/types/journeys/BusMatrix.js +20 -0
- package/lib/types/services/ServiceCart.d.ts +1 -1
- package/lib/utils/apiCall.js +14 -8
- package/package.json +3 -3
@@ -1 +1,21 @@
|
|
1
1
|
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SeatStatus = exports.BusCellTypes = void 0;
|
4
|
+
// Possible type BusSeat
|
5
|
+
var BusCellTypes;
|
6
|
+
(function (BusCellTypes) {
|
7
|
+
BusCellTypes["SEAT"] = "SEAT";
|
8
|
+
BusCellTypes["SELECTED_SEAT"] = "SELECTED_SEAT";
|
9
|
+
BusCellTypes["DRIVER"] = "DRIVER";
|
10
|
+
BusCellTypes["WC"] = "WC";
|
11
|
+
BusCellTypes["EXIT"] = "EXIT";
|
12
|
+
BusCellTypes["TABLE"] = "TABLE";
|
13
|
+
BusCellTypes["STAIRS"] = "STAIRS";
|
14
|
+
})(BusCellTypes || (exports.BusCellTypes = BusCellTypes = {}));
|
15
|
+
// Possible status for a seat
|
16
|
+
var SeatStatus;
|
17
|
+
(function (SeatStatus) {
|
18
|
+
SeatStatus["RESERVED"] = "RESERVED";
|
19
|
+
SeatStatus["AVAILABLE"] = "AVAILABLE";
|
20
|
+
SeatStatus["OCCUPIED"] = "OCCUPIED";
|
21
|
+
})(SeatStatus || (exports.SeatStatus = SeatStatus = {}));
|
@@ -22,7 +22,7 @@ export type CreateServiceCartRequest = {
|
|
22
22
|
};
|
23
23
|
};
|
24
24
|
/**
|
25
|
-
* @description Represents a `
|
25
|
+
* @description Represents a `ServiceCart`, which extends the {@link Cart} type by including additional
|
26
26
|
* information about the bookings
|
27
27
|
*
|
28
28
|
* @property {ServiceBooking[]} bookings - An array of {@link ServiceBookingType} objects representing the bookings associated
|
package/lib/utils/apiCall.js
CHANGED
@@ -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
|
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
|
-
|
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,
|
79
|
+
console.log("GetResponseData", url, filteredResponse_1);
|
74
80
|
}
|
75
|
-
resolve(
|
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) ||
|
82
|
-
mtsCode: ((_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.code) ||
|
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
|
-
|
92
|
-
reject(
|
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
|
3
|
+
"version": "1.2.1",
|
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.
|
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.
|
31
|
+
"axios": "^1.6.0",
|
32
32
|
"node-localstorage": "^3.0.5"
|
33
33
|
}
|
34
34
|
}
|