mts-booking-library 1.3.23 → 1.3.25
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/booking/booking.d.ts +3 -3
- package/lib/booking/booking.js +10 -8
- package/lib/booking/journeyBooking.js +16 -13
- package/lib/booking/serviceBooking.js +15 -13
- package/lib/booking/subscriptionBooking.js +15 -13
- package/lib/booking/tplBooking.js +16 -13
- package/lib/index.d.ts +1 -1
- package/lib/mtsStorage.js +3 -1
- package/lib/types/common/Payment.d.ts +12 -9
- package/lib/types/common/Payment.js +11 -8
- package/lib/types/journeys/JourneyCart.d.ts +8 -8
- package/lib/types/services/ServiceCart.d.ts +10 -10
- package/lib/utils/apiCall.js +21 -12
- package/package.json +5 -5
package/lib/booking/booking.d.ts
CHANGED
@@ -20,7 +20,7 @@ export declare abstract class Booking {
|
|
20
20
|
* - The third tells whether the section is required. <br/>
|
21
21
|
*/
|
22
22
|
bookingStepsToStatus: processedStepsToStatus;
|
23
|
-
/** @deprecated Please use {@link
|
23
|
+
/** @deprecated Please use {@link cartGuid} instead */
|
24
24
|
cartId: number | undefined;
|
25
25
|
cartGuid: string | undefined;
|
26
26
|
bookingDueDate: Date | undefined;
|
@@ -69,8 +69,8 @@ export declare abstract class Booking {
|
|
69
69
|
getSellerGateways(): Promise<ErrorResponse | GetSellerGatewaysResponse>;
|
70
70
|
/**
|
71
71
|
* @description This method shall be used to get all necessary informations to initialize a payment with a certain gateway.
|
72
|
-
* @param
|
73
|
-
* @param
|
72
|
+
* @param gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
|
73
|
+
* @param returnUrl The url to which the user will be redirected after the payment. This value shall be set only if the
|
74
74
|
* chosen gateway is {@link GatewayTypes.PAYPAL} or {@link GatewayTypes.WORLDLINE}
|
75
75
|
* @returns An {@link ErrorResponse} object in case of error, a {@link GetPaymentInformationFromGatewayResponse} object otherwise.
|
76
76
|
*/
|
package/lib/booking/booking.js
CHANGED
@@ -53,6 +53,7 @@ var ErrorResponse_1 = require("../types/ErrorResponse");
|
|
53
53
|
var Payment_1 = require("../types/common/Payment");
|
54
54
|
var apiCall_1 = require("../utils/apiCall");
|
55
55
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
56
|
+
var utils_1 = require("../utils/utils");
|
56
57
|
var Booking = /** @class */ (function () {
|
57
58
|
/**
|
58
59
|
* This is the constructor of the Booking class. See {@link Booking.BookingConfig} for more information.
|
@@ -160,7 +161,7 @@ var Booking = /** @class */ (function () {
|
|
160
161
|
var _this = this;
|
161
162
|
return __generator(this, function (_a) {
|
162
163
|
// First check that it is possible to call this API
|
163
|
-
if (
|
164
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
164
165
|
throw Error("Cart is not initialized yet");
|
165
166
|
}
|
166
167
|
currentStepStatus = this.bookingStepsToStatus.get(bookingStep);
|
@@ -174,7 +175,7 @@ var Booking = /** @class */ (function () {
|
|
174
175
|
// Booking step is already completed, no need to call the API
|
175
176
|
if (currentStepStatus[0])
|
176
177
|
return [2 /*return*/, true];
|
177
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
178
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/bookingSteps");
|
178
179
|
return [2 /*return*/, this.callPostApi(url, { bookingStep: bookingStep }).then(function (response) {
|
179
180
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
180
181
|
return response;
|
@@ -200,7 +201,7 @@ var Booking = /** @class */ (function () {
|
|
200
201
|
switch (_c.label) {
|
201
202
|
case 0:
|
202
203
|
// First check that it is possible to call this API
|
203
|
-
if (!this.
|
204
|
+
if (!this.cartGuid || (0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
204
205
|
throw Error("Cart is not initialized yet");
|
205
206
|
}
|
206
207
|
issueStep = this.bookingStepsToStatus.get(Booking.BookingSteps.ISSUE);
|
@@ -245,8 +246,8 @@ var Booking = /** @class */ (function () {
|
|
245
246
|
};
|
246
247
|
/**
|
247
248
|
* @description This method shall be used to get all necessary informations to initialize a payment with a certain gateway.
|
248
|
-
* @param
|
249
|
-
* @param
|
249
|
+
* @param gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
|
250
|
+
* @param returnUrl The url to which the user will be redirected after the payment. This value shall be set only if the
|
250
251
|
* chosen gateway is {@link GatewayTypes.PAYPAL} or {@link GatewayTypes.WORLDLINE}
|
251
252
|
* @returns An {@link ErrorResponse} object in case of error, a {@link GetPaymentInformationFromGatewayResponse} object otherwise.
|
252
253
|
*/
|
@@ -255,15 +256,15 @@ var Booking = /** @class */ (function () {
|
|
255
256
|
var issueStep, searchParams, url;
|
256
257
|
return __generator(this, function (_a) {
|
257
258
|
// First check that it is possible to call this API
|
258
|
-
if (
|
259
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
259
260
|
throw Error("Cart is not initialized yet");
|
260
261
|
}
|
261
262
|
issueStep = this.bookingStepsToStatus.get(Booking.BookingSteps.ISSUE);
|
262
263
|
if (!issueStep || !issueStep[0]) {
|
263
264
|
throw Error("The status of the cart does not allow to call this API");
|
264
265
|
}
|
265
|
-
searchParams = new URLSearchParams(__assign({ gatewayId: gatewayId.toString() }, (returnUrl && { returnUrl: returnUrl })));
|
266
|
-
url = "".concat(this.config.API_ENDPOINT, "/
|
266
|
+
searchParams = new URLSearchParams(__assign({ gatewayId: gatewayId.toString(), cartGuid: this.cartGuid }, (returnUrl && { returnUrl: returnUrl })));
|
267
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_payment/paymentInformation?").concat(searchParams);
|
267
268
|
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
268
269
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
269
270
|
? response
|
@@ -272,6 +273,7 @@ var Booking = /** @class */ (function () {
|
|
272
273
|
});
|
273
274
|
});
|
274
275
|
};
|
276
|
+
// TODO: Rename this as issueCart
|
275
277
|
/**
|
276
278
|
* @description This method shall be used to issue the tickets. It must be called after the payment was successful.
|
277
279
|
* @param {PaymentMethods} paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
|
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
|
|
77
77
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
78
78
|
var Reduction_1 = require("../types/common/Reduction");
|
79
79
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
80
|
+
var utils_1 = require("../utils/utils");
|
80
81
|
var booking_1 = require("./booking");
|
81
82
|
var JourneyBooking = /** @class */ (function (_super) {
|
82
83
|
__extends(JourneyBooking, _super);
|
@@ -354,6 +355,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
354
355
|
});
|
355
356
|
});
|
356
357
|
};
|
358
|
+
// TODO: rename this as getPerson and use personDetails as return type
|
357
359
|
/**
|
358
360
|
* @description This method shall be called when the user wants to retrieve information about an esisting buyer.
|
359
361
|
* @param {GetBuyerRequest} request The object containing the parameters to search the buyer.
|
@@ -562,7 +564,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
562
564
|
switch (_c.label) {
|
563
565
|
case 0:
|
564
566
|
// First check that it is possible to call this API
|
565
|
-
if (
|
567
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
566
568
|
throw Error("Cart is not initialized yet");
|
567
569
|
}
|
568
570
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
@@ -590,8 +592,8 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
590
592
|
}
|
591
593
|
_c.label = 5;
|
592
594
|
case 5:
|
593
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
594
|
-
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
595
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
|
596
|
+
return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
|
595
597
|
var _a, _b;
|
596
598
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
597
599
|
return response;
|
@@ -619,15 +621,15 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
619
621
|
var _this = this;
|
620
622
|
return __generator(this, function (_a) {
|
621
623
|
// First check that it is possible to call this API
|
622
|
-
if (
|
624
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
623
625
|
throw Error("Cart is not initialized yet");
|
624
626
|
}
|
625
627
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
626
628
|
if (!discountsStep || !discountsStep[0]) {
|
627
629
|
throw Error("The status of the cart does not allow to call this API");
|
628
630
|
}
|
629
|
-
queryParams = new URLSearchParams({ tripId: tripId.toString() });
|
630
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
631
|
+
queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
632
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
|
631
633
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
632
634
|
var _a, _b, _c;
|
633
635
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -662,7 +664,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
662
664
|
switch (_c.label) {
|
663
665
|
case 0:
|
664
666
|
// First check that it is possible to call this API
|
665
|
-
if (
|
667
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
666
668
|
throw Error("Cart is not initialized yet");
|
667
669
|
}
|
668
670
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
@@ -690,12 +692,12 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
690
692
|
// Check again if the discounts step is accessible
|
691
693
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
692
694
|
if (!issueStep || !issueStep[0]) {
|
693
|
-
throw Error("The status of the cart does not allow to call the API: booking/carts/
|
695
|
+
throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
|
694
696
|
}
|
695
697
|
_c.label = 5;
|
696
698
|
case 5:
|
697
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
698
|
-
return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
|
699
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
|
700
|
+
return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
|
699
701
|
var _a, _b;
|
700
702
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
701
703
|
return response;
|
@@ -718,14 +720,15 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
718
720
|
*/
|
719
721
|
JourneyBooking.prototype.removeWalletReduction = function () {
|
720
722
|
return __awaiter(this, void 0, void 0, function () {
|
721
|
-
var url;
|
723
|
+
var queryParams, url;
|
722
724
|
var _this = this;
|
723
725
|
return __generator(this, function (_a) {
|
724
726
|
// First check that it is possible to call this API
|
725
|
-
if (
|
727
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
726
728
|
throw Error("Cart is not initialized yet");
|
727
729
|
}
|
728
|
-
|
730
|
+
queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
731
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
|
729
732
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
730
733
|
var _a, _b, _c;
|
731
734
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
|
|
77
77
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
78
78
|
var Reduction_1 = require("../types/common/Reduction");
|
79
79
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
80
|
+
var utils_1 = require("../utils/utils");
|
80
81
|
var booking_1 = require("./booking");
|
81
82
|
var ServiceBooking = /** @class */ (function (_super) {
|
82
83
|
__extends(ServiceBooking, _super);
|
@@ -419,7 +420,7 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
419
420
|
switch (_c.label) {
|
420
421
|
case 0:
|
421
422
|
// First check that it is possible to call this API
|
422
|
-
if (
|
423
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
423
424
|
throw Error("Cart is not initialized yet");
|
424
425
|
}
|
425
426
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
@@ -447,8 +448,8 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
447
448
|
}
|
448
449
|
_c.label = 5;
|
449
450
|
case 5:
|
450
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
451
|
-
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
451
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
|
452
|
+
return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
|
452
453
|
var _a, _b;
|
453
454
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
454
455
|
return response;
|
@@ -476,15 +477,15 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
476
477
|
var _this = this;
|
477
478
|
return __generator(this, function (_a) {
|
478
479
|
// First check that it is possible to call this API
|
479
|
-
if (
|
480
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
480
481
|
throw Error("Cart is not initialized yet");
|
481
482
|
}
|
482
483
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
483
484
|
if (!discountsStep || !discountsStep[0]) {
|
484
485
|
throw Error("The status of the cart does not allow to call this API");
|
485
486
|
}
|
486
|
-
queryParams = new URLSearchParams({ tripId: tripId.toString() });
|
487
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
487
|
+
queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
488
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
|
488
489
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
489
490
|
var _a, _b, _c;
|
490
491
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -519,7 +520,7 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
519
520
|
switch (_c.label) {
|
520
521
|
case 0:
|
521
522
|
// First check that it is possible to call this API
|
522
|
-
if (
|
523
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
523
524
|
throw Error("Cart is not initialized yet");
|
524
525
|
}
|
525
526
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
@@ -547,12 +548,12 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
547
548
|
// Check again if the discounts step is accessible
|
548
549
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
549
550
|
if (!issueStep || !issueStep[0]) {
|
550
|
-
throw Error("The status of the cart does not allow to call the API: booking/carts/
|
551
|
+
throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
|
551
552
|
}
|
552
553
|
_c.label = 5;
|
553
554
|
case 5:
|
554
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
555
|
-
return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
|
555
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
|
556
|
+
return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
|
556
557
|
var _a, _b;
|
557
558
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
558
559
|
return response;
|
@@ -575,14 +576,15 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
575
576
|
*/
|
576
577
|
ServiceBooking.prototype.removeWalletReduction = function () {
|
577
578
|
return __awaiter(this, void 0, void 0, function () {
|
578
|
-
var url;
|
579
|
+
var queryParams, url;
|
579
580
|
var _this = this;
|
580
581
|
return __generator(this, function (_a) {
|
581
582
|
// First check that it is possible to call this API
|
582
|
-
if (
|
583
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
583
584
|
throw Error("Cart is not initialized yet");
|
584
585
|
}
|
585
|
-
|
586
|
+
queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
587
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
|
586
588
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
587
589
|
var _a, _b, _c;
|
588
590
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
|
|
77
77
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
78
78
|
var Reduction_1 = require("../types/common/Reduction");
|
79
79
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
80
|
+
var utils_1 = require("../utils/utils");
|
80
81
|
var booking_1 = require("./booking");
|
81
82
|
var SubscriptionBooking = /** @class */ (function (_super) {
|
82
83
|
__extends(SubscriptionBooking, _super);
|
@@ -499,7 +500,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
499
500
|
switch (_c.label) {
|
500
501
|
case 0:
|
501
502
|
// First check that it is possible to call this API
|
502
|
-
if (
|
503
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
503
504
|
throw Error("Cart is not initialized yet");
|
504
505
|
}
|
505
506
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
@@ -527,8 +528,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
527
528
|
}
|
528
529
|
_c.label = 5;
|
529
530
|
case 5:
|
530
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
531
|
-
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
531
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
|
532
|
+
return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
|
532
533
|
var _a, _b;
|
533
534
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
534
535
|
return response;
|
@@ -556,15 +557,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
556
557
|
var _this = this;
|
557
558
|
return __generator(this, function (_a) {
|
558
559
|
// First check that it is possible to call this API
|
559
|
-
if (
|
560
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
560
561
|
throw Error("Cart is not initialized yet");
|
561
562
|
}
|
562
563
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
563
564
|
if (!discountsStep || !discountsStep[0]) {
|
564
565
|
throw Error("The status of the cart does not allow to call this API");
|
565
566
|
}
|
566
|
-
queryParams = new URLSearchParams({ tripId: tripId.toString() });
|
567
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
567
|
+
queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
568
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
|
568
569
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
569
570
|
var _a, _b, _c;
|
570
571
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -599,7 +600,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
599
600
|
switch (_c.label) {
|
600
601
|
case 0:
|
601
602
|
// First check that it is possible to call this API
|
602
|
-
if (
|
603
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
603
604
|
throw Error("Cart is not initialized yet");
|
604
605
|
}
|
605
606
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
@@ -627,12 +628,12 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
627
628
|
// Check again if the discounts step is accessible
|
628
629
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
629
630
|
if (!issueStep || !issueStep[0]) {
|
630
|
-
throw Error("The status of the cart does not allow to call the API: booking/carts/
|
631
|
+
throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
|
631
632
|
}
|
632
633
|
_c.label = 5;
|
633
634
|
case 5:
|
634
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
635
|
-
return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
|
635
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
|
636
|
+
return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
|
636
637
|
var _a, _b;
|
637
638
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
638
639
|
return response;
|
@@ -655,14 +656,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
655
656
|
*/
|
656
657
|
SubscriptionBooking.prototype.removeWalletReduction = function () {
|
657
658
|
return __awaiter(this, void 0, void 0, function () {
|
658
|
-
var url;
|
659
|
+
var queryParams, url;
|
659
660
|
var _this = this;
|
660
661
|
return __generator(this, function (_a) {
|
661
662
|
// First check that it is possible to call this API
|
662
|
-
if (
|
663
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
663
664
|
throw Error("Cart is not initialized yet");
|
664
665
|
}
|
665
|
-
|
666
|
+
queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
667
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
|
666
668
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
667
669
|
var _a, _b, _c;
|
668
670
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
|
|
77
77
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
78
78
|
var Reduction_1 = require("../types/common/Reduction");
|
79
79
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
80
|
+
var utils_1 = require("../utils/utils");
|
80
81
|
var booking_1 = require("./booking");
|
81
82
|
var TplBooking = /** @class */ (function (_super) {
|
82
83
|
__extends(TplBooking, _super);
|
@@ -226,6 +227,7 @@ var TplBooking = /** @class */ (function (_super) {
|
|
226
227
|
});
|
227
228
|
});
|
228
229
|
};
|
230
|
+
// TODO: use v3_resources/superAreas
|
229
231
|
/**
|
230
232
|
* This method fetches the list of super areas for a given city. A super area is a region of the city in which
|
231
233
|
* the TPL service is available at a certain price.
|
@@ -491,7 +493,7 @@ var TplBooking = /** @class */ (function (_super) {
|
|
491
493
|
switch (_c.label) {
|
492
494
|
case 0:
|
493
495
|
// First check that it is possible to call this API
|
494
|
-
if (
|
496
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
495
497
|
throw Error("Cart is not initialized yet");
|
496
498
|
}
|
497
499
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
@@ -519,8 +521,8 @@ var TplBooking = /** @class */ (function (_super) {
|
|
519
521
|
}
|
520
522
|
_c.label = 5;
|
521
523
|
case 5:
|
522
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
523
|
-
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
524
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
|
525
|
+
return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
|
524
526
|
var _a, _b;
|
525
527
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
526
528
|
return response;
|
@@ -548,15 +550,15 @@ var TplBooking = /** @class */ (function (_super) {
|
|
548
550
|
var _this = this;
|
549
551
|
return __generator(this, function (_a) {
|
550
552
|
// First check that it is possible to call this API
|
551
|
-
if (
|
553
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
552
554
|
throw Error("Cart is not initialized yet");
|
553
555
|
}
|
554
556
|
discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
|
555
557
|
if (!discountsStep || !discountsStep[0]) {
|
556
558
|
throw Error("The status of the cart does not allow to call this API");
|
557
559
|
}
|
558
|
-
queryParams = new URLSearchParams({ tripId: tripId.toString() });
|
559
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
560
|
+
queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
561
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
|
560
562
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
561
563
|
var _a, _b, _c;
|
562
564
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
@@ -591,7 +593,7 @@ var TplBooking = /** @class */ (function (_super) {
|
|
591
593
|
switch (_c.label) {
|
592
594
|
case 0:
|
593
595
|
// First check that it is possible to call this API
|
594
|
-
if (
|
596
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
595
597
|
throw Error("Cart is not initialized yet");
|
596
598
|
}
|
597
599
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
@@ -619,12 +621,12 @@ var TplBooking = /** @class */ (function (_super) {
|
|
619
621
|
// Check again if the discounts step is accessible
|
620
622
|
issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
|
621
623
|
if (!issueStep || !issueStep[0]) {
|
622
|
-
throw Error("The status of the cart does not allow to call the API: booking/carts/
|
624
|
+
throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
|
623
625
|
}
|
624
626
|
_c.label = 5;
|
625
627
|
case 5:
|
626
|
-
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/
|
627
|
-
return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
|
628
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
|
629
|
+
return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
|
628
630
|
var _a, _b;
|
629
631
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
630
632
|
return response;
|
@@ -647,14 +649,15 @@ var TplBooking = /** @class */ (function (_super) {
|
|
647
649
|
*/
|
648
650
|
TplBooking.prototype.removeWalletReduction = function () {
|
649
651
|
return __awaiter(this, void 0, void 0, function () {
|
650
|
-
var url;
|
652
|
+
var queryParams, url;
|
651
653
|
var _this = this;
|
652
654
|
return __generator(this, function (_a) {
|
653
655
|
// First check that it is possible to call this API
|
654
|
-
if (
|
656
|
+
if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
|
655
657
|
throw Error("Cart is not initialized yet");
|
656
658
|
}
|
657
|
-
|
659
|
+
queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
|
660
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
|
658
661
|
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
659
662
|
var _a, _b, _c;
|
660
663
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
package/lib/index.d.ts
CHANGED
@@ -4,7 +4,7 @@ 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 { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
|
7
|
+
export { Person, Buyer, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
|
8
8
|
export { GetBuyerPassengersDetailsResponse, GetBuyerRequest, GetPassenger, BuyerDataStatus, EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
|
9
9
|
export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
|
10
10
|
export { Reduction, AddReductionRequest } from "./types/common/Reduction";
|
package/lib/mtsStorage.js
CHANGED
@@ -19,7 +19,9 @@ var INITIAL_STATE = {
|
|
19
19
|
cartId: 0,
|
20
20
|
cartGuid: undefined
|
21
21
|
};
|
22
|
-
var useMtsBookingAsyncState = (0, zustand_1.create)((0, middleware_1.persist)(function (set) { return (__assign(__assign({}, INITIAL_STATE), { updateCartId: function (cartId
|
22
|
+
var useMtsBookingAsyncState = (0, zustand_1.create)((0, middleware_1.persist)(function (set) { return (__assign(__assign({}, INITIAL_STATE), { updateCartId: function (cartId, cartGuid) {
|
23
|
+
return set(function () { return ({ cartId: cartId, cartGuid: cartGuid }); });
|
24
|
+
}, resetState: function () { return set(function () { return INITIAL_STATE; }); } })); }, {
|
23
25
|
name: "mts-booking-storage",
|
24
26
|
storage: (0, middleware_1.createJSONStorage)(function () { return async_storage_1.default; })
|
25
27
|
}));
|
@@ -54,23 +54,26 @@ export declare enum GatewayTypes {
|
|
54
54
|
PAYPAL = "PAYPAL"
|
55
55
|
}
|
56
56
|
/**
|
57
|
-
*
|
58
|
-
*
|
59
|
-
* @property {string} ZERO_COST: Only for Sellers: 100% discount
|
60
|
-
* @property {string} PAY_LATER: Only for Sellers: Ticket will be paid at the counter/bus
|
61
|
-
* @property {string} WALLET: Only for Resellers: the ticket will be paid with the wallet balance
|
62
|
-
* @property {string} CARD: Pay with card at the Seller/Reseller counter
|
63
|
-
* @property {string} CASH: Pay with cash at the Seller/Reseller counter
|
64
|
-
* @property {string} ONLINE_CARD: Pay online using payment gateways
|
57
|
+
* This enum contains the possible values for the `paymentMethod` parameter of the
|
58
|
+
* {@link Booking.issueTickets} function.
|
65
59
|
*/
|
66
60
|
export declare enum PaymentMethods {
|
61
|
+
/** Pay with card at the Seller/Reseller counter */
|
67
62
|
CARD = "CARD",
|
63
|
+
/** Pay with cash at the Seller/Reseller counter */
|
68
64
|
CASH = "CASH",
|
65
|
+
/** Pay with credit from change*/
|
69
66
|
CREDIT_FROM_CHANGE = "CREDIT_FROM_CHANGE",
|
67
|
+
/** Only for Sellers: Ticket will be paid at the counter/bus */
|
70
68
|
PAY_LATER = "PAY_LATER",
|
69
|
+
/** Pay online using payment gateways */
|
71
70
|
ONLINE_CARD = "ONLINE_CARD",
|
71
|
+
/** Only for Resellers: the ticket will be paid with the wallet balance */
|
72
72
|
WALLET = "WALLET",
|
73
|
-
|
73
|
+
/** Only for Sellers: 100% discount */
|
74
|
+
ZERO_COST = "ZERO_COST",
|
75
|
+
/** Pay with a bank transfer */
|
76
|
+
TRANSFER = "TRANSFER"
|
74
77
|
}
|
75
78
|
export type Wallet = {
|
76
79
|
id: number;
|
@@ -12,22 +12,25 @@ var GatewayTypes;
|
|
12
12
|
GatewayTypes["PAYPAL"] = "PAYPAL";
|
13
13
|
})(GatewayTypes || (exports.GatewayTypes = GatewayTypes = {}));
|
14
14
|
/**
|
15
|
-
*
|
16
|
-
*
|
17
|
-
* @property {string} ZERO_COST: Only for Sellers: 100% discount
|
18
|
-
* @property {string} PAY_LATER: Only for Sellers: Ticket will be paid at the counter/bus
|
19
|
-
* @property {string} WALLET: Only for Resellers: the ticket will be paid with the wallet balance
|
20
|
-
* @property {string} CARD: Pay with card at the Seller/Reseller counter
|
21
|
-
* @property {string} CASH: Pay with cash at the Seller/Reseller counter
|
22
|
-
* @property {string} ONLINE_CARD: Pay online using payment gateways
|
15
|
+
* This enum contains the possible values for the `paymentMethod` parameter of the
|
16
|
+
* {@link Booking.issueTickets} function.
|
23
17
|
*/
|
24
18
|
var PaymentMethods;
|
25
19
|
(function (PaymentMethods) {
|
20
|
+
/** Pay with card at the Seller/Reseller counter */
|
26
21
|
PaymentMethods["CARD"] = "CARD";
|
22
|
+
/** Pay with cash at the Seller/Reseller counter */
|
27
23
|
PaymentMethods["CASH"] = "CASH";
|
24
|
+
/** Pay with credit from change*/
|
28
25
|
PaymentMethods["CREDIT_FROM_CHANGE"] = "CREDIT_FROM_CHANGE";
|
26
|
+
/** Only for Sellers: Ticket will be paid at the counter/bus */
|
29
27
|
PaymentMethods["PAY_LATER"] = "PAY_LATER";
|
28
|
+
/** Pay online using payment gateways */
|
30
29
|
PaymentMethods["ONLINE_CARD"] = "ONLINE_CARD";
|
30
|
+
/** Only for Resellers: the ticket will be paid with the wallet balance */
|
31
31
|
PaymentMethods["WALLET"] = "WALLET";
|
32
|
+
/** Only for Sellers: 100% discount */
|
32
33
|
PaymentMethods["ZERO_COST"] = "ZERO_COST";
|
34
|
+
/** Pay with a bank transfer */
|
35
|
+
PaymentMethods["TRANSFER"] = "TRANSFER";
|
33
36
|
})(PaymentMethods || (exports.PaymentMethods = PaymentMethods = {}));
|
@@ -1,22 +1,22 @@
|
|
1
1
|
import { Booking } from "../../booking/booking";
|
2
2
|
import { Cart } from "../common/Cart";
|
3
|
-
import {
|
3
|
+
import { TariffSummary } from "../common/Tariffs";
|
4
4
|
import { Stop } from "./Stop";
|
5
5
|
import { CartTrip } from "./Trip";
|
6
6
|
/**
|
7
|
-
*
|
7
|
+
* Object containing information about a trip of a selected journey.
|
8
|
+
* This object is part of the {@link CreateJourneyCartRequest} object
|
8
9
|
* and describes a single trip of the journey (either outbound or return).
|
9
|
-
*
|
10
|
-
* @property {number} tripId - The unique identifier for the trip.
|
11
|
-
* @property {number} departureStopId - The unique identifier for the departure stop.
|
12
|
-
* @property {number} destinationStopId - The unique identifier for the destination stop.
|
13
|
-
* @property {TariffsMatrix} tariffsMatrix - The tariff matrix for pricing the outbound journey.
|
14
10
|
*/
|
15
11
|
export type TripBookingInfo = {
|
12
|
+
/** The unique identifier for the trip. */
|
16
13
|
tripId: number;
|
14
|
+
/** The unique identifier for the departure stop. */
|
17
15
|
departureStopId: number;
|
16
|
+
/** The unique identifier for the destination stop. */
|
18
17
|
destinationStopId: number;
|
19
|
-
|
18
|
+
/** A record containing tariff ids as keys and their respective quantities as values. */
|
19
|
+
tariffIdToQuantity: Record<number, number>;
|
20
20
|
};
|
21
21
|
/**
|
22
22
|
* @description This is the object to be passed to `JourneyBooking.createJourneyCart`, containing information about the selected service.
|
@@ -1,23 +1,23 @@
|
|
1
1
|
import { Booking } from "../../booking/booking";
|
2
2
|
import { Cart } from "../common/Cart";
|
3
|
-
import {
|
3
|
+
import { TariffSummary } from "../common/Tariffs";
|
4
4
|
import { ServiceTrip } from "./Service";
|
5
5
|
/**
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* @property {Booking.Currencies} currency - The currency in which the service is priced.
|
9
|
-
* @property {Object} service - Information about the selected service.
|
10
|
-
* @property {number} service.serviceId - The unique identifier for the service.
|
11
|
-
* @property {TariffsMatrix} service.tariffsMatrix - The tariff matrix for pricing the service.
|
12
|
-
* @property {string|undefined} [service.date] - The date for the service in ISO string format (optional).
|
13
|
-
* @property {number|undefined} [service.tripId] - The unique identifier for the trip (optional).
|
6
|
+
* This is the object to be passed to `ServiceBooking.createServiceCart`, containing
|
7
|
+
* information about the selected service.
|
14
8
|
*/
|
15
9
|
export type CreateServiceCartRequest = {
|
10
|
+
/** The currency in which the service is priced. */
|
16
11
|
currency: Booking.Currencies;
|
12
|
+
/** Information about the selected service. */
|
17
13
|
service: {
|
14
|
+
/** The unique identifier for the service. */
|
18
15
|
serviceId: number;
|
19
|
-
|
16
|
+
/** A record containing tariff ids as keys and their respective quantities as values. */
|
17
|
+
tariffIdToQuantity: Record<number, number>;
|
18
|
+
/** The date for the service in ISO string format (optional). */
|
20
19
|
date?: string;
|
20
|
+
/** The unique identifier for the trip (optional). */
|
21
21
|
tripId?: number;
|
22
22
|
};
|
23
23
|
};
|
package/lib/utils/apiCall.js
CHANGED
@@ -81,7 +81,7 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
81
81
|
throw new Error("MTS Library Error! makeGet: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
82
82
|
}
|
83
83
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
84
|
-
var response, filteredResponse, error_1, resError, resError;
|
84
|
+
var response, filteredResponse, error_1, message, resError, resError;
|
85
85
|
var _a, _b, _c, _d, _e, _f, _g;
|
86
86
|
return __generator(this, function (_h) {
|
87
87
|
switch (_h.label) {
|
@@ -101,10 +101,13 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
101
101
|
case 2:
|
102
102
|
error_1 = _h.sent();
|
103
103
|
if (axios_1.default.isAxiosError(error_1)) {
|
104
|
+
message = "error" in ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data)
|
105
|
+
? (_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.message
|
106
|
+
: (_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
104
107
|
resError = {
|
105
|
-
httpStatus: ((
|
106
|
-
mtsCode: ((
|
107
|
-
message:
|
108
|
+
httpStatus: ((_d = error_1.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
|
109
|
+
mtsCode: ((_g = (_f = (_e = error_1.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
|
110
|
+
message: message || "Unknown error"
|
108
111
|
};
|
109
112
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
110
113
|
console.log("GET_ResponseAxiosError", url, resError);
|
@@ -139,7 +142,7 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
139
142
|
throw new Error("MTS Library Error! makePost: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
140
143
|
}
|
141
144
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
142
|
-
var response, filteredResponse, error_2, resError, resError;
|
145
|
+
var response, filteredResponse, error_2, message, resError, resError;
|
143
146
|
var _a, _b, _c, _d, _e, _f, _g;
|
144
147
|
return __generator(this, function (_h) {
|
145
148
|
switch (_h.label) {
|
@@ -159,10 +162,13 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
159
162
|
case 2:
|
160
163
|
error_2 = _h.sent();
|
161
164
|
if (axios_1.default.isAxiosError(error_2)) {
|
165
|
+
message = "error" in ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.data)
|
166
|
+
? (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data.error.message
|
167
|
+
: (_c = error_2.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
162
168
|
resError = {
|
163
|
-
httpStatus: ((
|
164
|
-
mtsCode: ((
|
165
|
-
message:
|
169
|
+
httpStatus: ((_d = error_2.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
|
170
|
+
mtsCode: ((_g = (_f = (_e = error_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
|
171
|
+
message: message || "Unknown error"
|
166
172
|
};
|
167
173
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
168
174
|
console.log("POST_ResponseAxiosError", url, resError);
|
@@ -197,7 +203,7 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
197
203
|
throw new Error("MTS Library Error! makeDelete: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
198
204
|
}
|
199
205
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
200
|
-
var response, filteredResponse, error_3, resError, resError;
|
206
|
+
var response, filteredResponse, error_3, message, resError, resError;
|
201
207
|
var _a, _b, _c, _d, _e, _f, _g;
|
202
208
|
return __generator(this, function (_h) {
|
203
209
|
switch (_h.label) {
|
@@ -217,10 +223,13 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
217
223
|
case 2:
|
218
224
|
error_3 = _h.sent();
|
219
225
|
if (axios_1.default.isAxiosError(error_3)) {
|
226
|
+
message = "error" in ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.data)
|
227
|
+
? (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data.error.message
|
228
|
+
: (_c = error_3.response) === null || _c === void 0 ? void 0 : _c.data.message;
|
220
229
|
resError = {
|
221
|
-
httpStatus: ((
|
222
|
-
mtsCode: ((
|
223
|
-
message:
|
230
|
+
httpStatus: ((_d = error_3.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
|
231
|
+
mtsCode: ((_g = (_f = (_e = error_3.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
|
232
|
+
message: message || "Unknown error"
|
224
233
|
};
|
225
234
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
226
235
|
console.log("DELETE_ResponseAxiosError", url, resError);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.25",
|
4
4
|
"description": "Library for using MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
"@types/jest": "^29.5.12",
|
20
20
|
"jest": "^29.7.0",
|
21
21
|
"prettier": "^3.3.3",
|
22
|
-
"ts-jest": "^29.2.
|
22
|
+
"ts-jest": "^29.2.4",
|
23
23
|
"typescript": "^5.5.4"
|
24
24
|
},
|
25
25
|
"files": [
|
@@ -31,10 +31,10 @@
|
|
31
31
|
],
|
32
32
|
"author": "Infoservice s.r.l.",
|
33
33
|
"dependencies": {
|
34
|
-
"@react-native-async-storage/async-storage": "^1.
|
35
|
-
"axios": "^1.7.
|
34
|
+
"@react-native-async-storage/async-storage": "^1.24.0",
|
35
|
+
"axios": "^1.7.4",
|
36
36
|
"dotenv": "^16.4.5",
|
37
37
|
"node-localstorage": "^3.0.5",
|
38
|
-
"zustand": "^4.5.
|
38
|
+
"zustand": "^4.5.5"
|
39
39
|
}
|
40
40
|
}
|