mts-booking-library 2.0.0 → 2.1.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 +13 -12
- package/lib/booking/booking.js +24 -24
- package/lib/booking/journeyBooking.d.ts +32 -31
- package/lib/booking/journeyBooking.js +49 -49
- package/lib/booking/serviceBooking.d.ts +22 -21
- package/lib/booking/serviceBooking.js +34 -34
- package/lib/booking/subscriptionBooking.d.ts +34 -33
- package/lib/booking/subscriptionBooking.js +49 -49
- package/lib/booking/tplBooking.d.ts +23 -22
- package/lib/booking/tplBooking.js +38 -38
- package/lib/index.d.ts +1 -1
- package/lib/mtsStorage.d.ts +0 -11
- package/lib/mtsStorage.js +4 -4
- package/lib/types/common/Payment.d.ts +1 -1
- package/lib/utils/apiCall.d.ts +9 -4
- package/lib/utils/apiCall.js +12 -8
- package/package.json +2 -2
- package/lib/SubscriptionBooking.d.ts +0 -0
- package/lib/SubscriptionBooking.js +0 -148
- package/lib/utils/testUtils.d.ts +0 -8
- package/lib/utils/testUtils.js +0 -19
@@ -130,12 +130,12 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
130
130
|
console.log(e);
|
131
131
|
}
|
132
132
|
};
|
133
|
-
JourneyBooking.prototype.fetchAndSetCart = function (cartGuid) {
|
133
|
+
JourneyBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
|
134
134
|
return __awaiter(this, void 0, void 0, function () {
|
135
135
|
var _this = this;
|
136
136
|
return __generator(this, function (_a) {
|
137
137
|
switch (_a.label) {
|
138
|
-
case 0: return [4 /*yield*/, this.fetchCart(cartGuid).then(function (cart) {
|
138
|
+
case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options).then(function (cart) {
|
139
139
|
if (cart) {
|
140
140
|
var cartDueDate = new Date();
|
141
141
|
cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
|
@@ -161,13 +161,13 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
161
161
|
});
|
162
162
|
});
|
163
163
|
};
|
164
|
-
JourneyBooking.prototype.fetchCart = function (cartGuid) {
|
164
|
+
JourneyBooking.prototype.fetchCart = function (cartGuid, options) {
|
165
165
|
return __awaiter(this, void 0, void 0, function () {
|
166
166
|
var url;
|
167
167
|
var _this = this;
|
168
168
|
return __generator(this, function (_a) {
|
169
169
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts?").concat(new URLSearchParams({ cartGuid: cartGuid }));
|
170
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
170
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
171
171
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
172
172
|
_this.resetBooking();
|
173
173
|
throw new Error(JSON.stringify(response, null, 2));
|
@@ -186,7 +186,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
186
186
|
* @returns An {@link ErrorResponse} object in case of error, nothing otherwise. Note that also in case of error, all
|
187
187
|
* data will be deleted.
|
188
188
|
*/
|
189
|
-
JourneyBooking.prototype.deleteCart = function () {
|
189
|
+
JourneyBooking.prototype.deleteCart = function (options) {
|
190
190
|
return __awaiter(this, void 0, void 0, function () {
|
191
191
|
var url;
|
192
192
|
var _this = this;
|
@@ -196,7 +196,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
196
196
|
throw Error("Cart is not initialized yet");
|
197
197
|
}
|
198
198
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts?").concat(new URLSearchParams({ cartGuid: this.cart.guid }));
|
199
|
-
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
199
|
+
return [2 /*return*/, this.callDeleteApi(url, options).then(function (response) {
|
200
200
|
// Clear all data
|
201
201
|
_this.resetBooking();
|
202
202
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
|
@@ -206,14 +206,14 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
206
206
|
};
|
207
207
|
/**
|
208
208
|
* This method returns the possible departures for all journeys (MLP) sold by this seller.
|
209
|
-
* @returns
|
209
|
+
* @returns The list of possible departures
|
210
210
|
*/
|
211
|
-
JourneyBooking.prototype.getJourneysDepartures = function () {
|
211
|
+
JourneyBooking.prototype.getJourneysDepartures = function (options) {
|
212
212
|
return __awaiter(this, void 0, void 0, function () {
|
213
213
|
var url;
|
214
214
|
return __generator(this, function (_a) {
|
215
215
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/departures?");
|
216
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
216
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
217
217
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
218
218
|
? response
|
219
219
|
: response.stops;
|
@@ -223,16 +223,16 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
223
223
|
};
|
224
224
|
/**
|
225
225
|
* This method returns the possible destination for the journeys sold by this seller that start at the selected departure.
|
226
|
-
* @param
|
227
|
-
* @returns
|
226
|
+
* @param departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
|
227
|
+
* @returns The list of possible destinations
|
228
228
|
*/
|
229
|
-
JourneyBooking.prototype.getJourneysDestinations = function (departureStopName) {
|
229
|
+
JourneyBooking.prototype.getJourneysDestinations = function (departureStopName, options) {
|
230
230
|
return __awaiter(this, void 0, void 0, function () {
|
231
231
|
var searchParams, url;
|
232
232
|
return __generator(this, function (_a) {
|
233
233
|
searchParams = new URLSearchParams({ departureStopName: departureStopName });
|
234
234
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/destinations?").concat(searchParams);
|
235
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
235
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
236
236
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
237
237
|
? response
|
238
238
|
: response.stops;
|
@@ -244,10 +244,10 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
244
244
|
* This method returns the journeys that match the given parameters.
|
245
245
|
* Note that it will always return the journeys for the one-way trip.
|
246
246
|
* If you want to get the journeys for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
|
247
|
-
* @param
|
248
|
-
* @returns
|
247
|
+
* @param request an object of type {@link JourneySearch} containing the parameters of the search
|
248
|
+
* @returns The returned journeys that match the given parameters
|
249
249
|
*/
|
250
|
-
JourneyBooking.prototype.getJourneys = function (request) {
|
250
|
+
JourneyBooking.prototype.getJourneys = function (request, options) {
|
251
251
|
return __awaiter(this, void 0, void 0, function () {
|
252
252
|
var searchParams, url;
|
253
253
|
return __generator(this, function (_a) {
|
@@ -256,7 +256,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
256
256
|
}
|
257
257
|
searchParams = new URLSearchParams(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(), date: request.date, roundTripDate: request.roundTripDate ? request.roundTripDate : "null", currency: request.currency }, (this.cartGuid && { cartGuid: this.cartGuid })));
|
258
258
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys?").concat(searchParams);
|
259
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
259
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
260
260
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
261
261
|
? response
|
262
262
|
: response.journeys;
|
@@ -264,14 +264,14 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
264
264
|
});
|
265
265
|
});
|
266
266
|
};
|
267
|
-
JourneyBooking.prototype.createJourneyCart = function (journeyCart) {
|
267
|
+
JourneyBooking.prototype.createJourneyCart = function (journeyCart, options) {
|
268
268
|
return __awaiter(this, void 0, void 0, function () {
|
269
269
|
var url, request;
|
270
270
|
var _this = this;
|
271
271
|
return __generator(this, function (_a) {
|
272
272
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/carts");
|
273
273
|
request = __assign(__assign({}, journeyCart), (this.cartGuid && { cartGuid: this.cartGuid }));
|
274
|
-
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
274
|
+
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) {
|
275
275
|
// Check for errors
|
276
276
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
277
277
|
// If there was an error, reset cartGuid and remove it from the mts-storage
|
@@ -299,7 +299,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
299
299
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
300
300
|
* as well as a list of the available tariffs for each trip.
|
301
301
|
*/
|
302
|
-
JourneyBooking.prototype.getBuyerPassengersDetails = function () {
|
302
|
+
JourneyBooking.prototype.getBuyerPassengersDetails = function (options) {
|
303
303
|
return __awaiter(this, void 0, void 0, function () {
|
304
304
|
var buyerPassengersDetails, searchParams, url;
|
305
305
|
return __generator(this, function (_a) {
|
@@ -313,7 +313,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
313
313
|
}
|
314
314
|
searchParams = new URLSearchParams({ cartGuid: this.cart.guid });
|
315
315
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/details?").concat(searchParams);
|
316
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
316
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
317
317
|
// Check for errors
|
318
318
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
319
319
|
return response;
|
@@ -351,10 +351,10 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
351
351
|
};
|
352
352
|
/**
|
353
353
|
* @description This methosd shall be called when the user wants to update the buyer and the passengers information.
|
354
|
-
* @param
|
354
|
+
* @param passengersDetails The object containing the buyer and the passengers information.
|
355
355
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
356
356
|
*/
|
357
|
-
JourneyBooking.prototype.updateBuyerPassengersDetails = function (passengersDetails) {
|
357
|
+
JourneyBooking.prototype.updateBuyerPassengersDetails = function (passengersDetails, options) {
|
358
358
|
return __awaiter(this, void 0, void 0, function () {
|
359
359
|
var buyerPassengersDetails, request, url;
|
360
360
|
var _this = this;
|
@@ -376,7 +376,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
376
376
|
request.passengers[passengerIndex].tripsToTariffs = tripsToTariffsToJson;
|
377
377
|
});
|
378
378
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/details");
|
379
|
-
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
379
|
+
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) {
|
380
380
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
381
381
|
return response;
|
382
382
|
}
|
@@ -390,12 +390,12 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
390
390
|
/**
|
391
391
|
* @description This method shall be used when the user wants to retrieve the bus matrix for a trip. The bus matrix shows
|
392
392
|
* the seats that are available and the ones that are already taken, as well as how the bus is made.
|
393
|
-
* @param
|
394
|
-
* @param
|
395
|
-
* @param
|
393
|
+
* @param tripId The id of the trip for which the bus matrix should be retrieved
|
394
|
+
* @param departureStopId The id of the departure stop
|
395
|
+
* @param destinationStopId The id of the destination stop
|
396
396
|
* @returns An {@link ErrorResponse} object in case of error, a {@link BusMatrix} otherwise.
|
397
397
|
*/
|
398
|
-
JourneyBooking.prototype.getBusMatrix = function (tripId, departureStopId, destinationStopId) {
|
398
|
+
JourneyBooking.prototype.getBusMatrix = function (tripId, departureStopId, destinationStopId, options) {
|
399
399
|
return __awaiter(this, void 0, void 0, function () {
|
400
400
|
var seatSelectionStatus, searchParams, url;
|
401
401
|
return __generator(this, function (_a) {
|
@@ -413,7 +413,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
413
413
|
destinationStopId: destinationStopId.toString()
|
414
414
|
});
|
415
415
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/trips/seats?").concat(searchParams);
|
416
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
416
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
417
417
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
418
418
|
? response
|
419
419
|
: response.busMatrix;
|
@@ -423,10 +423,10 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
423
423
|
};
|
424
424
|
/**
|
425
425
|
* @description This method shall be called when the user wants to retrieve which seats were assigned for this booking.
|
426
|
-
* @param
|
426
|
+
* @param tripId The id of the trip for which the seats should be retrieved.
|
427
427
|
* @returns An {@link ErrorResponse} object in case of error, a list of {@link BusLayoutCell} ids otherwise, representing the assigned seats.
|
428
428
|
*/
|
429
|
-
JourneyBooking.prototype.getAssignedSeats = function (tripId) {
|
429
|
+
JourneyBooking.prototype.getAssignedSeats = function (tripId, options) {
|
430
430
|
return __awaiter(this, void 0, void 0, function () {
|
431
431
|
var seatSelectionStatus, searchParams, url;
|
432
432
|
return __generator(this, function (_a) {
|
@@ -443,7 +443,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
443
443
|
cartGuid: this.cart.guid
|
444
444
|
});
|
445
445
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/seats?").concat(searchParams);
|
446
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
446
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
447
447
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
448
448
|
? response
|
449
449
|
: response.assignedSeats;
|
@@ -453,11 +453,11 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
453
453
|
};
|
454
454
|
/**
|
455
455
|
* @description This method shall be called when the user wants to change the assigned seats of a trip.
|
456
|
-
* @param
|
457
|
-
* @param
|
456
|
+
* @param tripId The id of the trip for which the seats should be changed
|
457
|
+
* @param newSeatsIds The ids of the new seats, as found the {@link BusMatrix}
|
458
458
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
459
459
|
*/
|
460
|
-
JourneyBooking.prototype.changeSeatsOfTrip = function (tripId, newSeatsIds) {
|
460
|
+
JourneyBooking.prototype.changeSeatsOfTrip = function (tripId, newSeatsIds, options) {
|
461
461
|
return __awaiter(this, void 0, void 0, function () {
|
462
462
|
var seatSelectionStatus, url;
|
463
463
|
var _this = this;
|
@@ -475,7 +475,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
475
475
|
tripId: tripId,
|
476
476
|
newSeatsIds: newSeatsIds,
|
477
477
|
cartGuid: this.cart.guid
|
478
|
-
}).then(function (response) {
|
478
|
+
}, options).then(function (response) {
|
479
479
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
480
480
|
return response;
|
481
481
|
}
|
@@ -493,7 +493,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
493
493
|
* @see {@link Booking.addReduction} for detailed info on how to add a reduction.
|
494
494
|
* @returns An {@link ErrorResponse} object in case of error, a list of {@link ReductionTrip} otherwise, representing the trips in the cart.
|
495
495
|
*/
|
496
|
-
JourneyBooking.prototype.getCartTrips = function () {
|
496
|
+
JourneyBooking.prototype.getCartTrips = function (options) {
|
497
497
|
return __awaiter(this, void 0, void 0, function () {
|
498
498
|
var searchParams, url;
|
499
499
|
return __generator(this, function (_a) {
|
@@ -503,7 +503,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
503
503
|
}
|
504
504
|
searchParams = new URLSearchParams({ cartGuid: this.cart.guid });
|
505
505
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction/trips?").concat(searchParams);
|
506
|
-
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
506
|
+
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
507
507
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
508
508
|
? response
|
509
509
|
: response.trips;
|
@@ -513,10 +513,10 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
513
513
|
};
|
514
514
|
/**
|
515
515
|
* @description This method allows to add a reduction to the whole cart or to a single trip in the cart.
|
516
|
-
* @param
|
516
|
+
* @param request The information about the reduction to add
|
517
517
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
|
518
518
|
*/
|
519
|
-
JourneyBooking.prototype.addReduction = function (request) {
|
519
|
+
JourneyBooking.prototype.addReduction = function (request, options) {
|
520
520
|
return __awaiter(this, void 0, void 0, function () {
|
521
521
|
var discountsStep, _i, _a, step, url;
|
522
522
|
var _this = this;
|
@@ -554,7 +554,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
554
554
|
_c.label = 5;
|
555
555
|
case 5:
|
556
556
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
|
557
|
-
return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartGuid: this.cartGuid })).then(function (response) {
|
557
|
+
return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartGuid: this.cartGuid }), options).then(function (response) {
|
558
558
|
var _a, _b;
|
559
559
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
560
560
|
return response;
|
@@ -576,7 +576,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
576
576
|
* will be removed from the whole cart.
|
577
577
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
|
578
578
|
*/
|
579
|
-
JourneyBooking.prototype.removeReduction = function (tripId) {
|
579
|
+
JourneyBooking.prototype.removeReduction = function (tripId, options) {
|
580
580
|
return __awaiter(this, void 0, void 0, function () {
|
581
581
|
var discountsStep, queryParams, url;
|
582
582
|
var _this = this;
|
@@ -594,7 +594,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
594
594
|
cartGuid: this.cartGuid
|
595
595
|
});
|
596
596
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
|
597
|
-
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
597
|
+
return [2 /*return*/, this.callDeleteApi(url, options).then(function (response) {
|
598
598
|
var _a, _b, _c;
|
599
599
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
600
600
|
return response;
|
@@ -619,7 +619,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
619
619
|
* remaining amount with another payment method.
|
620
620
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
621
621
|
*/
|
622
|
-
JourneyBooking.prototype.useWallet = function () {
|
622
|
+
JourneyBooking.prototype.useWallet = function (options) {
|
623
623
|
return __awaiter(this, void 0, void 0, function () {
|
624
624
|
var issueStep, _i, _a, step, url;
|
625
625
|
var _this = this;
|
@@ -661,7 +661,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
661
661
|
_c.label = 5;
|
662
662
|
case 5:
|
663
663
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
|
664
|
-
return [2 /*return*/, this.callPostApi(url, { cartGuid: this.cartGuid }).then(function (response) {
|
664
|
+
return [2 /*return*/, this.callPostApi(url, { cartGuid: this.cartGuid }, options).then(function (response) {
|
665
665
|
var _a, _b;
|
666
666
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
667
667
|
return response;
|
@@ -682,7 +682,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
682
682
|
*
|
683
683
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
|
684
684
|
*/
|
685
|
-
JourneyBooking.prototype.removeWalletReduction = function () {
|
685
|
+
JourneyBooking.prototype.removeWalletReduction = function (options) {
|
686
686
|
return __awaiter(this, void 0, void 0, function () {
|
687
687
|
var queryParams, url;
|
688
688
|
var _this = this;
|
@@ -693,7 +693,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
693
693
|
}
|
694
694
|
queryParams = new URLSearchParams({ cartGuid: this.cartGuid });
|
695
695
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
|
696
|
-
return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
|
696
|
+
return [2 /*return*/, this.callDeleteApi(url, options).then(function (response) {
|
697
697
|
var _a, _b, _c;
|
698
698
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
699
699
|
return response;
|
@@ -715,7 +715,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
715
715
|
* @param voucherCode The code of the voucher to use
|
716
716
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
717
717
|
*/
|
718
|
-
JourneyBooking.prototype.useVoucher = function (voucherCode) {
|
718
|
+
JourneyBooking.prototype.useVoucher = function (voucherCode, options) {
|
719
719
|
return __awaiter(this, void 0, void 0, function () {
|
720
720
|
var discountsStep, _i, _a, step, url;
|
721
721
|
var _this = this;
|
@@ -753,7 +753,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
753
753
|
_c.label = 5;
|
754
754
|
case 5:
|
755
755
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/voucher");
|
756
|
-
return [2 /*return*/, this.callPostApi(url, { voucherCode: voucherCode, cartGuid: this.cartGuid }).then(function (response) {
|
756
|
+
return [2 /*return*/, this.callPostApi(url, { voucherCode: voucherCode, cartGuid: this.cartGuid }, options).then(function (response) {
|
757
757
|
var _a, _b;
|
758
758
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
759
759
|
return response;
|
@@ -3,6 +3,7 @@ import { PersonDetails, GetBuyerPassengersDetailsResponse } from "../types/commo
|
|
3
3
|
import { AddReductionRequest } from "../types/common/Reduction";
|
4
4
|
import { Service, ServiceTripsResponse } from "../types/services/Service";
|
5
5
|
import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
|
6
|
+
import { ApiCallOptions } from "../utils/apiCall";
|
6
7
|
import { Booking } from "./booking";
|
7
8
|
export declare class ServiceBooking extends Booking {
|
8
9
|
private cart?;
|
@@ -58,38 +59,38 @@ export declare class ServiceBooking extends Booking {
|
|
58
59
|
}>;
|
59
60
|
getCart(): ServiceCart | undefined;
|
60
61
|
resetBooking(): void;
|
61
|
-
fetchAndSetCart(cartGuid: string): Promise<void>;
|
62
|
-
fetchCart(cartGuid: string): Promise<ServiceCart>;
|
62
|
+
fetchAndSetCart(cartGuid: string, options?: ApiCallOptions): Promise<void>;
|
63
|
+
fetchCart(cartGuid: string, options?: ApiCallOptions): Promise<ServiceCart>;
|
63
64
|
/**
|
64
65
|
* This method allows to delete a cart, thus allowing the user to exit from the booking process.
|
65
66
|
* @returns An {@link ErrorResponse} object in case of error, nothing otherwise. Note that also in case of error, all
|
66
67
|
* data will be deleted.
|
67
68
|
*/
|
68
|
-
deleteCart(): Promise<ErrorResponse | any>;
|
69
|
+
deleteCart(options?: ApiCallOptions): Promise<ErrorResponse | any>;
|
69
70
|
/**
|
70
71
|
* This method returns the list of cities in which the seller offers tours.
|
71
72
|
* If the sellerId is not set or it is 0, it will return the list of cities for all sellers.
|
72
|
-
* @returns
|
73
|
+
* @returns The list of possible cities
|
73
74
|
*/
|
74
|
-
getServiceCities(): Promise<ErrorResponse | string[]>;
|
75
|
+
getServiceCities(options?: ApiCallOptions): Promise<ErrorResponse | string[]>;
|
75
76
|
/**
|
76
77
|
* This method returns the tours sold by this seller in the given city.
|
77
78
|
* If the sellerId is not set or it is 0, it will return the tours in the given city for all sellers.
|
78
|
-
* @param
|
79
|
-
* @param
|
80
|
-
* @returns
|
79
|
+
* @param cityName The name of the selected city (as returned by {@link getTourCities})
|
80
|
+
* @param The currency in which the prices should be returned
|
81
|
+
* @returns The returned tours
|
81
82
|
*/
|
82
|
-
getServices(currency: Booking.Currencies, cityName?: string): Promise<ErrorResponse | Service[]>;
|
83
|
+
getServices(currency: Booking.Currencies, cityName?: string, options?: ApiCallOptions): Promise<ErrorResponse | Service[]>;
|
83
84
|
/**
|
84
85
|
* This method returns the tours available for the given date. This method can be used if the seller wants the user to book a specific date
|
85
86
|
* and/or a specific hour for the tour.
|
86
87
|
* You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
|
87
|
-
* @param
|
88
|
-
* @param
|
88
|
+
* @param serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
|
89
|
+
* @param date The date on which to get the tours, in ISO string format
|
89
90
|
* @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
|
90
91
|
*/
|
91
|
-
getServiceTrips(serviceId: number, date: string): Promise<ErrorResponse | ServiceTripsResponse>;
|
92
|
-
createServiceCart(serviceCart: CreateServiceCartRequest): Promise<ErrorResponse | ServiceCart>;
|
92
|
+
getServiceTrips(serviceId: number, date: string, options?: ApiCallOptions): Promise<ErrorResponse | ServiceTripsResponse>;
|
93
|
+
createServiceCart(serviceCart: CreateServiceCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | ServiceCart>;
|
93
94
|
/**
|
94
95
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
95
96
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
@@ -102,41 +103,41 @@ export declare class ServiceBooking extends Booking {
|
|
102
103
|
* It should be null if the buyer data cannot be specified (see {@link GetBuyerPassengersDetailsResponse.buyerDataStatus}).
|
103
104
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
104
105
|
*/
|
105
|
-
updateBuyerPassengersDetails(buyerDetails: PersonDetails | null): Promise<ErrorResponse | boolean>;
|
106
|
+
updateBuyerPassengersDetails(buyerDetails: PersonDetails | null, options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
106
107
|
/**
|
107
108
|
* @description This method allows to add a reduction to the whole cart or to a single trip in the cart.
|
108
|
-
* @param
|
109
|
+
* @param request The information about the reduction to add
|
109
110
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
|
110
111
|
*/
|
111
|
-
addReduction(request: AddReductionRequest): Promise<ErrorResponse | boolean>;
|
112
|
+
addReduction(request: AddReductionRequest, options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
112
113
|
/**
|
113
114
|
* @description This method allows to remove a reduction from the whole cart or from a single trip in the cart.
|
114
115
|
* @param tripId The id of the trip from which the reduction should be removed. If the tripId is 0, then the reduction
|
115
116
|
* will be removed from the whole cart.
|
116
117
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
|
117
118
|
*/
|
118
|
-
removeReduction(tripId: number): Promise<ErrorResponse | boolean>;
|
119
|
+
removeReduction(tripId: number, options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
119
120
|
/**
|
120
121
|
* @description This method allows the user to use the balance in his wallet to pay the cart. If the balance of
|
121
122
|
* the wallet is enough to pay the cart, the cart will be paid fully. Otherwise, the user will be asked to pay the
|
122
123
|
* remaining amount with another payment method.
|
123
124
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
124
125
|
*/
|
125
|
-
useWallet(): Promise<ErrorResponse | boolean>;
|
126
|
+
useWallet(options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
126
127
|
/**
|
127
128
|
* @description This method allows to remove a waller reduction from the cart.
|
128
129
|
*
|
129
130
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise. Also, the cart is updated.
|
130
131
|
*/
|
131
|
-
removeWalletReduction(): Promise<ErrorResponse | boolean>;
|
132
|
+
removeWalletReduction(options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
132
133
|
/**
|
133
134
|
* @description This method allows the user to use a voucher to pay the cart.
|
134
135
|
* If the balance of the value of the voucher is enough to pay the cart, the cart will be paid fully.
|
135
136
|
* Otherwise, the user will be asked to pay the remaining amount with another payment method.
|
136
|
-
* @param
|
137
|
+
* @param voucherCode The code of the voucher to use
|
137
138
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
138
139
|
*/
|
139
|
-
useVoucher(voucherCode: string): Promise<ErrorResponse | boolean>;
|
140
|
+
useVoucher(voucherCode: string, options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
140
141
|
}
|
141
142
|
export declare namespace ServiceBooking {
|
142
143
|
const createBooking: ({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, dbType }: Omit<Booking.BookingConfig, "bookingType">) => Promise<ServiceBooking>;
|