mts-booking-library 1.2.34 → 1.2.36
Sign up to get free protection for your applications and to get access to all the features.
package/lib/booking/booking.d.ts
CHANGED
@@ -51,7 +51,6 @@ export declare abstract class Booking {
|
|
51
51
|
getBookingStepsToStatus(): Map<string, boolean[]>;
|
52
52
|
changeCurrency(currency: Booking.Currencies): void;
|
53
53
|
changeLanguage(language: string): void;
|
54
|
-
getCartExpirationTimeInMs(): Promise<number>;
|
55
54
|
/**
|
56
55
|
* This API allows to mark a non-required booking step as completed. It is useful for example for the seats selection step.
|
57
56
|
* @param bookingStep The booking step to mark as completed
|
package/lib/booking/booking.js
CHANGED
@@ -138,19 +138,6 @@ var Booking = /** @class */ (function () {
|
|
138
138
|
this.language = Booking.Languages.EN;
|
139
139
|
}
|
140
140
|
};
|
141
|
-
Booking.prototype.getCartExpirationTimeInMs = function () {
|
142
|
-
return __awaiter(this, void 0, void 0, function () {
|
143
|
-
return __generator(this, function (_a) {
|
144
|
-
// If cart is initialized, return the time in ms until the cart expires.
|
145
|
-
// Note that bookingDueDate is initialized only when the cart is created.
|
146
|
-
if (this.bookingDueDate) {
|
147
|
-
return [2 /*return*/, (new Date(this.bookingDueDate).valueOf() - new Date().valueOf())];
|
148
|
-
}
|
149
|
-
// Cart is not initialized
|
150
|
-
throw Error("Cart is not initialized yet");
|
151
|
-
});
|
152
|
-
});
|
153
|
-
};
|
154
141
|
/**
|
155
142
|
* This API allows to mark a non-required booking step as completed. It is useful for example for the seats selection step.
|
156
143
|
* @param bookingStep The booking step to mark as completed
|
@@ -2,7 +2,7 @@ import { MTSEnvs } from "../config";
|
|
2
2
|
import { ErrorResponse } from "../types/ErrorResponse";
|
3
3
|
import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
5
|
-
import { Service,
|
5
|
+
import { Service, ServiceTripsResponse } from "../types/services/Service";
|
6
6
|
import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
|
7
7
|
import { Booking } from "./booking";
|
8
8
|
export declare class ServiceBooking extends Booking {
|
@@ -48,9 +48,9 @@ export declare class ServiceBooking extends Booking {
|
|
48
48
|
* You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
|
49
49
|
* @param {number} serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
|
50
50
|
* @param {string} date The date on which to get the tours, in ISO string format
|
51
|
-
* @returns {
|
51
|
+
* @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
|
52
52
|
*/
|
53
|
-
getServiceTrips(serviceId: number, date: string): Promise<ErrorResponse |
|
53
|
+
getServiceTrips(serviceId: number, date: string): Promise<ErrorResponse | ServiceTripsResponse>;
|
54
54
|
createServiceCart(serviceCart: CreateServiceCartRequest): Promise<ErrorResponse | ServiceCart>;
|
55
55
|
/**
|
56
56
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
@@ -233,7 +233,7 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
233
233
|
* You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
|
234
234
|
* @param {number} serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
|
235
235
|
* @param {string} date The date on which to get the tours, in ISO string format
|
236
|
-
* @returns {
|
236
|
+
* @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
|
237
237
|
*/
|
238
238
|
ServiceBooking.prototype.getServiceTrips = function (serviceId, date) {
|
239
239
|
return __awaiter(this, void 0, void 0, function () {
|
@@ -242,7 +242,7 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
242
242
|
searchParams = new URLSearchParams({ date: date });
|
243
243
|
url = "".concat(this.config.API_ENDPOINT, "/booking/services/").concat(serviceId, "/trips?").concat(searchParams);
|
244
244
|
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
245
|
-
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response
|
245
|
+
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
|
246
246
|
})];
|
247
247
|
});
|
248
248
|
});
|
@@ -31,3 +31,13 @@ export type ServiceTrip = {
|
|
31
31
|
date: Date;
|
32
32
|
name: string;
|
33
33
|
};
|
34
|
+
/**
|
35
|
+
* @description Represents a response from the service trips endpoint
|
36
|
+
* @param {boolean} areThereTrips - Indicates whether there are trips available for the service.
|
37
|
+
* @param {ServiceTrip[]} trips - An array of {@link ServiceTrip} objects representing the available trips. This can be empty
|
38
|
+
* even if `areThereTrips` is true, as the user might be not allowed to select a specific trip.
|
39
|
+
*/
|
40
|
+
export type ServiceTripsResponse = {
|
41
|
+
areThereTrips: boolean;
|
42
|
+
trips: ServiceTrip[];
|
43
|
+
};
|
@@ -9,7 +9,7 @@ import { ServiceTrip } from "./Service";
|
|
9
9
|
* @property {Object} service - Information about the selected service.
|
10
10
|
* @property {number} service.serviceId - The unique identifier for the service.
|
11
11
|
* @property {TariffsMatrix} service.tariffsMatrix - The tariff matrix for pricing the service.
|
12
|
-
* @property {
|
12
|
+
* @property {string|undefined} [service.date] - The date for the service in ISO string format (optional).
|
13
13
|
* @property {number|undefined} [service.tripId] - The unique identifier for the trip (optional).
|
14
14
|
*/
|
15
15
|
export type CreateServiceCartRequest = {
|
@@ -17,7 +17,7 @@ export type CreateServiceCartRequest = {
|
|
17
17
|
service: {
|
18
18
|
serviceId: number;
|
19
19
|
tariffsMatrix: TariffsMatrix;
|
20
|
-
date?:
|
20
|
+
date?: string;
|
21
21
|
tripId?: number;
|
22
22
|
};
|
23
23
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.36",
|
4
4
|
"description": "Library for use MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -29,6 +29,7 @@
|
|
29
29
|
"author": "M",
|
30
30
|
"dependencies": {
|
31
31
|
"axios": "^1.6.7",
|
32
|
+
"dotenv": "^16.4.5",
|
32
33
|
"node-localstorage": "^3.0.5"
|
33
34
|
}
|
34
35
|
}
|