mts-booking-library 3.2.0 → 3.4.0
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 +3 -5
- package/lib/booking/booking.js +4 -6
- package/lib/booking/journeyBooking.d.ts +16 -3
- package/lib/booking/journeyBooking.js +28 -8
- package/lib/index.d.ts +1 -1
- package/lib/types/common/Person.d.ts +4 -0
- package/lib/types/common/Person.js +2 -1
- package/lib/types/journeys/BusMatrix.d.ts +11 -0
- package/package.json +1 -1
package/lib/booking/booking.d.ts
CHANGED
|
@@ -78,13 +78,11 @@ export declare abstract class Booking {
|
|
|
78
78
|
/**
|
|
79
79
|
* @description This method shall be used to get all necessary informations to initialize a payment with a certain gateway.
|
|
80
80
|
* @param gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
|
|
81
|
-
* @param
|
|
82
|
-
*
|
|
83
|
-
* `/booking?step=BOOKING_STEP_PAYMENT_PROCESSING&cartGuid={guid}` path on top. Pass `window.location.origin` from the
|
|
84
|
-
* caller — the BE owns the rest. Replaces the legacy full-URL `returnUrl` parameter (BE 3.2.0+).
|
|
81
|
+
* @param returnUrl The url to which the user will be redirected after the payment. This value shall be set only if the
|
|
82
|
+
* chosen gateway is {@link GatewayTypes.PAYPAL} or {@link GatewayTypes.WORLDLINE}
|
|
85
83
|
* @returns An {@link ErrorResponse} object in case of error, a {@link GetPaymentInformationFromGatewayResponse} object otherwise.
|
|
86
84
|
*/
|
|
87
|
-
getPaymentInformationFromGateway(gatewayId: number,
|
|
85
|
+
getPaymentInformationFromGateway(gatewayId: number, returnUrl?: string, options?: ApiCallOptions): Promise<ErrorResponse | GetPaymentInformationFromGatewayResponse>;
|
|
88
86
|
/**
|
|
89
87
|
* @description This method shall be used to issue the tickets. It must be called after the payment was successful.
|
|
90
88
|
* @param paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
|
package/lib/booking/booking.js
CHANGED
|
@@ -285,13 +285,11 @@ var Booking = /** @class */ (function () {
|
|
|
285
285
|
/**
|
|
286
286
|
* @description This method shall be used to get all necessary informations to initialize a payment with a certain gateway.
|
|
287
287
|
* @param gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
|
|
288
|
-
* @param
|
|
289
|
-
*
|
|
290
|
-
* `/booking?step=BOOKING_STEP_PAYMENT_PROCESSING&cartGuid={guid}` path on top. Pass `window.location.origin` from the
|
|
291
|
-
* caller — the BE owns the rest. Replaces the legacy full-URL `returnUrl` parameter (BE 3.2.0+).
|
|
288
|
+
* @param returnUrl The url to which the user will be redirected after the payment. This value shall be set only if the
|
|
289
|
+
* chosen gateway is {@link GatewayTypes.PAYPAL} or {@link GatewayTypes.WORLDLINE}
|
|
292
290
|
* @returns An {@link ErrorResponse} object in case of error, a {@link GetPaymentInformationFromGatewayResponse} object otherwise.
|
|
293
291
|
*/
|
|
294
|
-
Booking.prototype.getPaymentInformationFromGateway = function (gatewayId,
|
|
292
|
+
Booking.prototype.getPaymentInformationFromGateway = function (gatewayId, returnUrl, options) {
|
|
295
293
|
return __awaiter(this, void 0, void 0, function () {
|
|
296
294
|
var issueStep, searchParams, url;
|
|
297
295
|
return __generator(this, function (_a) {
|
|
@@ -303,7 +301,7 @@ var Booking = /** @class */ (function () {
|
|
|
303
301
|
if (!issueStep || !issueStep[0]) {
|
|
304
302
|
throw Error("The status of the cart does not allow to call this API");
|
|
305
303
|
}
|
|
306
|
-
searchParams = new URLSearchParams(__assign({ gatewayId: gatewayId.toString(), cartGuid: this.cartGuid }, (
|
|
304
|
+
searchParams = new URLSearchParams(__assign({ gatewayId: gatewayId.toString(), cartGuid: this.cartGuid }, (returnUrl && { returnUrl: returnUrl })));
|
|
307
305
|
url = "".concat(this.config.API_ENDPOINT, "/v3_payment/paymentInformation?").concat(searchParams);
|
|
308
306
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
309
307
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
|
@@ -2,7 +2,7 @@ import { ErrorResponse } from "../types/ErrorResponse";
|
|
|
2
2
|
import { CreateUpdateCartRequest } from "../types/common/Cart";
|
|
3
3
|
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse } from "../types/common/Person";
|
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
|
5
|
-
import { BusMatrix } from "../types/journeys/BusMatrix";
|
|
5
|
+
import { BusMatrix, SeatChange } from "../types/journeys/BusMatrix";
|
|
6
6
|
import { JourneyCart } from "../types/journeys/JourneyCart";
|
|
7
7
|
import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/JourneySearch";
|
|
8
8
|
import { ReductionTrip } from "../types/journeys/Trip";
|
|
@@ -165,11 +165,24 @@ export declare class JourneyBooking extends Booking {
|
|
|
165
165
|
getAssignedSeats(tripId: number, options?: ApiCallOptions): Promise<ErrorResponse | number[]>;
|
|
166
166
|
/**
|
|
167
167
|
* @description This method shall be called when the user wants to change the assigned seats of a trip.
|
|
168
|
+
*
|
|
169
|
+
* Two shapes are supported. Callers should prefer `seatChanges` when
|
|
170
|
+
* the cart has more than one passenger on the trip — the BE pairs by
|
|
171
|
+
* {@link SeatChange.oldSeatId}, which uniquely identifies the cart's
|
|
172
|
+
* underlying TripBusLayoutCell. The legacy `newSeatsIds` form is a
|
|
173
|
+
* full positional snapshot of every passenger's new seat; the BE
|
|
174
|
+
* zips it against EF-ordered TripBusLayoutCells, which can reassign
|
|
175
|
+
* the wrong passenger when the two orderings disagree.
|
|
176
|
+
*
|
|
177
|
+
* Send only one of the two arguments per call. If both are present
|
|
178
|
+
* the BE prefers `seatChanges`.
|
|
168
179
|
* @param tripId The id of the trip for which the seats should be changed
|
|
169
|
-
* @param
|
|
180
|
+
* @param seatsOrChanges Either the legacy `newSeatsIds` array (every
|
|
181
|
+
* passenger's new seat, in order) or an explicit list of
|
|
182
|
+
* {@link SeatChange} pairs (only the seats that change).
|
|
170
183
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
|
171
184
|
*/
|
|
172
|
-
changeSeatsOfTrip(tripId: number,
|
|
185
|
+
changeSeatsOfTrip(tripId: number, seatsOrChanges: number[] | SeatChange[], options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
|
173
186
|
/**
|
|
174
187
|
* @description This method shall be called when the user wants to retrieve the trips in the cart, for adding a available reduction
|
|
175
188
|
* to a specific trip (rather than to the whole cart).
|
|
@@ -462,13 +462,26 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
462
462
|
};
|
|
463
463
|
/**
|
|
464
464
|
* @description This method shall be called when the user wants to change the assigned seats of a trip.
|
|
465
|
+
*
|
|
466
|
+
* Two shapes are supported. Callers should prefer `seatChanges` when
|
|
467
|
+
* the cart has more than one passenger on the trip — the BE pairs by
|
|
468
|
+
* {@link SeatChange.oldSeatId}, which uniquely identifies the cart's
|
|
469
|
+
* underlying TripBusLayoutCell. The legacy `newSeatsIds` form is a
|
|
470
|
+
* full positional snapshot of every passenger's new seat; the BE
|
|
471
|
+
* zips it against EF-ordered TripBusLayoutCells, which can reassign
|
|
472
|
+
* the wrong passenger when the two orderings disagree.
|
|
473
|
+
*
|
|
474
|
+
* Send only one of the two arguments per call. If both are present
|
|
475
|
+
* the BE prefers `seatChanges`.
|
|
465
476
|
* @param tripId The id of the trip for which the seats should be changed
|
|
466
|
-
* @param
|
|
477
|
+
* @param seatsOrChanges Either the legacy `newSeatsIds` array (every
|
|
478
|
+
* passenger's new seat, in order) or an explicit list of
|
|
479
|
+
* {@link SeatChange} pairs (only the seats that change).
|
|
467
480
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
|
468
481
|
*/
|
|
469
|
-
JourneyBooking.prototype.changeSeatsOfTrip = function (tripId,
|
|
482
|
+
JourneyBooking.prototype.changeSeatsOfTrip = function (tripId, seatsOrChanges, options) {
|
|
470
483
|
return __awaiter(this, void 0, void 0, function () {
|
|
471
|
-
var seatSelectionStatus, url;
|
|
484
|
+
var seatSelectionStatus, usesExplicitShape, body, url;
|
|
472
485
|
var _this = this;
|
|
473
486
|
return __generator(this, function (_a) {
|
|
474
487
|
// First check that it is possible to call this API
|
|
@@ -479,12 +492,19 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
479
492
|
if (!seatSelectionStatus || !seatSelectionStatus[0]) {
|
|
480
493
|
throw Error("The status of the cart does not allow to call this API");
|
|
481
494
|
}
|
|
495
|
+
usesExplicitShape = seatsOrChanges.length > 0 && typeof seatsOrChanges[0] === "object";
|
|
496
|
+
body = {
|
|
497
|
+
tripId: tripId,
|
|
498
|
+
cartGuid: this.cart.guid
|
|
499
|
+
};
|
|
500
|
+
if (usesExplicitShape) {
|
|
501
|
+
body.seatChanges = seatsOrChanges;
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
504
|
+
body.newSeatsIds = seatsOrChanges;
|
|
505
|
+
}
|
|
482
506
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/seats");
|
|
483
|
-
return [2 /*return*/, this.callPostApi(url, {
|
|
484
|
-
tripId: tripId,
|
|
485
|
-
newSeatsIds: newSeatsIds,
|
|
486
|
-
cartGuid: this.cart.guid
|
|
487
|
-
}, options).then(function (response) {
|
|
507
|
+
return [2 /*return*/, this.callPostApi(url, body, options).then(function (response) {
|
|
488
508
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response))
|
|
489
509
|
return response;
|
|
490
510
|
// Update the booking process status
|
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export { ErrorResponse, objectIsMTSErrorResponse } from "./types/ErrorResponse";
|
|
|
16
16
|
export { City } from "./types/common/City";
|
|
17
17
|
export { Extra, GetExtrasResponse, GetExtrasForBookingResponse } from "./types/common/Extra";
|
|
18
18
|
export * from "./types/common/dates";
|
|
19
|
-
export { BusLayoutCell, BusMatrix, BusCellTypes, SeatStatus } from "./types/journeys/BusMatrix";
|
|
19
|
+
export { BusLayoutCell, BusMatrix, BusCellTypes, SeatChange, SeatStatus } from "./types/journeys/BusMatrix";
|
|
20
20
|
export { JourneyCart, JourneyBookingType, TripBookingInfo } from "./types/journeys/JourneyCart";
|
|
21
21
|
export { JourneyInfo } from "./types/journeys/JourneyInfo";
|
|
22
22
|
export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
|
|
@@ -19,6 +19,8 @@ export type Person = {
|
|
|
19
19
|
notes?: string;
|
|
20
20
|
/** The social security number of the person. */
|
|
21
21
|
socialSecurityNumber?: string | null;
|
|
22
|
+
/** The sex of the person. M = male, F = female, O = other. */
|
|
23
|
+
sex?: "M" | "F" | "O" | null;
|
|
22
24
|
};
|
|
23
25
|
export declare const DEFAULT_PERSON: Person;
|
|
24
26
|
export declare const initializePerson: (person?: Person | undefined | null) => Person;
|
|
@@ -55,6 +57,8 @@ export type GetPassenger = Person & {
|
|
|
55
57
|
passengerPhoneNumberOption: PersonDataFieldStatus;
|
|
56
58
|
/** Whether the passenger social security number is reuqired, optional or cannot be specified. */
|
|
57
59
|
passengerSSNOption: PersonDataFieldStatus;
|
|
60
|
+
/** Whether the passenger sex is required, optional or cannot be specified. */
|
|
61
|
+
passengerSexOption?: PersonDataFieldStatus;
|
|
58
62
|
};
|
|
59
63
|
export declare enum PersonDataFieldStatus {
|
|
60
64
|
/** The field (e.g. the buyer's email) is optional. The input shall be displayed, but the user can skip it. */
|
|
@@ -18,6 +18,17 @@ export type BusLayoutCell = {
|
|
|
18
18
|
* - On the third dimension, the are the columns.
|
|
19
19
|
*/
|
|
20
20
|
export type BusMatrix = BusLayoutCell[][][];
|
|
21
|
+
/**
|
|
22
|
+
* Explicit (oldSeatId, newSeatId) pair for a single seat change in a
|
|
23
|
+
* cart. Used by `JourneyBooking.changeSeatsOfTrip` instead of the
|
|
24
|
+
* legacy positional `newSeatsIds` snapshot — the BE pairs by
|
|
25
|
+
* `oldSeatId`, so multi-passenger swaps no longer depend on array
|
|
26
|
+
* order and can never reassign the wrong passenger.
|
|
27
|
+
*/
|
|
28
|
+
export type SeatChange = {
|
|
29
|
+
oldSeatId: number;
|
|
30
|
+
newSeatId: number;
|
|
31
|
+
};
|
|
21
32
|
export declare enum BusCellTypes {
|
|
22
33
|
SEAT = "SEAT",
|
|
23
34
|
SELECTED_SEAT = "SELECTED_SEAT",
|