mts-booking-library 1.0.5 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/booking/booking.d.ts +44 -0
- package/lib/booking/booking.js +105 -0
- package/lib/booking/journeyBooking.d.ts +49 -0
- package/lib/booking/journeyBooking.js +246 -0
- package/lib/booking/serviceBooking.d.ts +36 -0
- package/lib/booking/serviceBooking.js +190 -0
- package/lib/booking/subscriptionBooking.d.ts +50 -0
- package/lib/booking/subscriptionBooking.js +201 -0
- package/lib/config.d.ts +2 -1
- package/lib/config.js +5 -2
- package/lib/index.d.ts +15 -140
- package/lib/index.js +16 -415
- package/lib/types/common/Cart.d.ts +47 -0
- package/lib/types/common/Person.d.ts +31 -0
- package/lib/types/common/Person.js +11 -0
- package/lib/types/{TermsAndTariffs.d.ts → common/Tariffs.d.ts} +5 -0
- package/lib/types/journeys/JourneyCart.d.ts +55 -0
- package/lib/types/journeys/JourneyInfo.d.ts +18 -0
- package/lib/types/journeys/JourneySearch.d.ts +19 -0
- package/lib/types/{Journeys → journeys}/JourneySearch.js +7 -5
- package/lib/types/journeys/Stop.d.ts +16 -0
- package/lib/types/{Journeys → journeys}/Trip.d.ts +1 -1
- package/lib/types/services/Line.d.ts +14 -0
- package/lib/types/services/Service.d.ts +33 -0
- package/lib/types/services/ServiceCart.d.ts +46 -0
- package/lib/types/services/ServiceInfo.d.ts +14 -0
- package/lib/utils/apiCall.js +22 -2
- package/package.json +3 -3
- package/lib/types/Booking.d.ts +0 -0
- package/lib/types/Booking.js +0 -1
- package/lib/types/Cart.d.ts +0 -79
- package/lib/types/Details.d.ts +0 -9
- package/lib/types/Info.d.ts +0 -8
- package/lib/types/Journey.d.ts +0 -8
- package/lib/types/JourneySearch.d.ts +0 -9
- package/lib/types/Journeys/BusMatrix.d.ts +0 -0
- package/lib/types/Journeys/BusMatrix.js +0 -1
- package/lib/types/Journeys/Journey.d.ts +0 -8
- package/lib/types/Journeys/JourneySearch.d.ts +0 -11
- package/lib/types/Journeys/Stop.d.ts +0 -7
- package/lib/types/Line.d.ts +0 -6
- package/lib/types/Person.d.ts +0 -7
- package/lib/types/Stop.d.ts +0 -7
- package/lib/types/Stop.js +0 -2
- package/lib/types/Subscriptions/ValidityTypes.d.ts +0 -6
- package/lib/types/Subscriptions/ValidityTypes.js +0 -10
- package/lib/types/TermsAndTariffs.js +0 -2
- package/lib/types/Tour.d.ts +0 -18
- package/lib/types/Tour.js +0 -2
- package/lib/types/Tours/Tour.d.ts +0 -18
- package/lib/types/Tours/Tour.js +0 -2
- package/lib/types/Tours.d.ts +0 -0
- package/lib/types/Tours.js +0 -1
- package/lib/types/Trip.d.ts +0 -9
- package/lib/types/Trip.js +0 -2
- package/lib/types/TripSearch.d.ts +0 -9
- package/lib/types/TripSearch.js +0 -2
- /package/lib/types/{Cart.js → common/Cart.js} +0 -0
- /package/lib/types/{Details.js → common/Tariffs.js} +0 -0
- /package/lib/types/{BusMatrix.d.ts → journeys/BusMatrix.d.ts} +0 -0
- /package/lib/types/{BusMatrix.js → journeys/BusMatrix.js} +0 -0
- /package/lib/types/{Info.js → journeys/JourneyCart.js} +0 -0
- /package/lib/types/{Journey.js → journeys/JourneyInfo.js} +0 -0
- /package/lib/types/{Journeys → journeys}/Stop.js +0 -0
- /package/lib/types/{Journeys → journeys}/Trip.js +0 -0
- /package/lib/types/{Line.js → services/Line.js} +0 -0
- /package/lib/types/{JourneySearch.js → services/Service.js} +0 -0
- /package/lib/types/{Journeys/Journey.js → services/ServiceCart.js} +0 -0
- /package/lib/types/{Person.js → services/ServiceInfo.js} +0 -0
- /package/lib/types/{Subscriptions → subscriptions}/Subscrptions.d.ts +0 -0
- /package/lib/types/{Subscriptions → subscriptions}/Subscrptions.js +0 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
/**
|
2
|
+
* @description Represents a stop in a journey.
|
3
|
+
*
|
4
|
+
* @property {number} id - The unique identifier for the stop.
|
5
|
+
* @property {Date} departureTime - The time when the journey departs from this stop.
|
6
|
+
* @property {Date} destinationTime - The time when the journey arrives at this stop.
|
7
|
+
* @property {string} name - The name of the stop.
|
8
|
+
* @property {string} address - The address of the stop.
|
9
|
+
*/
|
10
|
+
export type Stop = {
|
11
|
+
id: number;
|
12
|
+
departureTime: Date;
|
13
|
+
destinationTime: Date;
|
14
|
+
name: string;
|
15
|
+
address: string;
|
16
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* @description Represents a line on which the service is sold.
|
3
|
+
*
|
4
|
+
* @property {number} id - The unique identifier for the line.
|
5
|
+
* @property {string} name - The name of the line.
|
6
|
+
* @property {string} linkavelDescription - A description of the line, to be used in {@link https://linkavel.com/} or in other ecommerses.
|
7
|
+
* @property {string} backofficeNotes - Additional notes or information about the line for internal use.
|
8
|
+
*/
|
9
|
+
export type Line = {
|
10
|
+
id: number;
|
11
|
+
name: string;
|
12
|
+
linkavelDescription: string;
|
13
|
+
backofficeNotes: string;
|
14
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { TariffMatrix, TariffType, TermsType } from "../common/Tariffs";
|
2
|
+
import { Line } from "./Line";
|
3
|
+
import { ServiceInfo } from "./ServiceInfo";
|
4
|
+
/**
|
5
|
+
* @description Represents a service offering, including information about the service, tariffs,
|
6
|
+
* terms, and other details.
|
7
|
+
*
|
8
|
+
* @property {number} id - The unique identifier for the service.
|
9
|
+
* @property {Line} line - Information about the line or route associated with the service.
|
10
|
+
* @property {ServiceInfo} info - Information about the service itself.
|
11
|
+
* @property {TariffMatrix} tariffsMatrix - The tariff matrix for pricing.
|
12
|
+
* @property {TariffType[]} tariffTypes - An array of tariff types available for the service.
|
13
|
+
* @property {TermsType[]} termsTypes - An array of terms types related to the service.
|
14
|
+
* @property {boolean} isDateOptional - Indicates whether a date can be optionally specified for this service.
|
15
|
+
* @property {boolean} isDateRequired - Indicates whether specifying a date is required for booking.
|
16
|
+
* @property {boolean} isTripMandatory - Indicates whether the selection of the trip in the selected date is mandatory.
|
17
|
+
*/
|
18
|
+
export type Service = {
|
19
|
+
id: number;
|
20
|
+
line: Line;
|
21
|
+
info: ServiceInfo;
|
22
|
+
tariffsMatrix: TariffMatrix;
|
23
|
+
tariffTypes: TariffType[];
|
24
|
+
termsTypes: TermsType[];
|
25
|
+
isDateOptional: boolean;
|
26
|
+
isDateRequired: boolean;
|
27
|
+
isTripMandatory: boolean;
|
28
|
+
};
|
29
|
+
export type ServiceTrip = {
|
30
|
+
tripId?: number;
|
31
|
+
date: Date;
|
32
|
+
name: string;
|
33
|
+
};
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { Booking } from "../../booking/booking";
|
2
|
+
import { Cart } from "../common/Cart";
|
3
|
+
import { TariffMatrix, TariffSummary } from "../common/Tariffs";
|
4
|
+
import { ServiceTrip } from "./Service";
|
5
|
+
/**
|
6
|
+
* @description This is the object to be passed to `ServiceBooking.createServiceCart`, containing information about the selected service.
|
7
|
+
*
|
8
|
+
* @property {Booking.Currencies} currency - The currency in which the service is priced.
|
9
|
+
* @property {Object} service - Information about the selected service.
|
10
|
+
* @property {number} service.serviceId - The unique identifier for the service.
|
11
|
+
* @property {TariffMatrix} service.tariffsMatrix - The tariff matrix for pricing the service.
|
12
|
+
* @property {Date|undefined} [service.date] - The date for the service (optional).
|
13
|
+
* @property {number|undefined} [service.tripId] - The unique identifier for the trip (optional).
|
14
|
+
*/
|
15
|
+
export type CreateServiceCartRequest = {
|
16
|
+
currency: Booking.Currencies;
|
17
|
+
service: {
|
18
|
+
serviceId: number;
|
19
|
+
tariffsMatrix: TariffMatrix;
|
20
|
+
date?: Date;
|
21
|
+
tripId?: number;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
/**
|
25
|
+
* @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
|
26
|
+
* information about the bookings
|
27
|
+
*
|
28
|
+
* @property {ServiceBooking[]} bookings - An array of {@link ServiceBookingType} objects representing the bookings associated
|
29
|
+
* with this journey cart.
|
30
|
+
*/
|
31
|
+
export type ServiceCart = Cart & {
|
32
|
+
bookings: ServiceBookingType[];
|
33
|
+
};
|
34
|
+
/**
|
35
|
+
* @description Represents a `JourneyBooking`, which contains information about a journey booking.
|
36
|
+
*
|
37
|
+
* @property {Booking.BookingTypes} type - The type of booking.
|
38
|
+
* @property {TariffSummary[]} summary - An array of {@link TariffSummary} objects representing the tariff summary
|
39
|
+
* associated with this journey booking.
|
40
|
+
* @property {ServiceTrip} info - An array of {@link ServiceTrip} objects representing the stops associated with this journey booking.
|
41
|
+
*/
|
42
|
+
export type ServiceBookingType = {
|
43
|
+
type: Booking.BookingTypes;
|
44
|
+
summary: TariffSummary[];
|
45
|
+
info: ServiceTrip;
|
46
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* @description Represents information about a service.
|
3
|
+
*
|
4
|
+
* @property {string} sellerName - The name of the seller offering the service.
|
5
|
+
* @property {string} minimumTotalPrice - The minimum total price for booking the service, meaning the price if all passenger choose the cheapest tariff.
|
6
|
+
* @property {string} bookingProcessMessage - Optional message to be displayed to the user when booking this service.
|
7
|
+
* @property {boolean} isBookable - Indicates whether the service is bookable (true) or not (false).
|
8
|
+
*/
|
9
|
+
export type ServiceInfo = {
|
10
|
+
sellerName: string;
|
11
|
+
minimumTotalPrice: string;
|
12
|
+
bookingProcessMessage: string;
|
13
|
+
isBookable: boolean;
|
14
|
+
};
|
package/lib/utils/apiCall.js
CHANGED
@@ -51,8 +51,12 @@ exports.makePost = exports.makeGet = void 0;
|
|
51
51
|
var axios_1 = require("axios");
|
52
52
|
var config_1 = require("../config");
|
53
53
|
var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function () {
|
54
|
+
var debug;
|
54
55
|
return __generator(this, function (_a) {
|
55
|
-
|
56
|
+
debug = (0, config_1.getConfig)().DEBUG;
|
57
|
+
if (debug) {
|
58
|
+
console.log("GetRequestData", url);
|
59
|
+
}
|
56
60
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
57
61
|
var response, error_1, resError;
|
58
62
|
return __generator(this, function (_a) {
|
@@ -64,11 +68,17 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
64
68
|
})];
|
65
69
|
case 1:
|
66
70
|
response = _a.sent();
|
71
|
+
if (debug) {
|
72
|
+
console.log("GetResponseData", url, response.data);
|
73
|
+
}
|
67
74
|
resolve(response.data);
|
68
75
|
return [3 /*break*/, 3];
|
69
76
|
case 2:
|
70
77
|
error_1 = _a.sent();
|
71
78
|
resError = error_1.response.data;
|
79
|
+
if (debug) {
|
80
|
+
console.log("GetResponseError", url, resError);
|
81
|
+
}
|
72
82
|
reject(resError);
|
73
83
|
return [3 /*break*/, 3];
|
74
84
|
case 3: return [2 /*return*/];
|
@@ -79,8 +89,12 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
79
89
|
}); };
|
80
90
|
exports.makeGet = makeGet;
|
81
91
|
var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, function () {
|
92
|
+
var debug;
|
82
93
|
return __generator(this, function (_a) {
|
83
|
-
|
94
|
+
debug = (0, config_1.getConfig)().DEBUG;
|
95
|
+
if (debug) {
|
96
|
+
console.log("PostRequestData", url, data);
|
97
|
+
}
|
84
98
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
85
99
|
var response, error_2, resError;
|
86
100
|
return __generator(this, function (_a) {
|
@@ -92,11 +106,17 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
92
106
|
})];
|
93
107
|
case 1:
|
94
108
|
response = _a.sent();
|
109
|
+
if (debug) {
|
110
|
+
console.log("PostResponseData", url, response.data);
|
111
|
+
}
|
95
112
|
resolve(response.data);
|
96
113
|
return [3 /*break*/, 3];
|
97
114
|
case 2:
|
98
115
|
error_2 = _a.sent();
|
99
116
|
resError = error_2.response.data;
|
117
|
+
if (debug) {
|
118
|
+
console.log("PostResponseError", url, resError);
|
119
|
+
}
|
100
120
|
reject(resError);
|
101
121
|
return [3 /*break*/, 3];
|
102
122
|
case 3: return [2 /*return*/];
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.1.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.5",
|
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.
|
31
|
+
"axios": "^1.5.1",
|
32
32
|
"node-localstorage": "^3.0.5"
|
33
33
|
}
|
34
34
|
}
|
package/lib/types/Booking.d.ts
DELETED
File without changes
|
package/lib/types/Booking.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
package/lib/types/Cart.d.ts
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
import { Booking } from "..";
|
2
|
-
import { Person } from "./Person";
|
3
|
-
import { TariffMatrix } from "./TermsAndTariffs";
|
4
|
-
export type Cart = {
|
5
|
-
id: number;
|
6
|
-
cartCode: string;
|
7
|
-
status: Booking.CartStatus;
|
8
|
-
nextStatus: Booking.CartStatus;
|
9
|
-
currency: string;
|
10
|
-
bookingDueDate: string;
|
11
|
-
bookings: {
|
12
|
-
type: string;
|
13
|
-
summary: {
|
14
|
-
quantity: number;
|
15
|
-
label: string;
|
16
|
-
value: number;
|
17
|
-
}[];
|
18
|
-
}[];
|
19
|
-
info: {
|
20
|
-
stops: {
|
21
|
-
id: number;
|
22
|
-
departureTime: Date;
|
23
|
-
destinationTime: Date;
|
24
|
-
name: string;
|
25
|
-
address: string;
|
26
|
-
}[];
|
27
|
-
};
|
28
|
-
buyer: Person;
|
29
|
-
reductions: {
|
30
|
-
tripId: number;
|
31
|
-
tripName: string;
|
32
|
-
value: number;
|
33
|
-
isPercentage: boolean;
|
34
|
-
voucherCode?: string;
|
35
|
-
}[];
|
36
|
-
isSeatsSelectionAllowed: boolean;
|
37
|
-
sellingMethod: string;
|
38
|
-
totalValue: number;
|
39
|
-
totalResellerFee?: number;
|
40
|
-
totalCreditFromChange: number;
|
41
|
-
totalAmountToPay: number;
|
42
|
-
extas: {
|
43
|
-
id: number;
|
44
|
-
resourceId: number;
|
45
|
-
name: string;
|
46
|
-
description: string;
|
47
|
-
notes: string;
|
48
|
-
tariff: {
|
49
|
-
tariffId: number;
|
50
|
-
tariffName: string;
|
51
|
-
};
|
52
|
-
}[];
|
53
|
-
};
|
54
|
-
export type TourCart = {
|
55
|
-
cartId?: number;
|
56
|
-
currency: Booking.Currencies;
|
57
|
-
tour: {
|
58
|
-
tourId: number;
|
59
|
-
date?: Date;
|
60
|
-
tripId?: number;
|
61
|
-
tariffsMatrix: TariffMatrix;
|
62
|
-
};
|
63
|
-
};
|
64
|
-
export type JourneyCart = {
|
65
|
-
cartId?: number;
|
66
|
-
currency: Booking.Currencies;
|
67
|
-
outboundJourney: {
|
68
|
-
departureStopId: number;
|
69
|
-
destinationStopId: number;
|
70
|
-
tripId: number;
|
71
|
-
tariffsMatrix: TariffMatrix;
|
72
|
-
}[];
|
73
|
-
returnJourney: {
|
74
|
-
tripId: number;
|
75
|
-
departureStopId: number;
|
76
|
-
destinationStopId: number;
|
77
|
-
tariffsMatrix: TariffMatrix;
|
78
|
-
}[] | null;
|
79
|
-
};
|
package/lib/types/Details.d.ts
DELETED
package/lib/types/Info.d.ts
DELETED
package/lib/types/Journey.d.ts
DELETED
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { Booking } from "../..";
|
2
|
-
export type JourneySearch = {
|
3
|
-
departureStopName: string | undefined;
|
4
|
-
destinationStopName: string | undefined;
|
5
|
-
passengersNumber: number;
|
6
|
-
date: Date;
|
7
|
-
roundTripDate: Date | null;
|
8
|
-
currency: Booking.Currencies;
|
9
|
-
isRoundtrip: boolean;
|
10
|
-
};
|
11
|
-
export declare const DefaultJourneySearch: JourneySearch;
|
package/lib/types/Line.d.ts
DELETED
package/lib/types/Person.d.ts
DELETED
package/lib/types/Stop.d.ts
DELETED
package/lib/types/Stop.js
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ValidityTypes = void 0;
|
4
|
-
var ValidityTypes;
|
5
|
-
(function (ValidityTypes) {
|
6
|
-
ValidityTypes["WORKING_WEEK"] = "WORKING_WEEK";
|
7
|
-
ValidityTypes["WEEKLY"] = "WEEKLY";
|
8
|
-
ValidityTypes["MONTHLY"] = "MONTHLY";
|
9
|
-
ValidityTypes["YEARLY"] = "YEARLY";
|
10
|
-
})(ValidityTypes || (exports.ValidityTypes = ValidityTypes = {}));
|
package/lib/types/Tour.d.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import { Info } from "./Info";
|
2
|
-
import { Line } from "./Line";
|
3
|
-
import { TariffMatrix, TariffType, TermsType } from "./TermsAndTariffs";
|
4
|
-
export type Tour = {
|
5
|
-
id: number;
|
6
|
-
line: Line;
|
7
|
-
info: Info;
|
8
|
-
tariffsMatrix: TariffMatrix;
|
9
|
-
tariffTypes: TariffType[];
|
10
|
-
termsTypes: TermsType[];
|
11
|
-
isDateOptional: boolean;
|
12
|
-
isDateRequired: boolean;
|
13
|
-
isTripMandatory: boolean;
|
14
|
-
};
|
15
|
-
export type TourTrip = {
|
16
|
-
tripId: number;
|
17
|
-
hour: Date;
|
18
|
-
};
|
package/lib/types/Tour.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import { Info } from "../Info";
|
2
|
-
import { Line } from "../Line";
|
3
|
-
import { TariffMatrix, TariffType, TermsType } from "../TermsAndTariffs";
|
4
|
-
export type Tour = {
|
5
|
-
id: number;
|
6
|
-
line: Line;
|
7
|
-
info: Info;
|
8
|
-
tariffsMatrix: TariffMatrix;
|
9
|
-
tariffTypes: TariffType[];
|
10
|
-
termsTypes: TermsType[];
|
11
|
-
isDateOptional: boolean;
|
12
|
-
isDateRequired: boolean;
|
13
|
-
isTripMandatory: boolean;
|
14
|
-
};
|
15
|
-
export type TourTrip = {
|
16
|
-
tripId: number;
|
17
|
-
hour: Date;
|
18
|
-
};
|
package/lib/types/Tours/Tour.js
DELETED
package/lib/types/Tours.d.ts
DELETED
File without changes
|
package/lib/types/Tours.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";
|
package/lib/types/Trip.d.ts
DELETED
package/lib/types/Trip.js
DELETED
package/lib/types/TripSearch.js
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|