mts-booking-library 1.2.10 → 1.2.12

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.
@@ -61,9 +61,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
61
61
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
62
  }
63
63
  };
64
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
65
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
66
+ if (ar || !(i in from)) {
67
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
68
+ ar[i] = from[i];
69
+ }
70
+ }
71
+ return to.concat(ar || Array.prototype.slice.call(from));
72
+ };
64
73
  Object.defineProperty(exports, "__esModule", { value: true });
65
74
  exports.JourneyBooking = void 0;
66
75
  var ErrorResponse_1 = require("../types/ErrorResponse");
76
+ var Reduction_1 = require("../types/common/Reduction");
77
+ var processBookingSteps_1 = require("../utils/processBookingSteps");
67
78
  var booking_1 = require("./booking");
68
79
  var JourneyBooking = /** @class */ (function (_super) {
69
80
  __extends(JourneyBooking, _super);
@@ -106,13 +117,7 @@ var JourneyBooking = /** @class */ (function (_super) {
106
117
  _this.cartId = cart.id;
107
118
  _this.bookingDueDate = cartDate; // See Booking class
108
119
  // Fill the booking process status
109
- _this.bookingStepsToStatus = new Map(Object.entries(cart.stepsToStatus).map(function (_a) {
110
- var bookingStep = _a[0], values = _a[1];
111
- return [
112
- bookingStep,
113
- values
114
- ];
115
- }));
120
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
116
121
  _this.createCartTimer(cartDate);
117
122
  }
118
123
  })];
@@ -260,13 +265,7 @@ var JourneyBooking = /** @class */ (function (_super) {
260
265
  // Save the cartId in the localStorage
261
266
  localStorage.setItem("cartId", response.cart.id.toString());
262
267
  // Fill the booking process status
263
- _this.bookingStepsToStatus = new Map(Object.entries(response.cart.stepsToStatus).map(function (_a) {
264
- var bookingStep = _a[0], values = _a[1];
265
- return [
266
- bookingStep,
267
- values
268
- ];
269
- }));
268
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
270
269
  _this.bookingDueDate = new Date(response.cart.bookingDueDate);
271
270
  _this.createCartTimer(new Date(response.cart.bookingDueDate));
272
271
  return response.cart;
@@ -367,11 +366,12 @@ var JourneyBooking = /** @class */ (function (_super) {
367
366
  /**
368
367
  * @description This methosd shall be called when the user wants to update the buyer and the passengers information.
369
368
  * @param {EditPassengersDetailsRequest} passengersDetails The object containing the buyer and the passengers information.
370
- * @returns An {@link ErrorResponse} object in case of error, nothing otherwise.
369
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
371
370
  */
372
371
  JourneyBooking.prototype.updateBuyerPassengersDetails = function (passengersDetails) {
373
372
  return __awaiter(this, void 0, void 0, function () {
374
373
  var buyerPassengersDetails, request, url;
374
+ var _this = this;
375
375
  return __generator(this, function (_a) {
376
376
  // First check that it is possible to call this API
377
377
  if (!this.cart) {
@@ -391,7 +391,12 @@ var JourneyBooking = /** @class */ (function (_super) {
391
391
  });
392
392
  url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/details");
393
393
  return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
394
- return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
394
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
395
+ return response;
396
+ }
397
+ // Update the booking process status
398
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.stepsToStatus);
399
+ return true;
395
400
  })];
396
401
  });
397
402
  });
@@ -456,11 +461,12 @@ var JourneyBooking = /** @class */ (function (_super) {
456
461
  * @description This method shall be called when the user wants to change the assigned seats of a trip.
457
462
  * @param {number} tripId The id of the trip for which the seats should be changed
458
463
  * @param {number[]} newSeatsIds The ids of the new seats, as found the {@link BusMatrix}
459
- * @returns An {@link ErrorResponse} object in case of error, nothing otherwise.
464
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
460
465
  */
461
466
  JourneyBooking.prototype.changeSeatsOfTrip = function (tripId, newSeatsIds) {
462
467
  return __awaiter(this, void 0, void 0, function () {
463
468
  var seatSelectionStatus, url;
469
+ var _this = this;
464
470
  return __generator(this, function (_a) {
465
471
  // First check that it is possible to call this API
466
472
  if (!this.cart) {
@@ -472,11 +478,304 @@ var JourneyBooking = /** @class */ (function (_super) {
472
478
  }
473
479
  url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/seats");
474
480
  return [2 /*return*/, this.callPostApi(url, { tripId: tripId, seatsIds: newSeatsIds }).then(function (response) {
475
- return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
481
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
482
+ return response;
483
+ }
484
+ // Update the booking process status
485
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.stepsToStatus);
486
+ return true;
476
487
  })];
477
488
  });
478
489
  });
479
490
  };
491
+ //#region Reductions APIs
492
+ /**
493
+ * @description This method shall be called when the user wants to retrieve the trips in the cart, for adding a available reduction
494
+ * to a specific trip (rather than to the whole cart).
495
+ * @see {@link Booking.addReduction} for detailed info on how to add a reduction.
496
+ * @returns An {@link ErrorResponse} object in case of error, a list of {@link ReductionTrip} otherwise, representing the trips in the cart.
497
+ */
498
+ JourneyBooking.prototype.getCartTrips = function () {
499
+ return __awaiter(this, void 0, void 0, function () {
500
+ var url;
501
+ return __generator(this, function (_a) {
502
+ // First check that it is possible to call this API
503
+ if (!this.cart) {
504
+ throw Error("Cart is not initialized yet");
505
+ }
506
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/payment/reduction/trips");
507
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
508
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.trips;
509
+ })];
510
+ });
511
+ });
512
+ };
513
+ /**
514
+ * @description This method allows to add a reduction to the whole cart or to a single trip in the cart.
515
+ * @param {AddReductionRequest} request The information about the reduction to add
516
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
517
+ */
518
+ JourneyBooking.prototype.addReduction = function (request) {
519
+ var _a;
520
+ return __awaiter(this, void 0, void 0, function () {
521
+ var discountsStep, _b, _c, _d, _i, step, url;
522
+ var _this = this;
523
+ return __generator(this, function (_e) {
524
+ switch (_e.label) {
525
+ case 0:
526
+ // First check that it is possible to call this API
527
+ if (!this.cartId || this.cartId === 0) {
528
+ throw Error("Cart is not initialized yet");
529
+ }
530
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
531
+ if (!discountsStep)
532
+ throw Error("Booking step not found!");
533
+ if (!!discountsStep[0]) return [3 /*break*/, 5];
534
+ _b = [booking_1.Booking.BookingSteps.SEATS_SELECTION, booking_1.Booking.BookingSteps.EXTRAS];
535
+ _c = [];
536
+ for (_d in _b)
537
+ _c.push(_d);
538
+ _i = 0;
539
+ _e.label = 1;
540
+ case 1:
541
+ if (!(_i < _c.length)) return [3 /*break*/, 4];
542
+ _d = _c[_i];
543
+ if (!(_d in _b)) return [3 /*break*/, 3];
544
+ step = _d;
545
+ if (!!((_a = this.bookingStepsToStatus.get(step)) !== null && _a !== void 0 ? _a : [false])[0]) return [3 /*break*/, 3];
546
+ return [4 /*yield*/, this.markBookingStepCompleted(step)];
547
+ case 2:
548
+ _e.sent();
549
+ _e.label = 3;
550
+ case 3:
551
+ _i++;
552
+ return [3 /*break*/, 1];
553
+ case 4:
554
+ // Check again if the discounts step is accessible
555
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
556
+ if (!discountsStep || !discountsStep[0]) {
557
+ throw Error("The status of the cart does not allow to call this API");
558
+ }
559
+ _e.label = 5;
560
+ case 5:
561
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cartId, "/payment/reduction");
562
+ return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
563
+ var _a, _b;
564
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
565
+ return response;
566
+ }
567
+ var reductionResponse = response;
568
+ // Update the booking process status
569
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(reductionResponse.stepsToStatus);
570
+ // Update the cart
571
+ _this.cart = __assign(__assign({}, _this.cart), { totalAmountToPay: reductionResponse.totalAmountToPay, reductions: __spreadArray(__spreadArray([], ((_b = (_a = _this.cart) === null || _a === void 0 ? void 0 : _a.reductions) !== null && _b !== void 0 ? _b : []), true), [reductionResponse.reduction], false) });
572
+ return true;
573
+ })];
574
+ }
575
+ });
576
+ });
577
+ };
578
+ /**
579
+ * @description This method allows to remove a reduction from the whole cart or from a single trip in the cart.
580
+ * @param tripId The id of the trip from which the reduction should be removed. If the tripId is 0, then the reduction
581
+ * will be removed from the whole cart.
582
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
583
+ */
584
+ JourneyBooking.prototype.removeReduction = function (tripId) {
585
+ return __awaiter(this, void 0, void 0, function () {
586
+ var discountsStep, queryParams, url;
587
+ var _this = this;
588
+ return __generator(this, function (_a) {
589
+ // First check that it is possible to call this API
590
+ if (!this.cartId || this.cartId === 0) {
591
+ throw Error("Cart is not initialized yet");
592
+ }
593
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
594
+ if (!discountsStep || !discountsStep[0]) {
595
+ throw Error("The status of the cart does not allow to call this API");
596
+ }
597
+ queryParams = new URLSearchParams({ tripId: tripId.toString() });
598
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cartId, "/payment/reduction?").concat(queryParams);
599
+ return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
600
+ var _a, _b, _c;
601
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
602
+ return response;
603
+ }
604
+ var reductionResponse = response;
605
+ // Update the booking process status
606
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(reductionResponse.stepsToStatus);
607
+ // Update the cart
608
+ _this.cart = __assign(__assign({}, _this.cart), { totalAmountToPay: reductionResponse.totalAmountToPay, reductions: (_c = (_b = (_a = _this.cart) === null || _a === void 0 ? void 0 : _a.reductions) === null || _b === void 0 ? void 0 : _b.filter(function (reduction) { return reduction.type === Reduction_1.ReductionType.WALLET ||
609
+ reduction.type === Reduction_1.ReductionType.VOUCHER ||
610
+ (reduction.type === Reduction_1.ReductionType.CASH && reduction.tripId !== tripId); })) !== null && _c !== void 0 ? _c : [] });
611
+ return true;
612
+ })];
613
+ });
614
+ });
615
+ };
616
+ /**
617
+ * @description This method allows the user to use the balance in his wallet to pay the cart. If the balance of
618
+ * the wallet is enough to pay the cart, the cart will be paid fully. Otherwise, the user will be asked to pay the
619
+ * remaining amount with another payment method.
620
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
621
+ */
622
+ JourneyBooking.prototype.useWallet = function () {
623
+ var _a;
624
+ return __awaiter(this, void 0, void 0, function () {
625
+ var discountsStep, _b, _c, _d, _i, step, url;
626
+ var _this = this;
627
+ return __generator(this, function (_e) {
628
+ switch (_e.label) {
629
+ case 0:
630
+ // First check that it is possible to call this API
631
+ if (!this.cartId || this.cartId === 0) {
632
+ throw Error("Cart is not initialized yet");
633
+ }
634
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
635
+ if (!discountsStep)
636
+ throw Error("Booking step not found!");
637
+ if (!!discountsStep[0]) return [3 /*break*/, 5];
638
+ _b = [booking_1.Booking.BookingSteps.SEATS_SELECTION, booking_1.Booking.BookingSteps.EXTRAS];
639
+ _c = [];
640
+ for (_d in _b)
641
+ _c.push(_d);
642
+ _i = 0;
643
+ _e.label = 1;
644
+ case 1:
645
+ if (!(_i < _c.length)) return [3 /*break*/, 4];
646
+ _d = _c[_i];
647
+ if (!(_d in _b)) return [3 /*break*/, 3];
648
+ step = _d;
649
+ if (!!((_a = this.bookingStepsToStatus.get(step)) !== null && _a !== void 0 ? _a : [false])[0]) return [3 /*break*/, 3];
650
+ return [4 /*yield*/, this.markBookingStepCompleted(step)];
651
+ case 2:
652
+ _e.sent();
653
+ _e.label = 3;
654
+ case 3:
655
+ _i++;
656
+ return [3 /*break*/, 1];
657
+ case 4:
658
+ // Check again if the discounts step is accessible
659
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
660
+ if (!discountsStep || !discountsStep[0]) {
661
+ throw Error("The status of the cart does not allow to call this API");
662
+ }
663
+ _e.label = 5;
664
+ case 5:
665
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cartId, "/payment/wallet");
666
+ return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
667
+ var _a, _b;
668
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
669
+ return response;
670
+ }
671
+ var reductionResponse = response;
672
+ // Update the booking process status
673
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(reductionResponse.stepsToStatus);
674
+ // Update the cart
675
+ _this.cart = __assign(__assign({}, _this.cart), { totalAmountToPay: reductionResponse.totalAmountToPay, reductions: __spreadArray(__spreadArray([], ((_b = (_a = _this.cart) === null || _a === void 0 ? void 0 : _a.reductions) !== null && _b !== void 0 ? _b : []), true), [reductionResponse.reduction], false) });
676
+ return true;
677
+ })];
678
+ }
679
+ });
680
+ });
681
+ };
682
+ /**
683
+ * @description This method allows to remove a waller reduction from the cart.
684
+ *
685
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
686
+ */
687
+ JourneyBooking.prototype.removeWalletReduction = function () {
688
+ return __awaiter(this, void 0, void 0, function () {
689
+ var url;
690
+ var _this = this;
691
+ return __generator(this, function (_a) {
692
+ // First check that it is possible to call this API
693
+ if (!this.cartId || this.cartId === 0) {
694
+ throw Error("Cart is not initialized yet");
695
+ }
696
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cartId, "/payment/wallet");
697
+ return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
698
+ var _a, _b, _c;
699
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
700
+ return response;
701
+ }
702
+ var reductionResponse = response;
703
+ // Update the booking process status
704
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(reductionResponse.stepsToStatus);
705
+ // Update the cart
706
+ _this.cart = __assign(__assign({}, _this.cart), { totalAmountToPay: reductionResponse.totalAmountToPay, reductions: (_c = (_b = (_a = _this.cart) === null || _a === void 0 ? void 0 : _a.reductions) === null || _b === void 0 ? void 0 : _b.filter(function (reduction) { return reduction.type !== Reduction_1.ReductionType.WALLET; })) !== null && _c !== void 0 ? _c : [] });
707
+ return true;
708
+ })];
709
+ });
710
+ });
711
+ };
712
+ /**
713
+ * @description This method allows the user to use a voucher to pay the cart.
714
+ * If the balance of the value of the voucher is enough to pay the cart, the cart will be paid fully.
715
+ * Otherwise, the user will be asked to pay the remaining amount with another payment method.
716
+ * @param {string} voucherCode The code of the voucher to use
717
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
718
+ */
719
+ JourneyBooking.prototype.useVoucher = function (voucherCode) {
720
+ var _a;
721
+ return __awaiter(this, void 0, void 0, function () {
722
+ var discountsStep, _b, _c, _d, _i, step, url;
723
+ var _this = this;
724
+ return __generator(this, function (_e) {
725
+ switch (_e.label) {
726
+ case 0:
727
+ // First check that it is possible to call this API
728
+ if (!this.cartId || this.cartId === 0) {
729
+ throw Error("Cart is not initialized yet");
730
+ }
731
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
732
+ if (!discountsStep)
733
+ throw Error("Booking step not found!");
734
+ if (!!discountsStep[0]) return [3 /*break*/, 5];
735
+ _b = [booking_1.Booking.BookingSteps.SEATS_SELECTION, booking_1.Booking.BookingSteps.EXTRAS];
736
+ _c = [];
737
+ for (_d in _b)
738
+ _c.push(_d);
739
+ _i = 0;
740
+ _e.label = 1;
741
+ case 1:
742
+ if (!(_i < _c.length)) return [3 /*break*/, 4];
743
+ _d = _c[_i];
744
+ if (!(_d in _b)) return [3 /*break*/, 3];
745
+ step = _d;
746
+ if (!!((_a = this.bookingStepsToStatus.get(step)) !== null && _a !== void 0 ? _a : [false])[0]) return [3 /*break*/, 3];
747
+ return [4 /*yield*/, this.markBookingStepCompleted(step)];
748
+ case 2:
749
+ _e.sent();
750
+ _e.label = 3;
751
+ case 3:
752
+ _i++;
753
+ return [3 /*break*/, 1];
754
+ case 4:
755
+ // Check again if the discounts step is accessible
756
+ discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
757
+ if (!discountsStep || !discountsStep[0]) {
758
+ throw Error("The status of the cart does not allow to call this API");
759
+ }
760
+ _e.label = 5;
761
+ case 5:
762
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cartId, "/payment/voucher");
763
+ return [2 /*return*/, this.callPostApi(url, { voucherCode: voucherCode }).then(function (response) {
764
+ var _a, _b;
765
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
766
+ return response;
767
+ }
768
+ var reductionResponse = response;
769
+ // Update the booking process status
770
+ _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(reductionResponse.stepsToStatus);
771
+ // Update the cart
772
+ _this.cart = __assign(__assign({}, _this.cart), { totalAmountToPay: reductionResponse.totalAmountToPay, reductions: __spreadArray(__spreadArray([], ((_b = (_a = _this.cart) === null || _a === void 0 ? void 0 : _a.reductions) !== null && _b !== void 0 ? _b : []), true), [reductionResponse.reduction], false) });
773
+ return true;
774
+ })];
775
+ }
776
+ });
777
+ });
778
+ };
480
779
  return JourneyBooking;
481
780
  }(booking_1.Booking));
482
781
  exports.JourneyBooking = JourneyBooking;
@@ -1,6 +1,7 @@
1
1
  import { MTSEnvs } from "../config";
2
2
  import { ErrorResponse } from "../types/ErrorResponse";
3
3
  import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
4
+ import { AddReductionRequest } from "../types/common/Reduction";
4
5
  import { Service, ServiceTrip } from "../types/services/Service";
5
6
  import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
6
7
  import { Booking } from "./booking";
@@ -71,9 +72,43 @@ export declare class ServiceBooking extends Booking {
71
72
  /**
72
73
  * @description This method shall be called when the user wants to update the buyer information.
73
74
  * @param {Person} buyerDetails The object containing the buyer information.
74
- * @returns An {@link ErrorResponse} object in case of error, nothing otherwise.
75
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
75
76
  */
76
- updateBuyerPassengersDetails(buyerDetails: Person): Promise<ErrorResponse | any>;
77
+ updateBuyerPassengersDetails(buyerDetails: Person): Promise<ErrorResponse | boolean>;
78
+ /**
79
+ * @description This method allows to add a reduction to the whole cart or to a single trip in the cart.
80
+ * @param {AddReductionRequest} request The information about the reduction to add
81
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
82
+ */
83
+ addReduction(request: AddReductionRequest): Promise<ErrorResponse | boolean>;
84
+ /**
85
+ * @description This method allows to remove a reduction from the whole cart or from a single trip in the cart.
86
+ * @param tripId The id of the trip from which the reduction should be removed. If the tripId is 0, then the reduction
87
+ * will be removed from the whole cart.
88
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
89
+ */
90
+ removeReduction(tripId: number): Promise<ErrorResponse | boolean>;
91
+ /**
92
+ * @description This method allows the user to use the balance in his wallet to pay the cart. If the balance of
93
+ * the wallet is enough to pay the cart, the cart will be paid fully. Otherwise, the user will be asked to pay the
94
+ * remaining amount with another payment method.
95
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
96
+ */
97
+ useWallet(): Promise<ErrorResponse | boolean>;
98
+ /**
99
+ * @description This method allows to remove a waller reduction from the cart.
100
+ *
101
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
102
+ */
103
+ removeWalletReduction(): Promise<ErrorResponse | boolean>;
104
+ /**
105
+ * @description This method allows the user to use a voucher to pay the cart.
106
+ * If the balance of the value of the voucher is enough to pay the cart, the cart will be paid fully.
107
+ * Otherwise, the user will be asked to pay the remaining amount with another payment method.
108
+ * @param {string} voucherCode The code of the voucher to use
109
+ * @returns An {@link ErrorResponse} object in case of error, true otherwise.
110
+ */
111
+ useVoucher(voucherCode: string): Promise<ErrorResponse | boolean>;
77
112
  }
78
113
  export declare namespace ServiceBooking {
79
114
  const createBooking: (env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug: boolean, language: string, access_token?: string, sellerId?: number, resellerId?: number) => Promise<ServiceBooking>;