mts-booking-library 2.4.12 → 3.0.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.
Files changed (36) hide show
  1. package/lib/booking/booking.d.ts +1 -1
  2. package/lib/booking/journeyBooking.d.ts +46 -6
  3. package/lib/booking/journeyBooking.js +33 -75
  4. package/lib/booking/serviceBooking.d.ts +47 -7
  5. package/lib/booking/serviceBooking.js +33 -73
  6. package/lib/booking/subscriptionBooking.d.ts +45 -3
  7. package/lib/booking/subscriptionBooking.js +30 -38
  8. package/lib/booking/tplBooking.d.ts +46 -6
  9. package/lib/booking/tplBooking.js +27 -78
  10. package/lib/index.d.ts +5 -4
  11. package/lib/index.js +8 -5
  12. package/lib/mtsStorage.d.ts +10 -6
  13. package/lib/types/common/Cart.d.ts +14 -14
  14. package/lib/types/common/Person.d.ts +0 -11
  15. package/lib/types/common/Person.js +1 -11
  16. package/lib/types/common/Tariffs.d.ts +0 -2
  17. package/lib/types/journeys/JourneyCart.d.ts +0 -18
  18. package/lib/types/journeys/JourneyCart.js +0 -8
  19. package/lib/types/journeys/JourneyInfo.d.ts +7 -8
  20. package/lib/types/journeys/JourneySearch.d.ts +3 -3
  21. package/lib/types/journeys/JourneySearch.js +4 -5
  22. package/lib/types/journeys/Stop.d.ts +7 -8
  23. package/lib/types/journeys/Trip.d.ts +8 -1
  24. package/lib/types/services/Service.d.ts +5 -2
  25. package/lib/types/services/ServiceCart.d.ts +0 -23
  26. package/lib/types/subscriptions/SubscriptionAvailabilities.d.ts +20 -22
  27. package/lib/types/subscriptions/SubscriptionCart.d.ts +5 -6
  28. package/lib/types/subscriptions/Subscriptions.d.ts +10 -11
  29. package/lib/types/tpl/TplCart.d.ts +2 -21
  30. package/lib/utils/utils.d.ts +9 -6
  31. package/lib/utils/utils.js +46 -14
  32. package/package.json +15 -15
  33. package/lib/SubscriptionBooking.d.ts +0 -0
  34. package/lib/SubscriptionBooking.js +0 -148
  35. package/lib/utils/testUtils.d.ts +0 -8
  36. package/lib/utils/testUtils.js +0 -19
@@ -121,7 +121,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
121
121
  this.cart = undefined;
122
122
  this.cartGuid = undefined;
123
123
  this.bookingStepsToStatus = new Map();
124
- this.bookingDueDate = undefined;
124
+ this.bookingDueDateLong = undefined;
125
125
  try {
126
126
  this.getStorage().getState().updateCartGuid(undefined);
127
127
  }
@@ -134,28 +134,28 @@ var SubscriptionBooking = /** @class */ (function (_super) {
134
134
  };
135
135
  SubscriptionBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
136
136
  return __awaiter(this, void 0, void 0, function () {
137
- var cart, cartDueDate;
137
+ var cart;
138
138
  return __generator(this, function (_a) {
139
139
  switch (_a.label) {
140
140
  case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
141
141
  case 1:
142
142
  cart = _a.sent();
143
- if (cart) {
144
- cartDueDate = new Date();
145
- cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
146
- if (cartDueDate > new Date() && !cart.hasIssuedTickets) {
147
- this.cart = cart;
148
- this.cartGuid = cart.guid;
149
- this.bookingDueDate = cartDueDate; // See Booking class
150
- // Update the sellerId. This is particularly important in Linkavel
151
- this.updateSellerId(cart.sellerId);
152
- // Fill the booking process status
153
- this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
154
- }
155
- else {
156
- // This should never happen, but just in case
157
- this.resetBooking();
158
- }
143
+ if (!cart)
144
+ return [2 /*return*/];
145
+ if (cart.bookingDueDateLong > 0 &&
146
+ (0, utils_1.getDateFromLong)(cart.bookingDueDateLong) > new Date() &&
147
+ !cart.hasIssuedTickets) {
148
+ this.cart = cart;
149
+ this.cartGuid = cart.guid;
150
+ this.bookingDueDateLong = cart.bookingDueDateLong; // See Booking class
151
+ // Update the sellerId. This is particularly important in Linkavel
152
+ this.updateSellerId(cart.sellerId);
153
+ // Fill the booking process status
154
+ this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
155
+ }
156
+ else {
157
+ // This should never happen, but just in case
158
+ this.resetBooking();
159
159
  }
160
160
  return [2 /*return*/];
161
161
  }
@@ -164,10 +164,17 @@ var SubscriptionBooking = /** @class */ (function (_super) {
164
164
  };
165
165
  SubscriptionBooking.prototype.fetchCart = function (cartGuid, options) {
166
166
  return __awaiter(this, void 0, void 0, function () {
167
- var url;
167
+ var searchParams, url;
168
168
  var _this = this;
169
169
  return __generator(this, function (_a) {
170
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts?").concat(new URLSearchParams({ cartGuid: cartGuid }));
170
+ searchParams = new URLSearchParams({
171
+ cartGuid: cartGuid,
172
+ includeBasicInfo: "true",
173
+ includeEconomicProperties: "true",
174
+ includeBookings: "true",
175
+ includeReductions: "true"
176
+ });
177
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts_v2?").concat(searchParams);
171
178
  return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
172
179
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
173
180
  _this.resetBooking();
@@ -334,7 +341,6 @@ var SubscriptionBooking = /** @class */ (function (_super) {
334
341
  return __generator(this, function (_a) {
335
342
  url = "".concat(this.config.API_ENDPOINT, "/v3_booking/subscriptions/carts");
336
343
  return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
337
- var cartDueDate;
338
344
  return __generator(this, function (_a) {
339
345
  switch (_a.label) {
340
346
  case 0:
@@ -344,23 +350,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
344
350
  this.resetBooking();
345
351
  return [2 /*return*/, response];
346
352
  }
347
- if (!response.cart) return [3 /*break*/, 1];
348
- this.cart = response.cart;
349
- this.cartGuid = response.cart.guid;
350
- // Save the cartGuid in the mts-storage
351
- this.getStorage().getState().updateCartGuid(response.cart.guid);
352
- // Fill the booking process status
353
- this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
354
- cartDueDate = new Date();
355
- cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
356
- this.bookingDueDate = cartDueDate;
357
- // Update the sellerId. This is particularly important in Linkavel
358
- this.updateSellerId(response.cart.sellerId);
359
- return [2 /*return*/, response.cart];
360
- case 1:
361
- // Fetch & update local properties
362
- return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
363
- case 2:
353
+ // Fetch & update local properties
354
+ return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
355
+ case 1:
364
356
  // Fetch & update local properties
365
357
  _a.sent();
366
358
  if (!this.cart) {
@@ -6,7 +6,7 @@ import { AddReductionRequest } from "../types/common/Reduction";
6
6
  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
- import { CreateTplCartRequest, TplCart } from "../types/tpl/TplCart";
9
+ import { TplCart } from "../types/tpl/TplCart";
10
10
  import { ApiCallOptions } from "../utils/apiCall";
11
11
  import { Booking } from "./booking";
12
12
  export declare class TplBooking extends Booking {
@@ -20,7 +20,49 @@ export declare class TplBooking extends Booking {
20
20
  } & {
21
21
  updateCartGuid: (cartGuid: string | undefined) => void;
22
22
  resetState: () => void;
23
- }>, "persist"> & {
23
+ }>, "setState" | "persist"> & {
24
+ setState(partial: ({
25
+ cartGuid: string | undefined;
26
+ } & {
27
+ updateCartGuid: (cartGuid: string | undefined) => void;
28
+ resetState: () => void;
29
+ }) | Partial<{
30
+ cartGuid: string | undefined;
31
+ } & {
32
+ updateCartGuid: (cartGuid: string | undefined) => void;
33
+ resetState: () => void;
34
+ }> | ((state: {
35
+ cartGuid: string | undefined;
36
+ } & {
37
+ updateCartGuid: (cartGuid: string | undefined) => void;
38
+ resetState: () => void;
39
+ }) => ({
40
+ cartGuid: string | undefined;
41
+ } & {
42
+ updateCartGuid: (cartGuid: string | undefined) => void;
43
+ resetState: () => void;
44
+ }) | Partial<{
45
+ cartGuid: string | undefined;
46
+ } & {
47
+ updateCartGuid: (cartGuid: string | undefined) => void;
48
+ resetState: () => void;
49
+ }>), replace?: false | undefined): unknown;
50
+ setState(state: ({
51
+ cartGuid: string | undefined;
52
+ } & {
53
+ updateCartGuid: (cartGuid: string | undefined) => void;
54
+ resetState: () => void;
55
+ }) | ((state: {
56
+ cartGuid: string | undefined;
57
+ } & {
58
+ updateCartGuid: (cartGuid: string | undefined) => void;
59
+ resetState: () => void;
60
+ }) => {
61
+ cartGuid: string | undefined;
62
+ } & {
63
+ updateCartGuid: (cartGuid: string | undefined) => void;
64
+ resetState: () => void;
65
+ }), replace: true): unknown;
24
66
  persist: {
25
67
  setOptions: (options: Partial<import("zustand/middleware").PersistOptions<{
26
68
  cartGuid: string | undefined;
@@ -32,7 +74,7 @@ export declare class TplBooking extends Booking {
32
74
  } & {
33
75
  updateCartGuid: (cartGuid: string | undefined) => void;
34
76
  resetState: () => void;
35
- }>>) => void;
77
+ }, unknown>>) => void;
36
78
  clearStorage: () => void;
37
79
  rehydrate: () => Promise<void> | void;
38
80
  hasHydrated: () => boolean;
@@ -58,7 +100,7 @@ export declare class TplBooking extends Booking {
58
100
  } & {
59
101
  updateCartGuid: (cartGuid: string | undefined) => void;
60
102
  resetState: () => void;
61
- }>>;
103
+ }, unknown>>;
62
104
  };
63
105
  }>;
64
106
  getCart(): undefined | TplCart;
@@ -108,8 +150,6 @@ export declare class TplBooking extends Booking {
108
150
  * @returns The created cart
109
151
  */
110
152
  createCart(request: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | TplCart>;
111
- /** @deprecated Use {@link createCart} instead. */
112
- createTplCart(tplCart: CreateTplCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | TplCart>;
113
153
  /**
114
154
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
115
155
  * @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
@@ -121,7 +121,7 @@ var TplBooking = /** @class */ (function (_super) {
121
121
  this.cart = undefined;
122
122
  this.cartGuid = undefined;
123
123
  this.bookingStepsToStatus = new Map();
124
- this.bookingDueDate = undefined;
124
+ this.bookingDueDateLong = undefined;
125
125
  try {
126
126
  this.getStorage().getState().updateCartGuid(undefined);
127
127
  }
@@ -134,28 +134,28 @@ var TplBooking = /** @class */ (function (_super) {
134
134
  };
135
135
  TplBooking.prototype.fetchAndSetCart = function (cartGuid, options) {
136
136
  return __awaiter(this, void 0, void 0, function () {
137
- var cart, cartDueDate;
137
+ var cart;
138
138
  return __generator(this, function (_a) {
139
139
  switch (_a.label) {
140
140
  case 0: return [4 /*yield*/, this.fetchCart(cartGuid, options)];
141
141
  case 1:
142
142
  cart = _a.sent();
143
- if (cart) {
144
- cartDueDate = new Date();
145
- cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
146
- if (cartDueDate > new Date() && !cart.hasIssuedTickets) {
147
- this.cart = cart;
148
- this.cartGuid = cart.guid;
149
- this.bookingDueDate = cartDueDate; // See Booking class
150
- // Update the sellerId. This is particularly important in Linkavel
151
- this.updateSellerId(cart.sellerId);
152
- // Fill the booking process status
153
- this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
154
- }
155
- else {
156
- // This should never happen, but just in case
157
- this.resetBooking();
158
- }
143
+ if (!cart)
144
+ return [2 /*return*/];
145
+ if (cart.bookingDueDateLong > 0 &&
146
+ (0, utils_1.getDateFromLong)(cart.bookingDueDateLong) > new Date() &&
147
+ !cart.hasIssuedTickets) {
148
+ this.cart = cart;
149
+ this.cartGuid = cart.guid;
150
+ this.bookingDueDateLong = cart.bookingDueDateLong; // See Booking class
151
+ // Update the sellerId. This is particularly important in Linkavel
152
+ this.updateSellerId(cart.sellerId);
153
+ // Fill the booking process status
154
+ this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
155
+ }
156
+ else {
157
+ // This should never happen, but just in case
158
+ this.resetBooking();
159
159
  }
160
160
  return [2 /*return*/];
161
161
  }
@@ -164,10 +164,17 @@ var TplBooking = /** @class */ (function (_super) {
164
164
  };
165
165
  TplBooking.prototype.fetchCart = function (cartGuid, options) {
166
166
  return __awaiter(this, void 0, void 0, function () {
167
- var url;
167
+ var searchParams, url;
168
168
  var _this = this;
169
169
  return __generator(this, function (_a) {
170
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts?").concat(new URLSearchParams({ cartGuid: cartGuid }));
170
+ searchParams = new URLSearchParams({
171
+ cartGuid: cartGuid,
172
+ includeBasicInfo: "true",
173
+ includeEconomicProperties: "true",
174
+ includeBookings: "true",
175
+ includeReductions: "true"
176
+ });
177
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts_v2?").concat(searchParams);
171
178
  return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
172
179
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
173
180
  _this.resetBooking();
@@ -344,64 +351,6 @@ var TplBooking = /** @class */ (function (_super) {
344
351
  });
345
352
  });
346
353
  };
347
- /** @deprecated Use {@link createCart} instead. */
348
- TplBooking.prototype.createTplCart = function (tplCart, options) {
349
- return __awaiter(this, void 0, void 0, function () {
350
- var url, processedTariffIdToQuantity, request;
351
- var _this = this;
352
- return __generator(this, function (_a) {
353
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/tpl/carts");
354
- processedTariffIdToQuantity = {};
355
- tplCart.tariffIdToQuantity.forEach(function (value, key) {
356
- processedTariffIdToQuantity[key] = value;
357
- });
358
- request = __assign(__assign(__assign(__assign(__assign({ tariffIdToQuantity: processedTariffIdToQuantity, currency: tplCart.currency }, (tplCart.startDate !== undefined && { startDate: tplCart.startDate })), (tplCart.isCurrentPeriod !== undefined && { isCurrentPeriod: tplCart.isCurrentPeriod })), (tplCart.renewSubscriptionTicketPNR !== undefined && {
359
- renewSubscriptionTicketPNR: tplCart.renewSubscriptionTicketPNR
360
- })), (tplCart.otaResellerId !== undefined && { otaResellerId: tplCart.otaResellerId })), (tplCart.otaTicketPicture !== undefined && { otaTicketPicture: tplCart.otaTicketPicture }));
361
- // Call the API
362
- return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
363
- var cartDueDate;
364
- return __generator(this, function (_a) {
365
- switch (_a.label) {
366
- case 0:
367
- // Check for errors
368
- if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
369
- // If there was an error, reset cartGuid and remove it from the mts-storage
370
- this.resetBooking();
371
- return [2 /*return*/, response];
372
- }
373
- if (!response.cart) return [3 /*break*/, 1];
374
- this.cart = response.cart;
375
- this.cartGuid = response.cart.guid;
376
- // Save the cartGuid in the mts-storage
377
- this.getStorage().getState().updateCartGuid(response.cart.guid);
378
- // Fill the booking process status
379
- this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
380
- cartDueDate = new Date();
381
- cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
382
- this.bookingDueDate = cartDueDate;
383
- // Update the sellerId. This is particularly important in Linkavel
384
- this.updateSellerId(response.cart.sellerId);
385
- return [2 /*return*/, response.cart];
386
- case 1:
387
- // Fetch & update local properties
388
- return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
389
- case 2:
390
- // Fetch & update local properties
391
- _a.sent();
392
- if (!this.cart) {
393
- // Should already be handled, but just in case
394
- throw new Error("Could not fetch cart");
395
- }
396
- // Update storage
397
- this.getStorage().getState().updateCartGuid(response.cartGuid);
398
- return [2 /*return*/, this.cart];
399
- }
400
- });
401
- }); })];
402
- });
403
- });
404
- };
405
354
  //#region PersonDetails data API
406
355
  /**
407
356
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
package/lib/index.d.ts CHANGED
@@ -4,9 +4,10 @@ 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 { getLongFromDate, getDateFromLong, isNullOrUndefined, isNullOrWhiteSpace } from "./utils/utils";
7
8
  export { CreateUpdateCartRequest, CartBooking } from "./types/common/Cart";
8
9
  export { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
9
- export { GetBuyerPassengersDetailsResponse, GetPersonRequest, GetPassenger, BuyerDataStatus, EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
10
+ export { GetBuyerPassengersDetailsResponse, GetPersonRequest, GetPassenger, EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
10
11
  export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
11
12
  export { ReductionType, Reduction, AddReductionRequest } from "./types/common/Reduction";
12
13
  export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, IssueCartResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
@@ -14,18 +15,18 @@ export { ErrorResponse, objectIsMTSErrorResponse } from "./types/ErrorResponse";
14
15
  export { City } from "./types/common/City";
15
16
  export { Extra, GetExtrasResponse, GetExtrasForBookingResponse } from "./types/common/Extra";
16
17
  export { BusLayoutCell, BusMatrix, BusCellTypes, SeatStatus } from "./types/journeys/BusMatrix";
17
- export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, TripBookingInfo, DEFAULT_CREATE_JOURNEY_CART } from "./types/journeys/JourneyCart";
18
+ export { JourneyCart, JourneyBookingType, TripBookingInfo } from "./types/journeys/JourneyCart";
18
19
  export { JourneyInfo } from "./types/journeys/JourneyInfo";
19
20
  export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
20
21
  export { Stop } from "./types/journeys/Stop";
21
22
  export { Trip, CartTrip, ReductionTrip } from "./types/journeys/Trip";
22
23
  export { Line } from "./types/services/Line";
23
24
  export { Service, ServiceTrip, ServiceTripsResponse } from "./types/services/Service";
24
- export { ServiceCart, ServiceBookingType, CreateServiceCartRequest } from "./types/services/ServiceCart";
25
+ export { ServiceCart, ServiceBookingType } from "./types/services/ServiceCart";
25
26
  export { ServiceInfo } from "./types/services/ServiceInfo";
26
27
  export { GetTariffsResponse } from "./types/tpl/GetTariffsResponse";
27
28
  export { SuperArea, GetSuperAreasRequest } from "./types/tpl/SuperArea";
28
- export { CreateTplCartRequest, TplCart, TplBookingType, TplBookingInfo } from "./types/tpl/TplCart";
29
+ export { TplCart, TplBookingType, TplBookingInfo } from "./types/tpl/TplCart";
29
30
  export { Subscription } from "./types/subscriptions/Subscriptions";
30
31
  export { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse, SubscriptionCalendarDayPeriodInfo } from "./types/subscriptions/SubscriptionAvailabilities";
31
32
  export { SubscriptionCart, SubscriptionBookingType, CreateSubscriptionCartRequest, SubscriptionPeriod } from "./types/subscriptions/SubscriptionCart";
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_CREATE_JOURNEY_CART = exports.SeatStatus = exports.BusCellTypes = exports.objectIsMTSErrorResponse = exports.PaymentMethods = exports.GatewayTypes = exports.ReductionType = exports.BuyerDataStatus = exports.initializePerson = exports.DEFAULT_PERSON = exports.useMtsBookingState = exports.TplBooking = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
3
+ exports.DEFAULT_JOURNEY_SEARCH = exports.SeatStatus = exports.BusCellTypes = exports.objectIsMTSErrorResponse = exports.PaymentMethods = exports.GatewayTypes = exports.ReductionType = exports.initializePerson = exports.DEFAULT_PERSON = exports.isNullOrWhiteSpace = exports.isNullOrUndefined = exports.getDateFromLong = exports.getLongFromDate = exports.useMtsBookingState = exports.TplBooking = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
4
4
  //#region Export Booking classes
5
5
  var booking_1 = require("./booking/booking");
6
6
  Object.defineProperty(exports, "Booking", { enumerable: true, get: function () { return booking_1.Booking; } });
@@ -16,11 +16,16 @@ Object.defineProperty(exports, "TplBooking", { enumerable: true, get: function (
16
16
  //#region Export Zustand states
17
17
  var mtsStorage_1 = require("./mtsStorage");
18
18
  Object.defineProperty(exports, "useMtsBookingState", { enumerable: true, get: function () { return mtsStorage_1.useMtsBookingState; } });
19
+ //#endregion
20
+ //#region Export utils
21
+ var utils_1 = require("./utils/utils");
22
+ Object.defineProperty(exports, "getLongFromDate", { enumerable: true, get: function () { return utils_1.getLongFromDate; } });
23
+ Object.defineProperty(exports, "getDateFromLong", { enumerable: true, get: function () { return utils_1.getDateFromLong; } });
24
+ Object.defineProperty(exports, "isNullOrUndefined", { enumerable: true, get: function () { return utils_1.isNullOrUndefined; } });
25
+ Object.defineProperty(exports, "isNullOrWhiteSpace", { enumerable: true, get: function () { return utils_1.isNullOrWhiteSpace; } });
19
26
  var Person_1 = require("./types/common/Person");
20
27
  Object.defineProperty(exports, "DEFAULT_PERSON", { enumerable: true, get: function () { return Person_1.DEFAULT_PERSON; } });
21
28
  Object.defineProperty(exports, "initializePerson", { enumerable: true, get: function () { return Person_1.initializePerson; } });
22
- var Person_2 = require("./types/common/Person");
23
- Object.defineProperty(exports, "BuyerDataStatus", { enumerable: true, get: function () { return Person_2.BuyerDataStatus; } });
24
29
  var Reduction_1 = require("./types/common/Reduction");
25
30
  Object.defineProperty(exports, "ReductionType", { enumerable: true, get: function () { return Reduction_1.ReductionType; } });
26
31
  var Payment_1 = require("./types/common/Payment");
@@ -33,8 +38,6 @@ Object.defineProperty(exports, "objectIsMTSErrorResponse", { enumerable: true, g
33
38
  var BusMatrix_1 = require("./types/journeys/BusMatrix");
34
39
  Object.defineProperty(exports, "BusCellTypes", { enumerable: true, get: function () { return BusMatrix_1.BusCellTypes; } });
35
40
  Object.defineProperty(exports, "SeatStatus", { enumerable: true, get: function () { return BusMatrix_1.SeatStatus; } });
36
- var JourneyCart_1 = require("./types/journeys/JourneyCart");
37
- Object.defineProperty(exports, "DEFAULT_CREATE_JOURNEY_CART", { enumerable: true, get: function () { return JourneyCart_1.DEFAULT_CREATE_JOURNEY_CART; } });
38
41
  var JourneySearch_1 = require("./types/journeys/JourneySearch");
39
42
  Object.defineProperty(exports, "DEFAULT_JOURNEY_SEARCH", { enumerable: true, get: function () { return JourneySearch_1.DEFAULT_JOURNEY_SEARCH; } });
40
43
  //#endregion
@@ -8,26 +8,30 @@ type MtsBookingAction = {
8
8
  /**
9
9
  * This hook will return the correct Zustand state based on the application which runs the library
10
10
  */
11
- export declare const useMtsBookingState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
11
+ export declare const useMtsBookingState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "setState" | "persist"> & {
12
+ setState(partial: (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction> | ((state: MtsBookingState & MtsBookingAction) => (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction>), replace?: false | undefined): unknown;
13
+ setState(state: (MtsBookingState & MtsBookingAction) | ((state: MtsBookingState & MtsBookingAction) => MtsBookingState & MtsBookingAction), replace: true): unknown;
12
14
  persist: {
13
- setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
15
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>) => void;
14
16
  clearStorage: () => void;
15
17
  rehydrate: () => Promise<void> | void;
16
18
  hasHydrated: () => boolean;
17
19
  onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
18
20
  onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
19
- getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
21
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>;
20
22
  };
21
23
  }>;
22
- export declare const useTestState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
24
+ export declare const useTestState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "setState" | "persist"> & {
25
+ setState(partial: (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction> | ((state: MtsBookingState & MtsBookingAction) => (MtsBookingState & MtsBookingAction) | Partial<MtsBookingState & MtsBookingAction>), replace?: false | undefined): unknown;
26
+ setState(state: (MtsBookingState & MtsBookingAction) | ((state: MtsBookingState & MtsBookingAction) => MtsBookingState & MtsBookingAction), replace: true): unknown;
23
27
  persist: {
24
- setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
28
+ setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>) => void;
25
29
  clearStorage: () => void;
26
30
  rehydrate: () => Promise<void> | void;
27
31
  hasHydrated: () => boolean;
28
32
  onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
29
33
  onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
30
- getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
34
+ getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction, unknown>>;
31
35
  };
32
36
  }>;
33
37
  export {};
@@ -26,14 +26,12 @@ export type CreateUpdateCartRequest = {
26
26
  export type CartBooking = {
27
27
  /** A record containing tariff ids as keys and their respective quantities as values. */
28
28
  tariffIdToQuantity?: Record<number, number>;
29
- /** The date of the booking in ISO string format (optional). */
30
- date?: string;
29
+ /** The date of the booking in YYYYMMDDHHMMSSMMM format (optional). The time refers to the local time zone of the seller. */
30
+ dateTimeLocalLong?: number;
31
31
  /** The id of the trip, if necessary. For example, this is used by services that require a specific trip to be selected, or by MLP booking */
32
32
  tripId?: number;
33
33
  /** The id of the line, if necessary. For example, this is used by Services */
34
34
  lineId?: number;
35
- /** The start date of the booking, if necessary. For example, this is used by TPL subscriptions. */
36
- startDate?: string;
37
35
  /** If true, then the booking will be the current period (e.g. this month or this year), otherwise it will be the next period. */
38
36
  isCurrentPeriod?: boolean;
39
37
  /** The PNR of the ticket of reference, if necessary. For example, this is used in TPL when renewing a subscription. */
@@ -62,10 +60,14 @@ export type Cart = {
62
60
  sellerTermsUrl: string;
63
61
  /** The support email of the seller, if any */
64
62
  sellerEmailLinkavel: string | null;
65
- /** The code of the cart */
66
- cartCode: string;
63
+ /** The id of the buyer that the cart is for. */
64
+ buyerId: number | null;
67
65
  /** If true, the tickets in the cart will be automatically printer after the payment */
68
66
  autoPrintOption: boolean;
67
+ /** The ids of the tickets in the cart */
68
+ ticketIds: number[];
69
+ /** The PNRs of the tickets in the cart */
70
+ ticketsPNRs: string[];
69
71
  /**
70
72
  * A boolean telling whether the cart has issued tickets.
71
73
  * Note that if this is the case, the cart will be null because it is not
@@ -84,10 +86,8 @@ export type Cart = {
84
86
  * - The third tells whether the section is required.
85
87
  */
86
88
  stepsToStatus: Record<Booking.BookingSteps, [boolean, boolean, boolean]>;
87
- /** The currency of the cart. See {@link Booking.Currencies} */
88
- currency: Booking.Currencies;
89
- /** The date and time when the cart expires */
90
- bookingDueDate: string;
89
+ /** The date and time when the cart expires in YYYYMMDDHHMMSSMMM format */
90
+ bookingDueDateLong: number;
91
91
  /**
92
92
  * The number of seconds remaining before the cart expires. This should be equivalent
93
93
  * `bookingDueDate`
@@ -99,6 +99,10 @@ export type Cart = {
99
99
  extras: Extra[];
100
100
  /** The selling method of the cart (LinkAvel, Backoffice) */
101
101
  sellingMethod: SellingMethod;
102
+ /** Whether the cart is not associated with a specific SSN. */
103
+ noSSN: boolean;
104
+ /** The currency of the cart. See {@link Booking.Currencies} */
105
+ currency: Booking.Currencies;
102
106
  /**
103
107
  * The total value of the cart, meaning the sum of the nominal prices of all tickets.
104
108
  * It is expressed in the currency of the cart.
@@ -126,10 +130,6 @@ export type Cart = {
126
130
  * The first element of the list is the default cash in method (and the preferred by the seller).
127
131
  */
128
132
  cashInMethods: PaymentMethods[];
129
- /**
130
- * Whether the cart is not associated with a specific SSN.
131
- */
132
- noSSN: boolean;
133
133
  };
134
134
  /** The type that {@link Cart.stepsToStatus} assumes once parsed to a map */
135
135
  export type processedStepsToStatus = Map<Booking.BookingSteps, [boolean, boolean, boolean]>;
@@ -56,15 +56,6 @@ export type GetPassenger = Person & {
56
56
  /** Whether the passenger social security number is reuqired, optional or cannot be specified. */
57
57
  passengerSSNOption: PersonDataFieldStatus;
58
58
  };
59
- /** @deprecated Use PersonDataFieldStatus */
60
- export declare enum BuyerDataStatus {
61
- /** The buyer data are optional. PersonDetails form shall be displayed, but the user can skip it. */
62
- OPTIONAL = 0,
63
- /** The buyer data are required. PersonDetails form shall be displayed and the user cannot skip it. */
64
- REQUIRED = 1,
65
- /** The buyer data cannot be specified. PersonDetails form shall not be displayed. */
66
- CANNOT_BE_SPECIFIED = 2
67
- }
68
59
  export declare enum PersonDataFieldStatus {
69
60
  /** The field (e.g. the buyer's email) is optional. The input shall be displayed, but the user can skip it. */
70
61
  OPTIONAL = "OPTIONAL",
@@ -75,8 +66,6 @@ export declare enum PersonDataFieldStatus {
75
66
  }
76
67
  /** Represents the response of the {@link getBuyerPassengersDetails} method. */
77
68
  export type GetBuyerPassengersDetailsResponse = {
78
- /** @deprecated Whether the form for the buyer data is required, optional or cannot be specified. */
79
- buyerDataStatus: BuyerDataStatus;
80
69
  /** The {@link Person} object representing the buyer. */
81
70
  buyer: Person | null;
82
71
  /** Whether the buyer name and last name are required, optional or cannot be specified. */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PersonDataFieldStatus = exports.BuyerDataStatus = exports.initializePerson = exports.DEFAULT_PERSON = void 0;
3
+ exports.PersonDataFieldStatus = exports.initializePerson = exports.DEFAULT_PERSON = void 0;
4
4
  exports.DEFAULT_PERSON = {
5
5
  id: 0,
6
6
  personCode: "",
@@ -17,16 +17,6 @@ var initializePerson = function (person) {
17
17
  return person;
18
18
  };
19
19
  exports.initializePerson = initializePerson;
20
- /** @deprecated Use PersonDataFieldStatus */
21
- var BuyerDataStatus;
22
- (function (BuyerDataStatus) {
23
- /** The buyer data are optional. PersonDetails form shall be displayed, but the user can skip it. */
24
- BuyerDataStatus[BuyerDataStatus["OPTIONAL"] = 0] = "OPTIONAL";
25
- /** The buyer data are required. PersonDetails form shall be displayed and the user cannot skip it. */
26
- BuyerDataStatus[BuyerDataStatus["REQUIRED"] = 1] = "REQUIRED";
27
- /** The buyer data cannot be specified. PersonDetails form shall not be displayed. */
28
- BuyerDataStatus[BuyerDataStatus["CANNOT_BE_SPECIFIED"] = 2] = "CANNOT_BE_SPECIFIED";
29
- })(BuyerDataStatus || (exports.BuyerDataStatus = BuyerDataStatus = {}));
30
20
  var PersonDataFieldStatus;
31
21
  (function (PersonDataFieldStatus) {
32
22
  /** The field (e.g. the buyer's email) is optional. The input shall be displayed, but the user can skip it. */
@@ -20,8 +20,6 @@ export type Tariff = {
20
20
  extraId: number | null;
21
21
  /** The value of the tariff (in the currency specified in the {@link Booking} object) */
22
22
  value: number;
23
- /** @deprecated Use {@link Tariff.valueCurrencies} instead */
24
- currency: null;
25
23
  /** The value of the tariff in the different currencies */
26
24
  valueCurrencies: {
27
25
  percentage: number | null;
@@ -22,24 +22,6 @@ export type TripBookingInfo = {
22
22
  /** A string in base64 representing the picture of the ticket that was sold */
23
23
  otaTicketPicture?: string;
24
24
  };
25
- /**
26
- * @description This is the object to be passed to {@link JourneyBooking.createJourneyCart}, containing information about the selected service.
27
- */
28
- export type CreateJourneyCartRequest = {
29
- /** The unique identifier for the cart. This should be passed during the change process to link the new ticket to the already existing change cart */
30
- cartGuid?: string;
31
- /** The currency in which the journey is priced */
32
- currency: Booking.Currencies;
33
- /**
34
- * Information about outbound journeys. This is an array of {@link TripBookingInfo} objects.
35
- * Note that when searching for journeys, the `trips` property of the {@link JourneySearchResult} object contains an array of {@link Trip} objects.
36
- * Each trip should be mapped into a {@link TripBookingInfo} object.
37
- */
38
- outboundJourney: TripBookingInfo[];
39
- /** Information about return journeys (optional, can be null). See outboundJourney. */
40
- returnJourney: TripBookingInfo[] | null;
41
- };
42
- export declare const DEFAULT_CREATE_JOURNEY_CART: CreateJourneyCartRequest;
43
25
  /**
44
26
  * @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
45
27
  * information about the bookings
@@ -1,10 +1,2 @@
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
- cartGuid: undefined,
7
- currency: booking_1.Booking.Currencies.EUR,
8
- outboundJourney: [],
9
- returnJourney: null
10
- };