mts-booking-library 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@ export declare abstract class Booking {
3
3
  readonly sellerId?: number | undefined;
4
4
  readonly bookingType: Booking.BookingTypes;
5
5
  readonly config: MTSConfig;
6
+ selectedCurrency: Booking.Currencies;
6
7
  cartStatus: Booking.CartStatus;
7
8
  bookingDueDate: Date | undefined;
8
9
  onCartExpiration: () => void;
@@ -22,6 +23,7 @@ export declare abstract class Booking {
22
23
  */
23
24
  renewAccessToken(access_token: string): void;
24
25
  getCartStatus(): Booking.CartStatus;
26
+ changeCurrency(currency: Booking.Currencies): void;
25
27
  getCartExpirationTimeInMs(): Promise<number>;
26
28
  }
27
29
  export declare namespace Booking {
@@ -50,6 +50,7 @@ var Booking = /** @class */ (function () {
50
50
  */
51
51
  function Booking(env, sub_key, onCartExpiration, bookingType, debug, access_token, sellerId) {
52
52
  if (debug === void 0) { debug = false; }
53
+ this.selectedCurrency = Booking.Currencies.EUR;
53
54
  this.cartStatus = Booking.CartStatus.EMPTY;
54
55
  this.sellerId = sellerId || undefined;
55
56
  this.config = (0, config_1.setConfig)(env, sub_key, debug, access_token);
@@ -66,6 +67,9 @@ var Booking = /** @class */ (function () {
66
67
  Booking.prototype.getCartStatus = function () {
67
68
  return this.cartStatus;
68
69
  };
70
+ Booking.prototype.changeCurrency = function (currency) {
71
+ this.selectedCurrency = currency;
72
+ };
69
73
  Booking.prototype.getCartExpirationTimeInMs = function () {
70
74
  return __awaiter(this, void 0, void 0, function () {
71
75
  return __generator(this, function (_a) {
package/lib/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ export { Booking } from "./booking/booking";
1
2
  export { JourneyBooking } from "./booking/journeyBooking";
2
3
  export { ServiceBooking } from "./booking/serviceBooking";
3
4
  export { SubscriptionBooking } from "./booking/subscriptionBooking";
4
5
  export { Person, PassengersDetails, DEFAULT_PERSON } from "./types/common/Person";
5
6
  export { TariffMatrix, TariffSummary, TariffType, TermsType } from "./types/common/Tariffs";
6
- export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, JourneyBookingInfo } from "./types/journeys/JourneyCart";
7
+ export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, TripBookingInfo, DEFAULT_CREATE_JOURNEY_CART } from "./types/journeys/JourneyCart";
7
8
  export { JourneyInfo } from "./types/journeys/JourneyInfo";
8
9
  export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
9
10
  export { Stop } from "./types/journeys/Stop";
package/lib/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_PERSON = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = void 0;
3
+ exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_CREATE_JOURNEY_CART = exports.DEFAULT_PERSON = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
4
4
  //#region Export Booking classes
5
+ var booking_1 = require("./booking/booking");
6
+ Object.defineProperty(exports, "Booking", { enumerable: true, get: function () { return booking_1.Booking; } });
5
7
  var journeyBooking_1 = require("./booking/journeyBooking");
6
8
  Object.defineProperty(exports, "JourneyBooking", { enumerable: true, get: function () { return journeyBooking_1.JourneyBooking; } });
7
9
  var serviceBooking_1 = require("./booking/serviceBooking");
@@ -13,6 +15,11 @@ Object.defineProperty(exports, "SubscriptionBooking", { enumerable: true, get: f
13
15
  // @note: Cart is not exported because it is extended by other types
14
16
  var Person_1 = require("./types/common/Person");
15
17
  Object.defineProperty(exports, "DEFAULT_PERSON", { enumerable: true, get: function () { return Person_1.DEFAULT_PERSON; } });
18
+ //#endregion
19
+ //#region Export JourneyBooking types
20
+ // TODO: BusMatrix.ts
21
+ var JourneyCart_1 = require("./types/journeys/JourneyCart");
22
+ Object.defineProperty(exports, "DEFAULT_CREATE_JOURNEY_CART", { enumerable: true, get: function () { return JourneyCart_1.DEFAULT_CREATE_JOURNEY_CART; } });
16
23
  var JourneySearch_1 = require("./types/journeys/JourneySearch");
17
24
  Object.defineProperty(exports, "DEFAULT_JOURNEY_SEARCH", { enumerable: true, get: function () { return JourneySearch_1.DEFAULT_JOURNEY_SEARCH; } });
18
25
  //#endregion
@@ -3,14 +3,15 @@ import { Cart } from "../common/Cart";
3
3
  import { TariffMatrix, TariffSummary } from "../common/Tariffs";
4
4
  import { Stop } from "./Stop";
5
5
  /**
6
- * @description Object containing information about the selected journey, to be used when booking the journey.
6
+ * @description Object containing information about a trip of a selected journey. This object is part of the {@link CreateJourneyCartRequest} object
7
+ * and describes a single trip of the journey (either outbound or return).
7
8
  *
8
9
  * @property {number} tripId - The unique identifier for the trip.
9
10
  * @property {number} departureStopId - The unique identifier for the departure stop.
10
11
  * @property {number} destinationStopId - The unique identifier for the destination stop.
11
12
  * @property {TariffMatrix} tariffsMatrix - The tariff matrix for pricing the outbound journey.
12
13
  */
13
- export type JourneyBookingInfo = {
14
+ export type TripBookingInfo = {
14
15
  tripId: number;
15
16
  departureStopId: number;
16
17
  destinationStopId: number;
@@ -21,15 +22,18 @@ export type JourneyBookingInfo = {
21
22
  *
22
23
  * @property {number|undefined} [cartId=0] - The unique identifier for the cart (optional).
23
24
  * @property {Booking.Currencies} currency - The currency in which the journey is priced.
24
- * @property {JourneyBookingInfo[]} outboundJourney - Information about outbound journeys.
25
- * @property {JourneyBookingInfo[]|null} returnJourney - Information about return journeys (optional, can be null).
25
+ * @property {TripBookingInfo[]} outboundJourney - Information about outbound journeys. This is an array of {@link TripBookingInfo} objects.
26
+ * Note that when searching for journeys, the `trips` property of the {@link JourneySearchResult} object contains an array of {@link Trip} objects.
27
+ * Each trip should be mapped into a {@link TripBookingInfo} object.
28
+ * @property {TripBookingInfo[] | null} returnJourney - Information about return journeys (optional, can be null). See outboundJourney.
26
29
  */
27
30
  export type CreateJourneyCartRequest = {
28
31
  cartId?: number;
29
32
  currency: Booking.Currencies;
30
- outboundJourney: JourneyBookingInfo[];
31
- returnJourney: JourneyBookingInfo[] | null;
33
+ outboundJourney: TripBookingInfo[];
34
+ returnJourney: TripBookingInfo[] | null;
32
35
  };
36
+ export declare const DEFAULT_CREATE_JOURNEY_CART: CreateJourneyCartRequest;
33
37
  /**
34
38
  * @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
35
39
  * information about the bookings
@@ -1,2 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CREATE_JOURNEY_CART = void 0;
4
+ var booking_1 = require("../../booking/booking");
5
+ exports.DEFAULT_CREATE_JOURNEY_CART = {
6
+ cartId: 0,
7
+ currency: booking_1.Booking.Currencies.EUR,
8
+ outboundJourney: [],
9
+ returnJourney: null,
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",