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
|
@@ -121,7 +121,7 @@ var SubscriptionBooking = /** @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 SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
SubscriptionBooking.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 SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
164
164
|
};
|
|
165
165
|
SubscriptionBooking.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();
|
|
@@ -316,6 +323,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
316
323
|
});
|
|
317
324
|
});
|
|
318
325
|
};
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
319
327
|
SubscriptionBooking.prototype.createCart = function (request) {
|
|
320
328
|
return __awaiter(this, void 0, void 0, function () {
|
|
321
329
|
return __generator(this, function (_a) {
|
|
@@ -334,7 +342,6 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
334
342
|
return __generator(this, function (_a) {
|
|
335
343
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/subscriptions/carts");
|
|
336
344
|
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
337
|
-
var cartDueDate;
|
|
338
345
|
return __generator(this, function (_a) {
|
|
339
346
|
switch (_a.label) {
|
|
340
347
|
case 0:
|
|
@@ -344,23 +351,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
344
351
|
this.resetBooking();
|
|
345
352
|
return [2 /*return*/, response];
|
|
346
353
|
}
|
|
347
|
-
|
|
348
|
-
this.
|
|
349
|
-
|
|
350
|
-
// Save the cartGuid in the mts-storage
|
|
351
|
-
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
|
352
|
-
// Fill the booking process status
|
|
353
|
-
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
|
354
|
-
cartDueDate = new Date();
|
|
355
|
-
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
|
356
|
-
this.bookingDueDate = cartDueDate;
|
|
357
|
-
// Update the sellerId. This is particularly important in Linkavel
|
|
358
|
-
this.updateSellerId(response.cart.sellerId);
|
|
359
|
-
return [2 /*return*/, response.cart];
|
|
360
|
-
case 1:
|
|
361
|
-
// Fetch & update local properties
|
|
362
|
-
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
|
363
|
-
case 2:
|
|
354
|
+
// Fetch & update local properties
|
|
355
|
+
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
|
356
|
+
case 1:
|
|
364
357
|
// Fetch & update local properties
|
|
365
358
|
_a.sent();
|
|
366
359
|
if (!this.cart) {
|
|
@@ -6,7 +6,7 @@ import { AddReductionRequest } from "../types/common/Reduction";
|
|
|
6
6
|
import { TariffType, TermsType } from "../types/common/Tariffs";
|
|
7
7
|
import { GetTariffsResponse } from "../types/tpl/GetTariffsResponse";
|
|
8
8
|
import { GetSuperAreasRequest, SuperArea } from "../types/tpl/SuperArea";
|
|
9
|
-
import {
|
|
9
|
+
import { TplCart } from "../types/tpl/TplCart";
|
|
10
10
|
import { ApiCallOptions } from "../utils/apiCall";
|
|
11
11
|
import { Booking } from "./booking";
|
|
12
12
|
export declare class TplBooking extends Booking {
|
|
@@ -20,7 +20,49 @@ export declare class TplBooking 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 TplBooking 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 TplBooking extends Booking {
|
|
|
58
100
|
} & {
|
|
59
101
|
updateCartGuid: (cartGuid: string | undefined) => void;
|
|
60
102
|
resetState: () => void;
|
|
61
|
-
}>>;
|
|
103
|
+
}, unknown>>;
|
|
62
104
|
};
|
|
63
105
|
}>;
|
|
64
106
|
getCart(): undefined | TplCart;
|
|
@@ -108,8 +150,6 @@ export declare class TplBooking extends Booking {
|
|
|
108
150
|
* @returns The created cart
|
|
109
151
|
*/
|
|
110
152
|
createCart(request: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | TplCart>;
|
|
111
|
-
/** @deprecated Use {@link createCart} instead. */
|
|
112
|
-
createTplCart(tplCart: CreateTplCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | TplCart>;
|
|
113
153
|
/**
|
|
114
154
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
|
115
155
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
|
@@ -121,7 +121,7 @@ var TplBooking = /** @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 TplBooking = /** @class */ (function (_super) {
|
|
|
134
134
|
};
|
|
135
135
|
TplBooking.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 TplBooking = /** @class */ (function (_super) {
|
|
|
164
164
|
};
|
|
165
165
|
TplBooking.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();
|
|
@@ -344,64 +351,6 @@ var TplBooking = /** @class */ (function (_super) {
|
|
|
344
351
|
});
|
|
345
352
|
});
|
|
346
353
|
};
|
|
347
|
-
/** @deprecated Use {@link createCart} instead. */
|
|
348
|
-
TplBooking.prototype.createTplCart = function (tplCart, options) {
|
|
349
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
350
|
-
var url, processedTariffIdToQuantity, request;
|
|
351
|
-
var _this = this;
|
|
352
|
-
return __generator(this, function (_a) {
|
|
353
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/tpl/carts");
|
|
354
|
-
processedTariffIdToQuantity = {};
|
|
355
|
-
tplCart.tariffIdToQuantity.forEach(function (value, key) {
|
|
356
|
-
processedTariffIdToQuantity[key] = value;
|
|
357
|
-
});
|
|
358
|
-
request = __assign(__assign(__assign(__assign(__assign({ tariffIdToQuantity: processedTariffIdToQuantity, currency: tplCart.currency }, (tplCart.startDate !== undefined && { startDate: tplCart.startDate })), (tplCart.isCurrentPeriod !== undefined && { isCurrentPeriod: tplCart.isCurrentPeriod })), (tplCart.renewSubscriptionTicketPNR !== undefined && {
|
|
359
|
-
renewSubscriptionTicketPNR: tplCart.renewSubscriptionTicketPNR
|
|
360
|
-
})), (tplCart.otaResellerId !== undefined && { otaResellerId: tplCart.otaResellerId })), (tplCart.otaTicketPicture !== undefined && { otaTicketPicture: tplCart.otaTicketPicture }));
|
|
361
|
-
// Call the API
|
|
362
|
-
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
363
|
-
var cartDueDate;
|
|
364
|
-
return __generator(this, function (_a) {
|
|
365
|
-
switch (_a.label) {
|
|
366
|
-
case 0:
|
|
367
|
-
// Check for errors
|
|
368
|
-
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
|
369
|
-
// If there was an error, reset cartGuid and remove it from the mts-storage
|
|
370
|
-
this.resetBooking();
|
|
371
|
-
return [2 /*return*/, response];
|
|
372
|
-
}
|
|
373
|
-
if (!response.cart) return [3 /*break*/, 1];
|
|
374
|
-
this.cart = response.cart;
|
|
375
|
-
this.cartGuid = response.cart.guid;
|
|
376
|
-
// Save the cartGuid in the mts-storage
|
|
377
|
-
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
|
378
|
-
// Fill the booking process status
|
|
379
|
-
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
|
380
|
-
cartDueDate = new Date();
|
|
381
|
-
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
|
382
|
-
this.bookingDueDate = cartDueDate;
|
|
383
|
-
// Update the sellerId. This is particularly important in Linkavel
|
|
384
|
-
this.updateSellerId(response.cart.sellerId);
|
|
385
|
-
return [2 /*return*/, response.cart];
|
|
386
|
-
case 1:
|
|
387
|
-
// Fetch & update local properties
|
|
388
|
-
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
|
389
|
-
case 2:
|
|
390
|
-
// Fetch & update local properties
|
|
391
|
-
_a.sent();
|
|
392
|
-
if (!this.cart) {
|
|
393
|
-
// Should already be handled, but just in case
|
|
394
|
-
throw new Error("Could not fetch cart");
|
|
395
|
-
}
|
|
396
|
-
// Update storage
|
|
397
|
-
this.getStorage().getState().updateCartGuid(response.cartGuid);
|
|
398
|
-
return [2 /*return*/, this.cart];
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
}); })];
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
354
|
//#region PersonDetails data API
|
|
406
355
|
/**
|
|
407
356
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
package/lib/index.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ export { ServiceBooking } from "./booking/serviceBooking";
|
|
|
4
4
|
export { SubscriptionBooking } from "./booking/subscriptionBooking";
|
|
5
5
|
export { TplBooking } from "./booking/tplBooking";
|
|
6
6
|
export { useMtsBookingState } from "./mtsStorage";
|
|
7
|
+
export { isNullOrUndefined, isNullOrWhiteSpace } from "./utils/utils";
|
|
7
8
|
export { CreateUpdateCartRequest, CartBooking } from "./types/common/Cart";
|
|
8
9
|
export { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
|
|
9
|
-
export { GetBuyerPassengersDetailsResponse, GetPersonRequest, GetPassenger,
|
|
10
|
+
export { GetBuyerPassengersDetailsResponse, GetPersonRequest, GetPassenger, EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
|
|
10
11
|
export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
|
|
11
12
|
export { ReductionType, Reduction, AddReductionRequest } from "./types/common/Reduction";
|
|
12
13
|
export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, IssueCartResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
|
|
@@ -14,18 +15,18 @@ export { ErrorResponse, objectIsMTSErrorResponse } from "./types/ErrorResponse";
|
|
|
14
15
|
export { City } from "./types/common/City";
|
|
15
16
|
export { Extra, GetExtrasResponse, GetExtrasForBookingResponse } from "./types/common/Extra";
|
|
16
17
|
export { BusLayoutCell, BusMatrix, BusCellTypes, SeatStatus } from "./types/journeys/BusMatrix";
|
|
17
|
-
export { JourneyCart, JourneyBookingType,
|
|
18
|
+
export { JourneyCart, JourneyBookingType, TripBookingInfo } from "./types/journeys/JourneyCart";
|
|
18
19
|
export { JourneyInfo } from "./types/journeys/JourneyInfo";
|
|
19
20
|
export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
|
|
20
21
|
export { Stop } from "./types/journeys/Stop";
|
|
21
22
|
export { Trip, CartTrip, ReductionTrip } from "./types/journeys/Trip";
|
|
22
23
|
export { Line } from "./types/services/Line";
|
|
23
|
-
export { Service,
|
|
24
|
-
export { ServiceCart, ServiceBookingType
|
|
24
|
+
export { Service, TripIdAndHour, ServiceTripsResponse, ServiceTrip } from "./types/services/Service";
|
|
25
|
+
export { ServiceCart, ServiceBookingType } from "./types/services/ServiceCart";
|
|
25
26
|
export { ServiceInfo } from "./types/services/ServiceInfo";
|
|
26
27
|
export { GetTariffsResponse } from "./types/tpl/GetTariffsResponse";
|
|
27
28
|
export { SuperArea, GetSuperAreasRequest } from "./types/tpl/SuperArea";
|
|
28
|
-
export {
|
|
29
|
+
export { TplCart, TplBookingType, TplBookingInfo } from "./types/tpl/TplCart";
|
|
29
30
|
export { Subscription } from "./types/subscriptions/Subscriptions";
|
|
30
31
|
export { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse, SubscriptionCalendarDayPeriodInfo } from "./types/subscriptions/SubscriptionAvailabilities";
|
|
31
32
|
export { SubscriptionCart, SubscriptionBookingType, CreateSubscriptionCartRequest, SubscriptionPeriod } from "./types/subscriptions/SubscriptionCart";
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_JOURNEY_SEARCH = exports.
|
|
3
|
+
exports.DEFAULT_JOURNEY_SEARCH = exports.SeatStatus = exports.BusCellTypes = exports.objectIsMTSErrorResponse = exports.PaymentMethods = exports.GatewayTypes = exports.ReductionType = exports.initializePerson = exports.DEFAULT_PERSON = exports.isNullOrWhiteSpace = exports.isNullOrUndefined = exports.useMtsBookingState = exports.TplBooking = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
|
|
4
4
|
//#region Export Booking classes
|
|
5
5
|
var booking_1 = require("./booking/booking");
|
|
6
6
|
Object.defineProperty(exports, "Booking", { enumerable: true, get: function () { return booking_1.Booking; } });
|
|
@@ -16,11 +16,14 @@ Object.defineProperty(exports, "TplBooking", { enumerable: true, get: function (
|
|
|
16
16
|
//#region Export Zustand states
|
|
17
17
|
var mtsStorage_1 = require("./mtsStorage");
|
|
18
18
|
Object.defineProperty(exports, "useMtsBookingState", { enumerable: true, get: function () { return mtsStorage_1.useMtsBookingState; } });
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region Export utils
|
|
21
|
+
var utils_1 = require("./utils/utils");
|
|
22
|
+
Object.defineProperty(exports, "isNullOrUndefined", { enumerable: true, get: function () { return utils_1.isNullOrUndefined; } });
|
|
23
|
+
Object.defineProperty(exports, "isNullOrWhiteSpace", { enumerable: true, get: function () { return utils_1.isNullOrWhiteSpace; } });
|
|
19
24
|
var Person_1 = require("./types/common/Person");
|
|
20
25
|
Object.defineProperty(exports, "DEFAULT_PERSON", { enumerable: true, get: function () { return Person_1.DEFAULT_PERSON; } });
|
|
21
26
|
Object.defineProperty(exports, "initializePerson", { enumerable: true, get: function () { return Person_1.initializePerson; } });
|
|
22
|
-
var Person_2 = require("./types/common/Person");
|
|
23
|
-
Object.defineProperty(exports, "BuyerDataStatus", { enumerable: true, get: function () { return Person_2.BuyerDataStatus; } });
|
|
24
27
|
var Reduction_1 = require("./types/common/Reduction");
|
|
25
28
|
Object.defineProperty(exports, "ReductionType", { enumerable: true, get: function () { return Reduction_1.ReductionType; } });
|
|
26
29
|
var Payment_1 = require("./types/common/Payment");
|
|
@@ -33,8 +36,6 @@ Object.defineProperty(exports, "objectIsMTSErrorResponse", { enumerable: true, g
|
|
|
33
36
|
var BusMatrix_1 = require("./types/journeys/BusMatrix");
|
|
34
37
|
Object.defineProperty(exports, "BusCellTypes", { enumerable: true, get: function () { return BusMatrix_1.BusCellTypes; } });
|
|
35
38
|
Object.defineProperty(exports, "SeatStatus", { enumerable: true, get: function () { return BusMatrix_1.SeatStatus; } });
|
|
36
|
-
var JourneyCart_1 = require("./types/journeys/JourneyCart");
|
|
37
|
-
Object.defineProperty(exports, "DEFAULT_CREATE_JOURNEY_CART", { enumerable: true, get: function () { return JourneyCart_1.DEFAULT_CREATE_JOURNEY_CART; } });
|
|
38
39
|
var JourneySearch_1 = require("./types/journeys/JourneySearch");
|
|
39
40
|
Object.defineProperty(exports, "DEFAULT_JOURNEY_SEARCH", { enumerable: true, get: function () { return JourneySearch_1.DEFAULT_JOURNEY_SEARCH; } });
|
|
40
41
|
//#endregion
|
package/lib/mtsStorage.d.ts
CHANGED
|
@@ -8,26 +8,30 @@ type MtsBookingAction = {
|
|
|
8
8
|
/**
|
|
9
9
|
* This hook will return the correct Zustand state based on the application which runs the library
|
|
10
10
|
*/
|
|
11
|
-
export declare const useMtsBookingState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
|
|
11
|
+
export declare const useMtsBookingState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "setState" | "persist"> & {
|
|
12
|
+
setState(partial: (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction> | ((state: MtsBookingState & MtsBookingAction) => (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction>), replace?: false | undefined): unknown;
|
|
13
|
+
setState(state: (MtsBookingState & MtsBookingAction) | ((state: MtsBookingState & MtsBookingAction) => MtsBookingState & MtsBookingAction), replace: true): unknown;
|
|
12
14
|
persist: {
|
|
13
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
|
|
15
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>) => void;
|
|
14
16
|
clearStorage: () => void;
|
|
15
17
|
rehydrate: () => Promise<void> | void;
|
|
16
18
|
hasHydrated: () => boolean;
|
|
17
19
|
onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
|
18
20
|
onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
|
19
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
|
|
21
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>;
|
|
20
22
|
};
|
|
21
23
|
}>;
|
|
22
|
-
export declare const useTestState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
|
|
24
|
+
export declare const useTestState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "setState" | "persist"> & {
|
|
25
|
+
setState(partial: (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction> | ((state: MtsBookingState & MtsBookingAction) => (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction>), replace?: false | undefined): unknown;
|
|
26
|
+
setState(state: (MtsBookingState & MtsBookingAction) | ((state: MtsBookingState & MtsBookingAction) => MtsBookingState & MtsBookingAction), replace: true): unknown;
|
|
23
27
|
persist: {
|
|
24
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
|
|
28
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>) => void;
|
|
25
29
|
clearStorage: () => void;
|
|
26
30
|
rehydrate: () => Promise<void> | void;
|
|
27
31
|
hasHydrated: () => boolean;
|
|
28
32
|
onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
|
29
33
|
onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
|
30
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
|
|
34
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>;
|
|
31
35
|
};
|
|
32
36
|
}>;
|
|
33
37
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Booking } from "../../booking/booking";
|
|
2
2
|
import { Reduction } from "./Reduction";
|
|
3
|
-
import { Extra } from "./Extra";
|
|
4
3
|
import { PaymentMethods } from "./Payment";
|
|
4
|
+
import { DateWithTimeZone } from "./dates";
|
|
5
5
|
export declare enum SellingMethod {
|
|
6
6
|
LINKAVEL = "LINKAVEL",
|
|
7
7
|
BACKOFFICE = "BACKOFFICE",
|
|
@@ -27,21 +27,11 @@ export type CartBooking = {
|
|
|
27
27
|
/** A record containing tariff ids as keys and their respective quantities as values. */
|
|
28
28
|
tariffIdToQuantity?: Record<number, number>;
|
|
29
29
|
/** The date of the booking in ISO string format (optional). */
|
|
30
|
-
|
|
30
|
+
dateTimeLocalString?: string;
|
|
31
31
|
/** The id of the trip, if necessary. For example, this is used by services that require a specific trip to be selected, or by MLP booking */
|
|
32
32
|
tripId?: number;
|
|
33
33
|
/** The id of the line, if necessary. For example, this is used by Services */
|
|
34
34
|
lineId?: number;
|
|
35
|
-
/**
|
|
36
|
-
* The start date of the booking, if necessary. For example, this is used by TPL subscriptions.
|
|
37
|
-
* @deprecated Use {@link CartBooking.dateTimeLocalLong} instead.
|
|
38
|
-
*/
|
|
39
|
-
startDate?: string;
|
|
40
|
-
/**
|
|
41
|
-
* The start date of the booking, if necessary. For example, this is used by TPL subscriptions.
|
|
42
|
-
* @format "YYYYMMDDHHMMSSMMM", the time refers to the local time zone of the seller.
|
|
43
|
-
*/
|
|
44
|
-
dateTimeLocalLong?: number;
|
|
45
35
|
/** If true, then the booking will be the current period (e.g. this month or this year), otherwise it will be the next period. */
|
|
46
36
|
isCurrentPeriod?: boolean;
|
|
47
37
|
/** The PNR of the ticket of reference, if necessary. For example, this is used in TPL when renewing a subscription. */
|
|
@@ -62,82 +52,94 @@ export type CartBooking = {
|
|
|
62
52
|
export type Cart = {
|
|
63
53
|
/** The guid of the cart */
|
|
64
54
|
guid: string;
|
|
65
|
-
/** The id of the
|
|
66
|
-
|
|
67
|
-
/** The url redirecting to the privacy policy of the seller */
|
|
68
|
-
sellerPrivacyUrl: string;
|
|
69
|
-
/** The url redirecting to the terms and conditions of the seller */
|
|
70
|
-
sellerTermsUrl: string;
|
|
71
|
-
/** The support email of the seller, if any */
|
|
72
|
-
sellerEmailLinkavel: string | null;
|
|
73
|
-
/** The code of the cart */
|
|
74
|
-
cartCode: string;
|
|
75
|
-
/** If true, the tickets in the cart will be automatically printer after the payment */
|
|
76
|
-
autoPrintOption: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* A boolean telling whether the cart has issued tickets.
|
|
79
|
-
* Note that if this is the case, the cart will be null because it is not
|
|
80
|
-
* possible to add tickets to an issued cart. Thus, all data should be reset.
|
|
81
|
-
*/
|
|
82
|
-
hasIssuedTickets: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* This data structure describes the steps of the booking process.
|
|
85
|
-
* The keys of this dictionary represent the booking steps. See {@link Booking.BookingSteps}
|
|
86
|
-
* for the list of possible steps.
|
|
87
|
-
* If the key is present, then the booking step shall be displayed. The value
|
|
88
|
-
* is a list of 3 booleans:
|
|
89
|
-
* - The first tells whether it is possible to go to that section. If not, other
|
|
90
|
-
* sections must be completed first.
|
|
91
|
-
* - The second tells whether the section is completed.
|
|
92
|
-
* - The third tells whether the section is required.
|
|
93
|
-
*/
|
|
94
|
-
stepsToStatus: Record<Booking.BookingSteps, [boolean, boolean, boolean]>;
|
|
95
|
-
/** The currency of the cart. See {@link Booking.Currencies} */
|
|
96
|
-
currency: Booking.Currencies;
|
|
97
|
-
/** The date and time when the cart expires */
|
|
98
|
-
bookingDueDate: string;
|
|
55
|
+
/** The id of the buyer that the cart is for. */
|
|
56
|
+
buyerId: number;
|
|
99
57
|
/**
|
|
100
58
|
* The number of seconds remaining before the cart expires. This should be equivalent
|
|
101
59
|
* `bookingDueDate`
|
|
102
60
|
*/
|
|
103
61
|
bookingDueDateRemainingSeconds: number;
|
|
104
|
-
/** The list of reductions applied to the cart */
|
|
105
|
-
reductions: Reduction[];
|
|
106
|
-
/** The list of extras services of the cart */
|
|
107
|
-
extras: Extra[];
|
|
108
|
-
/** The selling method of the cart (LinkAvel, Backoffice) */
|
|
109
|
-
sellingMethod: SellingMethod;
|
|
110
|
-
/**
|
|
111
|
-
* The total value of the cart, meaning the sum of the nominal prices of all tickets.
|
|
112
|
-
* It is expressed in the currency of the cart.
|
|
113
|
-
*/
|
|
114
|
-
totalValue: number;
|
|
115
62
|
/**
|
|
116
63
|
* The total reseller fee of the cart, meaning the sum of the reseller fees of
|
|
117
64
|
* all tickets. It is expressed in the currency of the cart.
|
|
118
65
|
*/
|
|
119
|
-
totalResellerFee
|
|
66
|
+
totalResellerFee: number;
|
|
120
67
|
/**
|
|
121
68
|
* The total credit from change of the cart. This is non zero only during the
|
|
122
69
|
* change process, and represents the credit that the user has from the previous
|
|
123
70
|
* cart. It is expressed in the currency of the cart.
|
|
124
71
|
*/
|
|
125
72
|
totalCreditFromChange: number;
|
|
73
|
+
/** The total amount to pay by buyer */
|
|
74
|
+
totalAmountToPayByBuyer: number;
|
|
126
75
|
/**
|
|
127
76
|
* The total amount to pay of the cart, meaning the amount that the user has to
|
|
128
77
|
* pay to complete the booking. This is what is displayed in the payment page.
|
|
129
78
|
* It is expressed in the currency of the cart.
|
|
130
79
|
*/
|
|
131
80
|
totalAmountToPay: number;
|
|
81
|
+
/** The total amount paid by buyer */
|
|
82
|
+
totalAmountPaidByBuyer: number;
|
|
83
|
+
/** The total services value */
|
|
84
|
+
totalServicesValue: number;
|
|
85
|
+
/** The total actual value */
|
|
86
|
+
totalActualValue: number;
|
|
87
|
+
/**
|
|
88
|
+
* The total value of the cart, meaning the sum of the nominal prices of all tickets.
|
|
89
|
+
* It is expressed in the currency of the cart.
|
|
90
|
+
*/
|
|
91
|
+
totalValue: number;
|
|
92
|
+
/** The currency of the cart. See {@link Booking.Currencies} */
|
|
93
|
+
currency: Booking.Currencies;
|
|
94
|
+
/** The selling method of the cart (LinkAvel, Backoffice) */
|
|
95
|
+
sellingMethod: SellingMethod;
|
|
96
|
+
/** The support email of the seller, if any */
|
|
97
|
+
sellerEmailLinkavel: string;
|
|
98
|
+
/** Whether the cart is not associated with a specific SSN. */
|
|
99
|
+
noSSN: boolean;
|
|
100
|
+
/** If true, the tickets in the cart will be automatically printer after the payment */
|
|
101
|
+
autoPrintOption: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* A boolean telling whether the cart has issued tickets.
|
|
104
|
+
* Note that if this is the case, the cart will be null because it is not
|
|
105
|
+
* possible to add tickets to an issued cart. Thus, all data should be reset.
|
|
106
|
+
*/
|
|
107
|
+
hasIssuedTickets: boolean;
|
|
108
|
+
/** The booking due date as ISO string */
|
|
109
|
+
bookingDueDateTime: DateWithTimeZone;
|
|
110
|
+
/** The ids of the tickets in the cart */
|
|
111
|
+
ticketIds: number[];
|
|
112
|
+
/** The PNRs of the tickets in the cart */
|
|
113
|
+
ticketsPNRs: string[];
|
|
114
|
+
/** The seller IDs */
|
|
115
|
+
sellerIds: number[];
|
|
116
|
+
/** The id of the seller of the tickets in the cart */
|
|
117
|
+
sellerId: number;
|
|
118
|
+
/** The url redirecting to the privacy policy of the seller */
|
|
119
|
+
sellerPrivacyUrl: string;
|
|
120
|
+
/** The url redirecting to the terms and conditions of the seller */
|
|
121
|
+
sellerTermsUrl: string;
|
|
122
|
+
/** The list of reductions applied to the cart */
|
|
123
|
+
reductions: Reduction[];
|
|
124
|
+
/**
|
|
125
|
+
* This data structure describes the steps of the booking process.
|
|
126
|
+
* The keys of this dictionary represent the booking steps. See {@link Booking.BookingSteps}
|
|
127
|
+
* for the list of possible steps.
|
|
128
|
+
* If the key is present, then the booking step shall be displayed. The value
|
|
129
|
+
* is a list of 3 booleans:
|
|
130
|
+
* - The first tells whether it is possible to go to that section. If not, other
|
|
131
|
+
* sections must be completed first.
|
|
132
|
+
* - The second tells whether the section is completed.
|
|
133
|
+
* - The third tells whether the section is required.
|
|
134
|
+
*/
|
|
135
|
+
stepsToStatus: Record<Booking.BookingSteps, [boolean, boolean, boolean]>;
|
|
132
136
|
/**
|
|
133
137
|
* A list of string representing the possible ways to cash in the ticket.
|
|
134
138
|
* The first element of the list is the default cash in method (and the preferred by the seller).
|
|
135
139
|
*/
|
|
136
140
|
cashInMethods: PaymentMethods[];
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
noSSN: boolean;
|
|
141
|
+
/** The cart ID */
|
|
142
|
+
id: number;
|
|
141
143
|
};
|
|
142
144
|
/** The type that {@link Cart.stepsToStatus} assumes once parsed to a map */
|
|
143
145
|
export type processedStepsToStatus = Map<Booking.BookingSteps, [boolean, boolean, boolean]>;
|