mts-booking-library 3.0.6 → 3.0.7

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.
@@ -2,8 +2,9 @@ import { ErrorResponse } from "../types/ErrorResponse";
2
2
  import { CreateUpdateCartRequest } from "../types/common/Cart";
3
3
  import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
4
4
  import { AddReductionRequest } from "../types/common/Reduction";
5
- import { Service, ServiceTripsResponse } from "../types/services/Service";
5
+ import { Service } from "../types/services/Service";
6
6
  import { ServiceCart } from "../types/services/ServiceCart";
7
+ import { GetTripsResponse } from "../types/tpl/Trips";
7
8
  import { ApiCallOptions } from "../utils/apiCall";
8
9
  import { Booking } from "./booking";
9
10
  export declare class ServiceBooking extends Booking {
@@ -132,7 +133,7 @@ export declare class ServiceBooking extends Booking {
132
133
  * @param dateString The date on which to get the tours, in ISO string format
133
134
  * @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
134
135
  */
135
- getServiceTrips(serviceId: number, dateString: string, options?: ApiCallOptions): Promise<ErrorResponse | ServiceTripsResponse>;
136
+ getServiceTrips(serviceId: number, dateString: string, options?: ApiCallOptions): Promise<ErrorResponse | GetTripsResponse>;
136
137
  /**
137
138
  * This method creates a service cart for the given parameters.
138
139
  * @returns The created cart
@@ -7,6 +7,7 @@ import { TariffType, TermsType } from "../types/common/Tariffs";
7
7
  import { GetTariffsResponse } from "../types/tpl/GetTariffsResponse";
8
8
  import { GetSuperAreasRequest, SuperArea } from "../types/tpl/SuperArea";
9
9
  import { BookingSkip, TplCart } from "../types/tpl/TplCart";
10
+ import { GetTripsResponse } from "../types/tpl/Trips";
10
11
  import { ApiCallOptions } from "../utils/apiCall";
11
12
  import { Booking } from "./booking";
12
13
  export declare class TplBooking extends Booking {
@@ -145,6 +146,16 @@ export declare class TplBooking extends Booking {
145
146
  * @returns A {@link GetTariffsResponse} if the call is successful, an {@link ErrorResponse} object otherwise.
146
147
  */
147
148
  getTariffs(superAreaId: number, termsTypeId: number | null, onlyTickets: boolean, onlySubscriptions: boolean, options?: ApiCallOptions): Promise<ErrorResponse | GetTariffsResponse>;
149
+ /**
150
+ * 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
151
+ * and/or a specific hour for the tour.
152
+ * You should call this method only if {@link Tariff.isDateOptional} or {@link Tariff.isDateRequired} is true for the selected tour.
153
+ * @param superAreaId The id of the selected super area (can be retrieved in the object {@link SuperArea} returned by {@link getSuperAreas})
154
+ * @param tariffId The id of the selected tariff (can be retrieved in the object {@link Tariff} returned by {@link getTariffs})
155
+ * @param dateString The date on which to get the tours, in ISO date string format
156
+ * @returns {GetTripsResponse} The returned information about the tour (tripId and hour)
157
+ */
158
+ getTplTrips(superAreaId: number, tariffId: number, dateString: string, options?: ApiCallOptions): Promise<ErrorResponse | GetTripsResponse>;
148
159
  /**
149
160
  * This method creates a tpl cart for the given parameters.
150
161
  * @returns The created cart
@@ -237,7 +237,7 @@ var TplBooking = /** @class */ (function (_super) {
237
237
  return __awaiter(this, void 0, void 0, function () {
238
238
  var searchParams, url;
239
239
  return __generator(this, function (_a) {
240
- searchParams = new URLSearchParams(__assign(__assign({ includeBasicInfo: "true", includeAreaIds: "false", includeTariffIds: "false", includeRouteIds: "false" }, (request.cityId && { cityId: request.cityId.toString() })), (request.tripId && { tripId: request.tripId.toString() })));
240
+ searchParams = new URLSearchParams(__assign(__assign({ includeBasicInfo: "true", includeImage: "true", includeAreaIds: "false", includeTariffIds: "false", includeRouteIds: "false", includeMultilingualDescriptions: "false" }, (request.cityId && { cityId: request.cityId.toString() })), (request.tripId && { tripId: request.tripId.toString() })));
241
241
  url = "".concat(this.config.API_ENDPOINT, "/v3_resources/superAreas?").concat(searchParams);
242
242
  return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
243
243
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.superAreas;
@@ -313,6 +313,31 @@ var TplBooking = /** @class */ (function (_super) {
313
313
  });
314
314
  });
315
315
  };
316
+ /**
317
+ * 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
318
+ * and/or a specific hour for the tour.
319
+ * You should call this method only if {@link Tariff.isDateOptional} or {@link Tariff.isDateRequired} is true for the selected tour.
320
+ * @param superAreaId The id of the selected super area (can be retrieved in the object {@link SuperArea} returned by {@link getSuperAreas})
321
+ * @param tariffId The id of the selected tariff (can be retrieved in the object {@link Tariff} returned by {@link getTariffs})
322
+ * @param dateString The date on which to get the tours, in ISO date string format
323
+ * @returns {GetTripsResponse} The returned information about the tour (tripId and hour)
324
+ */
325
+ TplBooking.prototype.getTplTrips = function (superAreaId, tariffId, dateString, options) {
326
+ return __awaiter(this, void 0, void 0, function () {
327
+ var searchParams, url;
328
+ return __generator(this, function (_a) {
329
+ searchParams = new URLSearchParams({
330
+ superAreaId: superAreaId.toString(),
331
+ tariffId: tariffId.toString(),
332
+ dateString: dateString
333
+ });
334
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/tpl/trips?").concat(searchParams);
335
+ return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
336
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
337
+ })];
338
+ });
339
+ });
340
+ };
316
341
  /**
317
342
  * This method creates a tpl cart for the given parameters.
318
343
  * @returns The created cart
package/lib/index.d.ts CHANGED
@@ -22,7 +22,7 @@ export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } fro
22
22
  export { Stop } from "./types/journeys/Stop";
23
23
  export { Trip, CartTrip, ReductionTrip } from "./types/journeys/Trip";
24
24
  export { Line } from "./types/services/Line";
25
- export { Service, TripIdAndHour, ServiceTripsResponse, ServiceTrip } from "./types/services/Service";
25
+ export { Service, ServiceTrip } from "./types/services/Service";
26
26
  export { ServiceCart, ServiceBookingType } from "./types/services/ServiceCart";
27
27
  export { ServiceInfo } from "./types/services/ServiceInfo";
28
28
  export { GetTariffsResponse } from "./types/tpl/GetTariffsResponse";
@@ -48,6 +48,14 @@ export type Tariff = {
48
48
  roundTripCode: string | null;
49
49
  /** Whether the tariff is active */
50
50
  isActive: boolean;
51
+ /** For TPL Tours, this tells whether it is possible to select a date for this tariff */
52
+ isDateOptional: boolean;
53
+ /** For TPL Tours, this tells whether it is mandatory to select a date for this tariff */
54
+ isDateRequired: boolean;
55
+ /** For TPL Tours, this tells whether it is mandatory to select a time for the selected date for this tariff */
56
+ isTripMandatory: boolean;
57
+ /** For TPL Tours, this is the list of possible dates to select for this tariff, in ISO date string format. */
58
+ possibleDates: string[];
51
59
  };
52
60
  /**
53
61
  * This represents a tariff matrix, returned when searching Journeys or Services.
@@ -26,12 +26,6 @@ export type Service = {
26
26
  isDateRequired: boolean;
27
27
  isTripMandatory: boolean;
28
28
  };
29
- export type TripIdAndHour = {
30
- /** The id of the trip. */
31
- tripId: number;
32
- /** The hour of the trip. */
33
- hour: string;
34
- };
35
29
  export type ServiceTrip = {
36
30
  /** The name of the service */
37
31
  name: string;
@@ -40,13 +34,3 @@ export type ServiceTrip = {
40
34
  /** The id of the trip, if set. */
41
35
  tripId?: number;
42
36
  };
43
- /**
44
- * @description Represents a response from the service trips endpoint
45
- * @param {boolean} areThereTrips - Indicates whether there are trips available for the service.
46
- * @param {TripIdAndHour[]} trips - An array of {@link TripIdAndHour} objects representing the available trips. This can be empty
47
- * even if `areThereTrips` is true, as the user might be not allowed to select a specific trip.
48
- */
49
- export type ServiceTripsResponse = {
50
- areThereTrips: boolean;
51
- trips: TripIdAndHour[];
52
- };
@@ -1,15 +1,17 @@
1
- /**
2
- * This type represents a super area. It is the return object of the {@link TplBooking.getSuperAreas} method.
3
- * @param {number} id The id of the super area in the database
4
- * @param {string} name The name of the super area
5
- * @param {string} shortName The short name of the super area
6
- * @param {string} description The description of the super area
7
- */
1
+ /** This type represents a super area. It is the return object of the {@link TplBooking.getSuperAreas} method. */
8
2
  export type SuperArea = {
3
+ /** The id of the super area in the database */
9
4
  id: number;
5
+ /** The name of the super area */
10
6
  name: string;
7
+ /** The short name of the super area */
11
8
  shortName: string;
9
+ /** The description of the super area */
12
10
  description: string;
11
+ /** The description of the super area to be shown in the booking process. This is returned in the language requested by the client */
12
+ bookingProcessDescription: string;
13
+ /** The url of the image of the super area */
14
+ imageUrl: string;
13
15
  };
14
16
  export type GetSuperAreasRequest = {
15
17
  /** The id of the city (as returned by the {@link TplBooking.getCities} method). If present, only the super areas associated with this city will be returned. */
@@ -0,0 +1,16 @@
1
+ export type TripIdAndHour = {
2
+ /** The id of the trip. */
3
+ tripId: number;
4
+ /** The hour of the trip. */
5
+ hour: string;
6
+ };
7
+ /**
8
+ * @description Represents a response from the service trips endpoint
9
+ * @param {boolean} areThereTrips - Indicates whether there are trips available for the service.
10
+ * @param {TripIdAndHour[]} trips - An array of {@link TripIdAndHour} objects representing the available trips. This can be empty
11
+ * even if `areThereTrips` is true, as the user might be not allowed to select a specific trip.
12
+ */
13
+ export type GetTripsResponse = {
14
+ areThereTrips: boolean;
15
+ trips: TripIdAndHour[];
16
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
7
  "scripts": {
8
- "build": "tsc",
8
+ "build": "tsc -p tsconfig.build.json",
9
9
  "pretest": "tsc --noEmit",
10
10
  "test": "jest --config jestconfig.json",
11
11
  "prepare": "npm audit --audit-level=moderate && npm run build",
@@ -22,16 +22,16 @@
22
22
  "@eslint/js": "^9.33.0",
23
23
  "@types/jest": "^30.0.0",
24
24
  "@types/node-localstorage": "^1.3.3",
25
- "dotenv": "^17.2.1",
25
+ "dotenv": "^17.3.1",
26
26
  "eslint": "^9.33.0",
27
27
  "eslint-config-prettier": "^10.1.8",
28
- "globals": "^16.3.0",
29
- "jest": "^30.0.5",
28
+ "globals": "^17.4.0",
29
+ "jest": "^30.2.0",
30
30
  "node-localstorage": "^3.0.5",
31
- "prettier": "^3.6.2",
32
- "ts-jest": "^29.4.1",
33
- "typescript": "^5.9.2",
34
- "typescript-eslint": "^8.40.0"
31
+ "prettier": "^3.8.1",
32
+ "ts-jest": "^29.4.6",
33
+ "typescript": "^5.9.3",
34
+ "typescript-eslint": "^8.56.1"
35
35
  },
36
36
  "files": [
37
37
  "lib/**/*"
@@ -42,8 +42,8 @@
42
42
  ],
43
43
  "author": "Infoservice s.r.l.",
44
44
  "dependencies": {
45
- "@react-native-async-storage/async-storage": "~2.2.0",
46
- "axios": "~1.13.0",
47
- "zustand": "~5.0.8"
45
+ "@react-native-async-storage/async-storage": "~3.0.1",
46
+ "axios": "~1.13.6",
47
+ "zustand": "~5.0.11"
48
48
  }
49
49
  }