mts-booking-library 2.4.14 → 3.0.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 +2 -1
- package/lib/booking/journeyBooking.d.ts +46 -6
- package/lib/booking/journeyBooking.js +31 -75
- package/lib/booking/serviceBooking.d.ts +48 -8
- package/lib/booking/serviceBooking.js +33 -74
- package/lib/booking/subscriptionBooking.d.ts +45 -3
- package/lib/booking/subscriptionBooking.js +31 -38
- package/lib/booking/tplBooking.d.ts +46 -6
- package/lib/booking/tplBooking.js +27 -78
- package/lib/index.d.ts +6 -5
- package/lib/index.js +6 -5
- package/lib/mtsStorage.d.ts +10 -6
- package/lib/types/common/Cart.d.ts +64 -62
- package/lib/types/common/Person.d.ts +0 -11
- package/lib/types/common/Person.js +1 -11
- package/lib/types/common/Reduction.d.ts +14 -21
- package/lib/types/common/Tariffs.d.ts +0 -2
- package/lib/types/common/dates.d.ts +8 -0
- package/lib/types/common/dates.js +320 -0
- package/lib/types/journeys/JourneyCart.d.ts +0 -18
- package/lib/types/journeys/JourneyCart.js +0 -8
- package/lib/types/journeys/JourneyInfo.d.ts +7 -8
- package/lib/types/journeys/JourneySearch.d.ts +5 -4
- package/lib/types/journeys/JourneySearch.js +10 -5
- package/lib/types/journeys/Stop.d.ts +8 -12
- package/lib/types/journeys/Trip.d.ts +70 -6
- package/lib/types/services/Service.d.ts +13 -4
- package/lib/types/services/ServiceCart.d.ts +4 -31
- package/lib/types/subscriptions/SubscriptionAvailabilities.d.ts +20 -22
- package/lib/types/subscriptions/SubscriptionCart.d.ts +3 -4
- package/lib/types/subscriptions/Subscriptions.d.ts +10 -11
- package/lib/types/tpl/TplCart.d.ts +2 -21
- package/lib/utils/utils.d.ts +0 -8
- package/lib/utils/utils.js +1 -17
- package/package.json +16 -16
package/lib/booking/booking.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { GetExtrasForBookingResponse, GetExtrasResponse } from "../types/common/
|
|
|
5
5
|
import { GetPaymentInformationFromGatewayResponse, GetSellerGatewaysResponse, PaymentMethods, IssueCartResponse } from "../types/common/Payment";
|
|
6
6
|
import { GetBuyerPassengersDetailsResponse, GetPersonRequest, Person } from "../types/common/Person";
|
|
7
7
|
import { AddReductionRequest } from "../types/common/Reduction";
|
|
8
|
+
import { DateWithTimeZone } from "../types/common/dates";
|
|
8
9
|
import { ApiCallOptions } from "../utils/apiCall";
|
|
9
10
|
export declare abstract class Booking {
|
|
10
11
|
private sellerId?;
|
|
@@ -23,7 +24,7 @@ export declare abstract class Booking {
|
|
|
23
24
|
*/
|
|
24
25
|
bookingStepsToStatus: processedStepsToStatus;
|
|
25
26
|
cartGuid: string | undefined;
|
|
26
|
-
|
|
27
|
+
bookingDueDateTime: DateWithTimeZone | undefined;
|
|
27
28
|
/**
|
|
28
29
|
* This is the constructor of the Booking class. See {@link Booking.BookingConfig} for more information.
|
|
29
30
|
*/
|
|
@@ -3,7 +3,7 @@ import { CreateUpdateCartRequest } from "../types/common/Cart";
|
|
|
3
3
|
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse } from "../types/common/Person";
|
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
|
5
5
|
import { BusMatrix } from "../types/journeys/BusMatrix";
|
|
6
|
-
import {
|
|
6
|
+
import { JourneyCart } from "../types/journeys/JourneyCart";
|
|
7
7
|
import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/JourneySearch";
|
|
8
8
|
import { ReductionTrip } from "../types/journeys/Trip";
|
|
9
9
|
import { ApiCallOptions } from "../utils/apiCall";
|
|
@@ -20,7 +20,49 @@ export declare class JourneyBooking extends Booking {
|
|
|
20
20
|
} & {
|
|
21
21
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
22
22
|
resetState: () => void;
|
|
23
|
-
}>, "persist"> & {
|
|
23
|
+
}>, "setState" | "persist"> & {
|
|
24
|
+
setState(partial: ({
|
|
25
|
+
cartGuid: string | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
28
|
+
resetState: () => void;
|
|
29
|
+
}) | Partial<{
|
|
30
|
+
cartGuid: string | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
33
|
+
resetState: () => void;
|
|
34
|
+
}> | ((state: {
|
|
35
|
+
cartGuid: string | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
38
|
+
resetState: () => void;
|
|
39
|
+
}) => ({
|
|
40
|
+
cartGuid: string | undefined;
|
|
41
|
+
} & {
|
|
42
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
43
|
+
resetState: () => void;
|
|
44
|
+
}) | Partial<{
|
|
45
|
+
cartGuid: string | undefined;
|
|
46
|
+
} & {
|
|
47
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
48
|
+
resetState: () => void;
|
|
49
|
+
}>), replace?: false | undefined): unknown;
|
|
50
|
+
setState(state: ({
|
|
51
|
+
cartGuid: string | undefined;
|
|
52
|
+
} & {
|
|
53
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
54
|
+
resetState: () => void;
|
|
55
|
+
}) | ((state: {
|
|
56
|
+
cartGuid: string | undefined;
|
|
57
|
+
} & {
|
|
58
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
59
|
+
resetState: () => void;
|
|
60
|
+
}) => {
|
|
61
|
+
cartGuid: string | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
64
|
+
resetState: () => void;
|
|
65
|
+
}), replace: true): unknown;
|
|
24
66
|
persist: {
|
|
25
67
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<{
|
|
26
68
|
cartGuid: string | undefined;
|
|
@@ -32,7 +74,7 @@ export declare class JourneyBooking extends Booking {
|
|
|
32
74
|
} & {
|
|
33
75
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
34
76
|
resetState: () => void;
|
|
35
|
-
}>>) => void;
|
|
77
|
+
}, unknown>>) => void;
|
|
36
78
|
clearStorage: () => void;
|
|
37
79
|
rehydrate: () => Promise<void> | void;
|
|
38
80
|
hasHydrated: () => boolean;
|
|
@@ -58,7 +100,7 @@ export declare class JourneyBooking extends Booking {
|
|
|
58
100
|
} & {
|
|
59
101
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
60
102
|
resetState: () => void;
|
|
61
|
-
}>>;
|
|
103
|
+
}, unknown>>;
|
|
62
104
|
};
|
|
63
105
|
}>;
|
|
64
106
|
resetBooking(): void;
|
|
@@ -94,8 +136,6 @@ export declare class JourneyBooking extends Booking {
|
|
|
94
136
|
* @returns The created cart
|
|
95
137
|
*/
|
|
96
138
|
createCart(cartRequest: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | JourneyCart>;
|
|
97
|
-
/** @deprecated Use {@link createCart} instead. */
|
|
98
|
-
createJourneyCart(journeyCart: CreateJourneyCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | JourneyCart>;
|
|
99
139
|
/**
|
|
100
140
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
|
101
141
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
|
@@ -121,7 +121,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
121
121
|
this.cart = undefined;
|
|
122
122
|
this.cartGuid = undefined;
|
|
123
123
|
this.bookingStepsToStatus = new Map();
|
|
124
|
-
this.
|
|
124
|
+
this.bookingDueDateTime = undefined;
|
|
125
125
|
try {
|
|
126
126
|
this.getStorage().getState().updateCartGuid(undefined);
|
|
127
127
|
}
|
|
@@ -134,28 +134,28 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
JourneyBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var cart
|
|
137
|
+
var cart;
|
|
138
138
|
return __generator(this, function (_a) {
|
|
139
139
|
switch (_a.label) {
|
|
140
140
|
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
|
|
141
141
|
case 1:
|
|
142
142
|
cart = _a.sent();
|
|
143
|
-
if (cart)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
143
|
+
if (!cart)
|
|
144
|
+
return [2 /*return*/];
|
|
145
|
+
if (cart.bookingDueDateTime &&
|
|
146
|
+
new Date(cart.bookingDueDateTime.dateTime) > new Date() &&
|
|
147
|
+
!cart.hasIssuedTickets) {
|
|
148
|
+
this.cart = cart;
|
|
149
|
+
this.cartGuid = cart.guid;
|
|
150
|
+
this.bookingDueDateTime = cart.bookingDueDateTime; // See Booking class
|
|
151
|
+
// Update the sellerId. This is particularly important in Linkavel
|
|
152
|
+
this.updateSellerId(cart.sellerId);
|
|
153
|
+
// Fill the booking process status
|
|
154
|
+
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
// This should never happen, but just in case
|
|
158
|
+
this.resetBooking();
|
|
159
159
|
}
|
|
160
160
|
return [2 /*return*/];
|
|
161
161
|
}
|
|
@@ -164,10 +164,17 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
164
164
|
};
|
|
165
165
|
JourneyBooking.prototype.fetchCart = function (cartGuid, options) {
|
|
166
166
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var url;
|
|
167
|
+
var searchParams, url;
|
|
168
168
|
var _this = this;
|
|
169
169
|
return __generator(this, function (_a) {
|
|
170
|
-
|
|
170
|
+
searchParams = new URLSearchParams({
|
|
171
|
+
cartGuid: cartGuid,
|
|
172
|
+
includeBasicInfo: "true",
|
|
173
|
+
includeEconomicProperties: "true",
|
|
174
|
+
includeBookings: "true",
|
|
175
|
+
includeReductions: "true"
|
|
176
|
+
});
|
|
177
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts_v2?").concat(searchParams);
|
|
171
178
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
172
179
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
|
173
180
|
_this.resetBooking();
|
|
@@ -247,13 +254,13 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
247
254
|
JourneyBooking.prototype.getJourneys = function (request, options) {
|
|
248
255
|
return __awaiter(this, void 0, void 0, function () {
|
|
249
256
|
var searchParams, url;
|
|
250
|
-
var _a, _b
|
|
251
|
-
return __generator(this, function (
|
|
257
|
+
var _a, _b;
|
|
258
|
+
return __generator(this, function (_c) {
|
|
252
259
|
if (request.departureStopName === undefined || request.destinationStopName === undefined) {
|
|
253
260
|
throw Error("Fields departureStopName and destinationStopName are required");
|
|
254
261
|
}
|
|
255
|
-
searchParams = new URLSearchParams(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(),
|
|
256
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/
|
|
262
|
+
searchParams = new URLSearchParams(__assign(__assign(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(), outboundDate: request.outboundDate.dateTime }, (request.returnDate && { returnDate: request.returnDate.dateTime })), { currency: request.currency, outboundTripId: (_b = (_a = request.outboundTripId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "null" }), (this.cartGuid && { cartGuid: this.cartGuid })));
|
|
263
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys_v4?").concat(searchParams);
|
|
257
264
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
258
265
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
|
259
266
|
? response
|
|
@@ -301,57 +308,6 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
301
308
|
});
|
|
302
309
|
});
|
|
303
310
|
};
|
|
304
|
-
/** @deprecated Use {@link createCart} instead. */
|
|
305
|
-
JourneyBooking.prototype.createJourneyCart = function (journeyCart, options) {
|
|
306
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
-
var url, request;
|
|
308
|
-
var _this = this;
|
|
309
|
-
return __generator(this, function (_a) {
|
|
310
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/carts");
|
|
311
|
-
request = __assign(__assign({}, journeyCart), (this.cartGuid && { cartGuid: this.cartGuid }));
|
|
312
|
-
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
313
|
-
var cartDueDate;
|
|
314
|
-
return __generator(this, function (_a) {
|
|
315
|
-
switch (_a.label) {
|
|
316
|
-
case 0:
|
|
317
|
-
// Check for errors
|
|
318
|
-
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
|
319
|
-
// If there was an error, reset cartGuid and remove it from the mts-storage
|
|
320
|
-
this.resetBooking();
|
|
321
|
-
return [2 /*return*/, response];
|
|
322
|
-
}
|
|
323
|
-
if (!response.cart) return [3 /*break*/, 1];
|
|
324
|
-
this.cart = response.cart;
|
|
325
|
-
this.cartGuid = response.cart.guid;
|
|
326
|
-
// Save the cartGuid in the storage
|
|
327
|
-
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
|
328
|
-
// Fill the booking process status
|
|
329
|
-
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
|
330
|
-
cartDueDate = new Date();
|
|
331
|
-
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
|
332
|
-
this.bookingDueDate = cartDueDate;
|
|
333
|
-
// Update the sellerId. This is particularly important in Linkavel
|
|
334
|
-
this.updateSellerId(response.cart.sellerId);
|
|
335
|
-
return [2 /*return*/, response.cart];
|
|
336
|
-
case 1:
|
|
337
|
-
// Fetch & update local properties
|
|
338
|
-
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
|
339
|
-
case 2:
|
|
340
|
-
// Fetch & update local properties
|
|
341
|
-
_a.sent();
|
|
342
|
-
if (!this.cart) {
|
|
343
|
-
// Should already be handled, but just in case
|
|
344
|
-
throw new Error("Could not fetch cart");
|
|
345
|
-
}
|
|
346
|
-
// Update storage
|
|
347
|
-
this.getStorage().getState().updateCartGuid(response.cartGuid);
|
|
348
|
-
return [2 /*return*/, this.cart];
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}); })];
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
};
|
|
355
311
|
/**
|
|
356
312
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
|
357
313
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
|
@@ -3,7 +3,7 @@ import { CreateUpdateCartRequest } from "../types/common/Cart";
|
|
|
3
3
|
import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
|
5
5
|
import { Service, ServiceTripsResponse } from "../types/services/Service";
|
|
6
|
-
import {
|
|
6
|
+
import { ServiceCart } from "../types/services/ServiceCart";
|
|
7
7
|
import { ApiCallOptions } from "../utils/apiCall";
|
|
8
8
|
import { Booking } from "./booking";
|
|
9
9
|
export declare class ServiceBooking extends Booking {
|
|
@@ -17,7 +17,49 @@ export declare class ServiceBooking extends Booking {
|
|
|
17
17
|
} & {
|
|
18
18
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
19
19
|
resetState: () => void;
|
|
20
|
-
}>, "persist"> & {
|
|
20
|
+
}>, "setState" | "persist"> & {
|
|
21
|
+
setState(partial: ({
|
|
22
|
+
cartGuid: string | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
25
|
+
resetState: () => void;
|
|
26
|
+
}) | Partial<{
|
|
27
|
+
cartGuid: string | undefined;
|
|
28
|
+
} & {
|
|
29
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
30
|
+
resetState: () => void;
|
|
31
|
+
}> | ((state: {
|
|
32
|
+
cartGuid: string | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
35
|
+
resetState: () => void;
|
|
36
|
+
}) => ({
|
|
37
|
+
cartGuid: string | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
40
|
+
resetState: () => void;
|
|
41
|
+
}) | Partial<{
|
|
42
|
+
cartGuid: string | undefined;
|
|
43
|
+
} & {
|
|
44
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
45
|
+
resetState: () => void;
|
|
46
|
+
}>), replace?: false | undefined): unknown;
|
|
47
|
+
setState(state: ({
|
|
48
|
+
cartGuid: string | undefined;
|
|
49
|
+
} & {
|
|
50
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
51
|
+
resetState: () => void;
|
|
52
|
+
}) | ((state: {
|
|
53
|
+
cartGuid: string | undefined;
|
|
54
|
+
} & {
|
|
55
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
56
|
+
resetState: () => void;
|
|
57
|
+
}) => {
|
|
58
|
+
cartGuid: string | undefined;
|
|
59
|
+
} & {
|
|
60
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
61
|
+
resetState: () => void;
|
|
62
|
+
}), replace: true): unknown;
|
|
21
63
|
persist: {
|
|
22
64
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<{
|
|
23
65
|
cartGuid: string | undefined;
|
|
@@ -29,7 +71,7 @@ export declare class ServiceBooking extends Booking {
|
|
|
29
71
|
} & {
|
|
30
72
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
31
73
|
resetState: () => void;
|
|
32
|
-
}>>) => void;
|
|
74
|
+
}, unknown>>) => void;
|
|
33
75
|
clearStorage: () => void;
|
|
34
76
|
rehydrate: () => Promise<void> | void;
|
|
35
77
|
hasHydrated: () => boolean;
|
|
@@ -55,7 +97,7 @@ export declare class ServiceBooking extends Booking {
|
|
|
55
97
|
} & {
|
|
56
98
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
57
99
|
resetState: () => void;
|
|
58
|
-
}>>;
|
|
100
|
+
}, unknown>>;
|
|
59
101
|
};
|
|
60
102
|
}>;
|
|
61
103
|
getCart(): ServiceCart | undefined;
|
|
@@ -87,17 +129,15 @@ export declare class ServiceBooking extends Booking {
|
|
|
87
129
|
* and/or a specific hour for the tour.
|
|
88
130
|
* You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
|
|
89
131
|
* @param serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
|
|
90
|
-
* @param
|
|
132
|
+
* @param dateString The date on which to get the tours, in ISO string format
|
|
91
133
|
* @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
|
|
92
134
|
*/
|
|
93
|
-
getServiceTrips(serviceId: number,
|
|
135
|
+
getServiceTrips(serviceId: number, dateString: string, options?: ApiCallOptions): Promise<ErrorResponse | ServiceTripsResponse>;
|
|
94
136
|
/**
|
|
95
137
|
* This method creates a service cart for the given parameters.
|
|
96
138
|
* @returns The created cart
|
|
97
139
|
*/
|
|
98
140
|
createCart(request: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | ServiceCart>;
|
|
99
|
-
/** @deprecated Use {@link createCart} instead. */
|
|
100
|
-
createServiceCart(serviceCart: CreateServiceCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | ServiceCart>;
|
|
101
141
|
/**
|
|
102
142
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
|
103
143
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
|
@@ -121,7 +121,7 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
121
121
|
this.cart = undefined;
|
|
122
122
|
this.cartGuid = undefined;
|
|
123
123
|
this.bookingStepsToStatus = new Map();
|
|
124
|
-
this.
|
|
124
|
+
this.bookingDueDateTime = undefined;
|
|
125
125
|
try {
|
|
126
126
|
this.getStorage().getState().updateCartGuid(undefined);
|
|
127
127
|
}
|
|
@@ -134,28 +134,28 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
ServiceBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
var cart
|
|
137
|
+
var cart;
|
|
138
138
|
return __generator(this, function (_a) {
|
|
139
139
|
switch (_a.label) {
|
|
140
140
|
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
|
|
141
141
|
case 1:
|
|
142
142
|
cart = _a.sent();
|
|
143
|
-
if (cart)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
143
|
+
if (!cart)
|
|
144
|
+
return [2 /*return*/];
|
|
145
|
+
if (cart.bookingDueDateTime &&
|
|
146
|
+
new Date(cart.bookingDueDateTime.dateTime) > new Date() &&
|
|
147
|
+
!cart.hasIssuedTickets) {
|
|
148
|
+
this.cart = cart;
|
|
149
|
+
this.cartGuid = cart.guid;
|
|
150
|
+
this.bookingDueDateTime = cart.bookingDueDateTime; // See Booking class
|
|
151
|
+
// Update the sellerId. This is particularly important in Linkavel
|
|
152
|
+
this.updateSellerId(cart.sellerId);
|
|
153
|
+
// Fill the booking process status
|
|
154
|
+
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
// This should never happen, but just in case
|
|
158
|
+
this.resetBooking();
|
|
159
159
|
}
|
|
160
160
|
return [2 /*return*/];
|
|
161
161
|
}
|
|
@@ -164,10 +164,17 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
164
164
|
};
|
|
165
165
|
ServiceBooking.prototype.fetchCart = function (cartGuid, options) {
|
|
166
166
|
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var url;
|
|
167
|
+
var searchParams, url;
|
|
168
168
|
var _this = this;
|
|
169
169
|
return __generator(this, function (_a) {
|
|
170
|
-
|
|
170
|
+
searchParams = new URLSearchParams({
|
|
171
|
+
cartGuid: cartGuid,
|
|
172
|
+
includeBasicInfo: "true",
|
|
173
|
+
includeEconomicProperties: "true",
|
|
174
|
+
includeBookings: "true",
|
|
175
|
+
includeReductions: "true"
|
|
176
|
+
});
|
|
177
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts_v2?").concat(searchParams);
|
|
171
178
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
172
179
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
|
173
180
|
_this.resetBooking();
|
|
@@ -245,14 +252,17 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
245
252
|
* and/or a specific hour for the tour.
|
|
246
253
|
* You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
|
|
247
254
|
* @param serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
|
|
248
|
-
* @param
|
|
255
|
+
* @param dateString The date on which to get the tours, in ISO string format
|
|
249
256
|
* @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
|
|
250
257
|
*/
|
|
251
|
-
ServiceBooking.prototype.getServiceTrips = function (serviceId,
|
|
258
|
+
ServiceBooking.prototype.getServiceTrips = function (serviceId, dateString, options) {
|
|
252
259
|
return __awaiter(this, void 0, void 0, function () {
|
|
253
260
|
var searchParams, url;
|
|
254
261
|
return __generator(this, function (_a) {
|
|
255
|
-
searchParams = new URLSearchParams({
|
|
262
|
+
searchParams = new URLSearchParams({
|
|
263
|
+
serviceId: serviceId.toString(),
|
|
264
|
+
dateString: dateString
|
|
265
|
+
});
|
|
256
266
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/services/trips?").concat(searchParams);
|
|
257
267
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
258
268
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
|
|
@@ -298,57 +308,6 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
298
308
|
});
|
|
299
309
|
});
|
|
300
310
|
};
|
|
301
|
-
/** @deprecated Use {@link createCart} instead. */
|
|
302
|
-
ServiceBooking.prototype.createServiceCart = function (serviceCart, options) {
|
|
303
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
-
var url;
|
|
305
|
-
var _this = this;
|
|
306
|
-
return __generator(this, function (_a) {
|
|
307
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/services/carts");
|
|
308
|
-
return [2 /*return*/, this.callPostApi(url, serviceCart, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
309
|
-
var cartDueDate;
|
|
310
|
-
return __generator(this, function (_a) {
|
|
311
|
-
switch (_a.label) {
|
|
312
|
-
case 0:
|
|
313
|
-
// Check for errors
|
|
314
|
-
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
|
315
|
-
// If there was an error, reset cartGuid and remove it from the mts-storage
|
|
316
|
-
this.resetBooking();
|
|
317
|
-
return [2 /*return*/, response];
|
|
318
|
-
}
|
|
319
|
-
if (!response.cart) return [3 /*break*/, 1];
|
|
320
|
-
// Save the local data
|
|
321
|
-
this.cart = response.cart;
|
|
322
|
-
this.cartGuid = response.cart.guid;
|
|
323
|
-
// Save the cartGuid in the mts-storage
|
|
324
|
-
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
|
325
|
-
// Fill the booking process status
|
|
326
|
-
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
|
327
|
-
cartDueDate = new Date();
|
|
328
|
-
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
|
329
|
-
this.bookingDueDate = cartDueDate;
|
|
330
|
-
// Update the sellerId. This is particularly important in Linkavel
|
|
331
|
-
this.updateSellerId(response.cart.sellerId);
|
|
332
|
-
return [2 /*return*/, response.cart];
|
|
333
|
-
case 1:
|
|
334
|
-
// Fetch & update local properties
|
|
335
|
-
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
|
336
|
-
case 2:
|
|
337
|
-
// Fetch & update local properties
|
|
338
|
-
_a.sent();
|
|
339
|
-
if (!this.cart) {
|
|
340
|
-
// Should already be handled, but just in case
|
|
341
|
-
throw new Error("Could not fetch cart");
|
|
342
|
-
}
|
|
343
|
-
// Update storage
|
|
344
|
-
this.getStorage().getState().updateCartGuid(response.cartGuid);
|
|
345
|
-
return [2 /*return*/, this.cart];
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
}); })];
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
};
|
|
352
311
|
//#region PersonDetails data API
|
|
353
312
|
/**
|
|
354
313
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
|
@@ -18,7 +18,49 @@ export declare class SubscriptionBooking extends Booking {
|
|
|
18
18
|
} & {
|
|
19
19
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
20
20
|
resetState: () => void;
|
|
21
|
-
}>, "persist"> & {
|
|
21
|
+
}>, "setState" | "persist"> & {
|
|
22
|
+
setState(partial: ({
|
|
23
|
+
cartGuid: string | undefined;
|
|
24
|
+
} & {
|
|
25
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
26
|
+
resetState: () => void;
|
|
27
|
+
}) | Partial<{
|
|
28
|
+
cartGuid: string | undefined;
|
|
29
|
+
} & {
|
|
30
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
31
|
+
resetState: () => void;
|
|
32
|
+
}> | ((state: {
|
|
33
|
+
cartGuid: string | undefined;
|
|
34
|
+
} & {
|
|
35
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
36
|
+
resetState: () => void;
|
|
37
|
+
}) => ({
|
|
38
|
+
cartGuid: string | undefined;
|
|
39
|
+
} & {
|
|
40
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
41
|
+
resetState: () => void;
|
|
42
|
+
}) | Partial<{
|
|
43
|
+
cartGuid: string | undefined;
|
|
44
|
+
} & {
|
|
45
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
46
|
+
resetState: () => void;
|
|
47
|
+
}>), replace?: false | undefined): unknown;
|
|
48
|
+
setState(state: ({
|
|
49
|
+
cartGuid: string | undefined;
|
|
50
|
+
} & {
|
|
51
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
52
|
+
resetState: () => void;
|
|
53
|
+
}) | ((state: {
|
|
54
|
+
cartGuid: string | undefined;
|
|
55
|
+
} & {
|
|
56
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
57
|
+
resetState: () => void;
|
|
58
|
+
}) => {
|
|
59
|
+
cartGuid: string | undefined;
|
|
60
|
+
} & {
|
|
61
|
+
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
62
|
+
resetState: () => void;
|
|
63
|
+
}), replace: true): unknown;
|
|
22
64
|
persist: {
|
|
23
65
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<{
|
|
24
66
|
cartGuid: string | undefined;
|
|
@@ -30,7 +72,7 @@ export declare class SubscriptionBooking extends Booking {
|
|
|
30
72
|
} & {
|
|
31
73
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
32
74
|
resetState: () => void;
|
|
33
|
-
}>>) => void;
|
|
75
|
+
}, unknown>>) => void;
|
|
34
76
|
clearStorage: () => void;
|
|
35
77
|
rehydrate: () => Promise<void> | void;
|
|
36
78
|
hasHydrated: () => boolean;
|
|
@@ -56,7 +98,7 @@ export declare class SubscriptionBooking extends Booking {
|
|
|
56
98
|
} & {
|
|
57
99
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
58
100
|
resetState: () => void;
|
|
59
|
-
}>>;
|
|
101
|
+
}, unknown>>;
|
|
60
102
|
};
|
|
61
103
|
}>;
|
|
62
104
|
getCart(): SubscriptionCart | undefined;
|