mts-booking-library 1.3.16 → 1.3.18
Sign up to get free protection for your applications and to get access to all the features.
@@ -128,9 +128,11 @@ export declare class TplBooking extends Booking {
|
|
128
128
|
* @description This method shall be called when the user wants to update the buyer information.
|
129
129
|
* @param buyerDetails The object containing the buyer information.
|
130
130
|
* It should be null if the buyer data cannot be specified (see {@link GetBuyerPassengersDetailsResponse.buyerDataStatus}).
|
131
|
+
* @param subscriptionPersonCode The person code of the passenger that is associated
|
132
|
+
* with the subscription. This parameter is required if the cart contains a subscription.
|
131
133
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
132
134
|
*/
|
133
|
-
updateBuyerPassengersDetails(buyerDetails: Buyer | null): Promise<ErrorResponse | boolean>;
|
135
|
+
updateBuyerPassengersDetails(buyerDetails: Buyer | null, subscriptionPersonCode?: string): Promise<ErrorResponse | boolean>;
|
134
136
|
/**
|
135
137
|
* @description This method allows to add a reduction to the whole cart or to a single trip in the cart.
|
136
138
|
* @param {AddReductionRequest} request The information about the reduction to add
|
@@ -425,9 +425,11 @@ var TplBooking = /** @class */ (function (_super) {
|
|
425
425
|
* @description This method shall be called when the user wants to update the buyer information.
|
426
426
|
* @param buyerDetails The object containing the buyer information.
|
427
427
|
* It should be null if the buyer data cannot be specified (see {@link GetBuyerPassengersDetailsResponse.buyerDataStatus}).
|
428
|
+
* @param subscriptionPersonCode The person code of the passenger that is associated
|
429
|
+
* with the subscription. This parameter is required if the cart contains a subscription.
|
428
430
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
429
431
|
*/
|
430
|
-
TplBooking.prototype.updateBuyerPassengersDetails = function (buyerDetails) {
|
432
|
+
TplBooking.prototype.updateBuyerPassengersDetails = function (buyerDetails, subscriptionPersonCode) {
|
431
433
|
return __awaiter(this, void 0, void 0, function () {
|
432
434
|
var buyerPassengersDetails, request, url;
|
433
435
|
var _this = this;
|
@@ -436,13 +438,23 @@ var TplBooking = /** @class */ (function (_super) {
|
|
436
438
|
if (!this.cart) {
|
437
439
|
throw Error("Cart is not initialized yet");
|
438
440
|
}
|
441
|
+
if (this.cart.bookings.some(function (b) { return b.info.isSubscription && b.type === TplBooking.BookingTypes.TPL; }) &&
|
442
|
+
!subscriptionPersonCode) {
|
443
|
+
throw Error("The subscriptionPersonCode is required when updating a subscription");
|
444
|
+
}
|
439
445
|
buyerPassengersDetails = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.BUYER_PASSENGERS);
|
440
446
|
if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
|
441
447
|
throw Error("The status of the cart does not allow to call this API");
|
442
448
|
}
|
443
449
|
request = {
|
444
450
|
buyer: buyerDetails,
|
445
|
-
passengers:
|
451
|
+
passengers: subscriptionPersonCode
|
452
|
+
? [
|
453
|
+
{
|
454
|
+
personCode: subscriptionPersonCode
|
455
|
+
}
|
456
|
+
]
|
457
|
+
: []
|
446
458
|
};
|
447
459
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cart.id, "/details");
|
448
460
|
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
@@ -2,6 +2,9 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.objectIsMTSErrorResponse = void 0;
|
4
4
|
var objectIsMTSErrorResponse = function (error) {
|
5
|
-
|
5
|
+
if (typeof error !== "object" || error === null) {
|
6
|
+
return false;
|
7
|
+
}
|
8
|
+
return "mtsCode" in error && "httpStatus" in error && "message" in error;
|
6
9
|
};
|
7
10
|
exports.objectIsMTSErrorResponse = objectIsMTSErrorResponse;
|