mts-booking-library 3.4.0 → 3.5.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.
|
@@ -8,6 +8,10 @@ import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/Jou
|
|
|
8
8
|
import { ReductionTrip } from "../types/journeys/Trip";
|
|
9
9
|
import { ApiCallOptions } from "../utils/apiCall";
|
|
10
10
|
import { Booking } from "./booking";
|
|
11
|
+
type JourneyLineRouteFilters = {
|
|
12
|
+
lineId?: number | null;
|
|
13
|
+
routeId?: number | null;
|
|
14
|
+
};
|
|
11
15
|
export declare class JourneyBooking extends Booking {
|
|
12
16
|
private cart?;
|
|
13
17
|
/**
|
|
@@ -116,13 +120,13 @@ export declare class JourneyBooking extends Booking {
|
|
|
116
120
|
* This method returns the possible departures for all journeys (MLP) sold by this seller.
|
|
117
121
|
* @returns The list of possible departures
|
|
118
122
|
*/
|
|
119
|
-
getJourneysDepartures(options?: ApiCallOptions): Promise<ErrorResponse | string[]>;
|
|
123
|
+
getJourneysDepartures(filtersOrOptions?: JourneyLineRouteFilters | ApiCallOptions, options?: ApiCallOptions): Promise<ErrorResponse | string[]>;
|
|
120
124
|
/**
|
|
121
125
|
* This method returns the possible destination for the journeys sold by this seller that start at the selected departure.
|
|
122
126
|
* @param departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
|
|
123
127
|
* @returns The list of possible destinations
|
|
124
128
|
*/
|
|
125
|
-
getJourneysDestinations(departureStopName: string, options?: ApiCallOptions): Promise<ErrorResponse | string[]>;
|
|
129
|
+
getJourneysDestinations(departureStopName: string, filtersOrOptions?: JourneyLineRouteFilters | ApiCallOptions, options?: ApiCallOptions): Promise<ErrorResponse | string[]>;
|
|
126
130
|
/**
|
|
127
131
|
* This method returns the journeys that match the given parameters.
|
|
128
132
|
* Note that it will always return the journeys for the one-way trip.
|
|
@@ -228,3 +232,4 @@ export declare class JourneyBooking extends Booking {
|
|
|
228
232
|
export declare namespace JourneyBooking {
|
|
229
233
|
const createBooking: ({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType }: Omit<Booking.BookingConfig, "bookingType">) => Promise<JourneyBooking>;
|
|
230
234
|
}
|
|
235
|
+
export {};
|
|
@@ -79,6 +79,8 @@ var Reduction_1 = require("../types/common/Reduction");
|
|
|
79
79
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
|
80
80
|
var utils_1 = require("../utils/utils");
|
|
81
81
|
var booking_1 = require("./booking");
|
|
82
|
+
var isJourneyLineRouteFilters = function (value) { return !!value && ("lineId" in value || "routeId" in value); };
|
|
83
|
+
var getJourneyLineRouteParams = function (filters) { return (__assign(__assign({}, ((filters === null || filters === void 0 ? void 0 : filters.lineId) && { lineId: filters.lineId.toString() })), ((filters === null || filters === void 0 ? void 0 : filters.routeId) && { routeId: filters.routeId.toString() }))); };
|
|
82
84
|
var JourneyBooking = /** @class */ (function (_super) {
|
|
83
85
|
__extends(JourneyBooking, _super);
|
|
84
86
|
/**
|
|
@@ -219,12 +221,15 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
219
221
|
* This method returns the possible departures for all journeys (MLP) sold by this seller.
|
|
220
222
|
* @returns The list of possible departures
|
|
221
223
|
*/
|
|
222
|
-
JourneyBooking.prototype.getJourneysDepartures = function (options) {
|
|
224
|
+
JourneyBooking.prototype.getJourneysDepartures = function (filtersOrOptions, options) {
|
|
223
225
|
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
-
var url;
|
|
226
|
+
var filters, requestOptions, searchParams, url;
|
|
225
227
|
return __generator(this, function (_a) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
filters = isJourneyLineRouteFilters(filtersOrOptions) ? filtersOrOptions : undefined;
|
|
229
|
+
requestOptions = isJourneyLineRouteFilters(filtersOrOptions) ? options : filtersOrOptions;
|
|
230
|
+
searchParams = new URLSearchParams(getJourneyLineRouteParams(filters));
|
|
231
|
+
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/departures?").concat(searchParams);
|
|
232
|
+
return [2 /*return*/, this.callGetApi(url, requestOptions).then(function (response) {
|
|
228
233
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.stops;
|
|
229
234
|
})];
|
|
230
235
|
});
|
|
@@ -235,13 +240,15 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
235
240
|
* @param departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
|
|
236
241
|
* @returns The list of possible destinations
|
|
237
242
|
*/
|
|
238
|
-
JourneyBooking.prototype.getJourneysDestinations = function (departureStopName, options) {
|
|
243
|
+
JourneyBooking.prototype.getJourneysDestinations = function (departureStopName, filtersOrOptions, options) {
|
|
239
244
|
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
-
var searchParams, url;
|
|
245
|
+
var filters, requestOptions, searchParams, url;
|
|
241
246
|
return __generator(this, function (_a) {
|
|
242
|
-
|
|
247
|
+
filters = isJourneyLineRouteFilters(filtersOrOptions) ? filtersOrOptions : undefined;
|
|
248
|
+
requestOptions = isJourneyLineRouteFilters(filtersOrOptions) ? options : filtersOrOptions;
|
|
249
|
+
searchParams = new URLSearchParams(__assign({ departureStopName: departureStopName }, getJourneyLineRouteParams(filters)));
|
|
243
250
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/destinations?").concat(searchParams);
|
|
244
|
-
return [2 /*return*/, this.callGetApi(url,
|
|
251
|
+
return [2 /*return*/, this.callGetApi(url, requestOptions).then(function (response) {
|
|
245
252
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.stops;
|
|
246
253
|
})];
|
|
247
254
|
});
|
|
@@ -262,7 +269,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
262
269
|
if (request.departureStopName === undefined || request.destinationStopName === undefined) {
|
|
263
270
|
throw Error("Fields departureStopName and destinationStopName are required");
|
|
264
271
|
}
|
|
265
|
-
searchParams = new URLSearchParams(__assign(__assign(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(), outboundDate: request.outboundDate.dateTime }, (request.returnDate && { returnDate: request.returnDate.dateTime })), { currency: request.currency, outboundTripId: (_b = (_a = request.outboundTripId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "null" }), (this.cartGuid && { cartGuid: this.cartGuid })));
|
|
272
|
+
searchParams = new URLSearchParams(__assign(__assign(__assign(__assign(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(), outboundDate: request.outboundDate.dateTime }, (request.returnDate && { returnDate: request.returnDate.dateTime })), { currency: request.currency, outboundTripId: (_b = (_a = request.outboundTripId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "null" }), (request.lineId && { lineId: request.lineId.toString() })), (request.routeId && { routeId: request.routeId.toString() })), (this.cartGuid && { cartGuid: this.cartGuid })));
|
|
266
273
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys_v4?").concat(searchParams);
|
|
267
274
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
268
275
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
|
|
@@ -12,6 +12,8 @@ export type JourneySearchRequest = {
|
|
|
12
12
|
currency: Booking.Currencies;
|
|
13
13
|
isRoundTrip: boolean;
|
|
14
14
|
outboundTripId?: number | null;
|
|
15
|
+
lineId?: number | null;
|
|
16
|
+
routeId?: number | null;
|
|
15
17
|
};
|
|
16
18
|
export declare const DEFAULT_JOURNEY_SEARCH: JourneySearchRequest;
|
|
17
19
|
export type JourneySearchResult = {
|