mts-booking-library 2.4.11 → 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.
@@ -23,7 +23,7 @@ export declare abstract class Booking {
23
23
  */
24
24
  bookingStepsToStatus: processedStepsToStatus;
25
25
  cartGuid: string | undefined;
26
- bookingDueDate: Date | undefined;
26
+ bookingDueDateLong: number | undefined;
27
27
  /**
28
28
  * This is the constructor of the Booking class. See {@link Booking.BookingConfig} for more information.
29
29
  */
@@ -3,7 +3,7 @@ import { CreateUpdateCartRequest } from "../types/common/Cart";
3
3
  import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse } from "../types/common/Person";
4
4
  import { AddReductionRequest } from "../types/common/Reduction";
5
5
  import { BusMatrix } from "../types/journeys/BusMatrix";
6
- import { CreateJourneyCartRequest, JourneyCart } from "../types/journeys/JourneyCart";
6
+ import { JourneyCart } from "../types/journeys/JourneyCart";
7
7
  import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/JourneySearch";
8
8
  import { ReductionTrip } from "../types/journeys/Trip";
9
9
  import { ApiCallOptions } from "../utils/apiCall";
@@ -20,7 +20,49 @@ export declare class JourneyBooking 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 JourneyBooking 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 JourneyBooking extends Booking {
58
100
  } & {
59
101
  updateCartGuid: (cartGuid: string | undefined) => void;
60
102
  resetState: () => void;
61
- }>>;
103
+ }, unknown>>;
62
104
  };
63
105
  }>;
64
106
  resetBooking(): void;
@@ -93,9 +135,7 @@ export declare class JourneyBooking extends Booking {
93
135
  * This method creates a journey cart (MLP) for the given parameters.
94
136
  * @returns The created cart
95
137
  */
96
- createCart(request: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | JourneyCart>;
97
- /** @deprecated Use {@link createCart} instead. */
98
- createJourneyCart(journeyCart: CreateJourneyCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | JourneyCart>;
138
+ createCart(cartRequest: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | JourneyCart>;
99
139
  /**
100
140
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
101
141
  * @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
@@ -121,7 +121,7 @@ var JourneyBooking = /** @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 JourneyBooking = /** @class */ (function (_super) {
134
134
  };
135
135
  JourneyBooking.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 JourneyBooking = /** @class */ (function (_super) {
164
164
  };
165
165
  JourneyBooking.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();
@@ -247,13 +254,15 @@ var JourneyBooking = /** @class */ (function (_super) {
247
254
  JourneyBooking.prototype.getJourneys = function (request, options) {
248
255
  return __awaiter(this, void 0, void 0, function () {
249
256
  var searchParams, url;
250
- var _a, _b, _c;
251
- return __generator(this, function (_d) {
257
+ var _a, _b, _c, _d;
258
+ return __generator(this, function (_e) {
252
259
  if (request.departureStopName === undefined || request.destinationStopName === undefined) {
253
260
  throw Error("Fields departureStopName and destinationStopName are required");
254
261
  }
255
- searchParams = new URLSearchParams(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(), date: request.date, roundTripDate: (_a = request.roundTripDate) !== null && _a !== void 0 ? _a : "null", currency: request.currency, outboundTripId: (_c = (_b = request.outboundTripId) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "null" }, (this.cartGuid && { cartGuid: this.cartGuid })));
256
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys?").concat(searchParams);
262
+ searchParams = new URLSearchParams(__assign(__assign({ departureStopName: request.departureStopName, destinationStopName: request.destinationStopName, passengersNumber: request.passengersNumber.toString(), dateTimeLocalLong: request.dateTimeLocalLong.toString(), roundTripDateTimeLocalLong: (_b = (_a = request.roundTripDateTimeLocalLong) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "null", currency: request.currency, outboundTripId: (_d = (_c = request.outboundTripId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "null" }, (this.cartGuid && { cartGuid: this.cartGuid })), {
263
+ // TODO: delete once it will be removed from APIM
264
+ date: "null" }));
265
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys_v4?").concat(searchParams);
257
266
  return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
258
267
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
259
268
  ? response
@@ -266,12 +275,13 @@ var JourneyBooking = /** @class */ (function (_super) {
266
275
  * This method creates a journey cart (MLP) for the given parameters.
267
276
  * @returns The created cart
268
277
  */
269
- JourneyBooking.prototype.createCart = function (request, options) {
278
+ JourneyBooking.prototype.createCart = function (cartRequest, options) {
270
279
  return __awaiter(this, void 0, void 0, function () {
271
- var url;
280
+ var url, request;
272
281
  var _this = this;
273
282
  return __generator(this, function (_a) {
274
283
  url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts");
284
+ request = __assign(__assign({}, cartRequest), (this.cartGuid && { cartGuid: this.cartGuid }));
275
285
  return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
276
286
  return __generator(this, function (_a) {
277
287
  switch (_a.label) {
@@ -300,57 +310,6 @@ var JourneyBooking = /** @class */ (function (_super) {
300
310
  });
301
311
  });
302
312
  };
303
- /** @deprecated Use {@link createCart} instead. */
304
- JourneyBooking.prototype.createJourneyCart = function (journeyCart, options) {
305
- return __awaiter(this, void 0, void 0, function () {
306
- var url, request;
307
- var _this = this;
308
- return __generator(this, function (_a) {
309
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/carts");
310
- request = __assign(__assign({}, journeyCart), (this.cartGuid && { cartGuid: this.cartGuid }));
311
- return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
312
- var cartDueDate;
313
- return __generator(this, function (_a) {
314
- switch (_a.label) {
315
- case 0:
316
- // Check for errors
317
- if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
318
- // If there was an error, reset cartGuid and remove it from the mts-storage
319
- this.resetBooking();
320
- return [2 /*return*/, response];
321
- }
322
- if (!response.cart) return [3 /*break*/, 1];
323
- this.cart = response.cart;
324
- this.cartGuid = response.cart.guid;
325
- // Save the cartGuid in the storage
326
- this.getStorage().getState().updateCartGuid(response.cart.guid);
327
- // Fill the booking process status
328
- this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
329
- cartDueDate = new Date();
330
- cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
331
- this.bookingDueDate = cartDueDate;
332
- // Update the sellerId. This is particularly important in Linkavel
333
- this.updateSellerId(response.cart.sellerId);
334
- return [2 /*return*/, response.cart];
335
- case 1:
336
- // Fetch & update local properties
337
- return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
338
- case 2:
339
- // Fetch & update local properties
340
- _a.sent();
341
- if (!this.cart) {
342
- // Should already be handled, but just in case
343
- throw new Error("Could not fetch cart");
344
- }
345
- // Update storage
346
- this.getStorage().getState().updateCartGuid(response.cartGuid);
347
- return [2 /*return*/, this.cart];
348
- }
349
- });
350
- }); })];
351
- });
352
- });
353
- };
354
313
  /**
355
314
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
356
315
  * @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
@@ -3,7 +3,7 @@ import { CreateUpdateCartRequest } from "../types/common/Cart";
3
3
  import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
4
4
  import { AddReductionRequest } from "../types/common/Reduction";
5
5
  import { Service, ServiceTripsResponse } from "../types/services/Service";
6
- import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
6
+ import { ServiceCart } from "../types/services/ServiceCart";
7
7
  import { ApiCallOptions } from "../utils/apiCall";
8
8
  import { Booking } from "./booking";
9
9
  export declare class ServiceBooking extends Booking {
@@ -17,7 +17,49 @@ export declare class ServiceBooking extends Booking {
17
17
  } & {
18
18
  updateCartGuid: (cartGuid: string | undefined) => void;
19
19
  resetState: () => void;
20
- }>, "persist"> & {
20
+ }>, "setState" | "persist"> & {
21
+ setState(partial: ({
22
+ cartGuid: string | undefined;
23
+ } & {
24
+ updateCartGuid: (cartGuid: string | undefined) => void;
25
+ resetState: () => void;
26
+ }) | Partial<{
27
+ cartGuid: string | undefined;
28
+ } & {
29
+ updateCartGuid: (cartGuid: string | undefined) => void;
30
+ resetState: () => void;
31
+ }> | ((state: {
32
+ cartGuid: string | undefined;
33
+ } & {
34
+ updateCartGuid: (cartGuid: string | undefined) => void;
35
+ resetState: () => void;
36
+ }) => ({
37
+ cartGuid: string | undefined;
38
+ } & {
39
+ updateCartGuid: (cartGuid: string | undefined) => void;
40
+ resetState: () => void;
41
+ }) | Partial<{
42
+ cartGuid: string | undefined;
43
+ } & {
44
+ updateCartGuid: (cartGuid: string | undefined) => void;
45
+ resetState: () => void;
46
+ }>), replace?: false | undefined): unknown;
47
+ setState(state: ({
48
+ cartGuid: string | undefined;
49
+ } & {
50
+ updateCartGuid: (cartGuid: string | undefined) => void;
51
+ resetState: () => void;
52
+ }) | ((state: {
53
+ cartGuid: string | undefined;
54
+ } & {
55
+ updateCartGuid: (cartGuid: string | undefined) => void;
56
+ resetState: () => void;
57
+ }) => {
58
+ cartGuid: string | undefined;
59
+ } & {
60
+ updateCartGuid: (cartGuid: string | undefined) => void;
61
+ resetState: () => void;
62
+ }), replace: true): unknown;
21
63
  persist: {
22
64
  setOptions: (options: Partial<import("zustand/middleware").PersistOptions<{
23
65
  cartGuid: string | undefined;
@@ -29,7 +71,7 @@ export declare class ServiceBooking extends Booking {
29
71
  } & {
30
72
  updateCartGuid: (cartGuid: string | undefined) => void;
31
73
  resetState: () => void;
32
- }>>) => void;
74
+ }, unknown>>) => void;
33
75
  clearStorage: () => void;
34
76
  rehydrate: () => Promise<void> | void;
35
77
  hasHydrated: () => boolean;
@@ -55,7 +97,7 @@ export declare class ServiceBooking extends Booking {
55
97
  } & {
56
98
  updateCartGuid: (cartGuid: string | undefined) => void;
57
99
  resetState: () => void;
58
- }>>;
100
+ }, unknown>>;
59
101
  };
60
102
  }>;
61
103
  getCart(): ServiceCart | undefined;
@@ -90,14 +132,12 @@ export declare class ServiceBooking extends Booking {
90
132
  * @param date The date on which to get the tours, in ISO string format
91
133
  * @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
92
134
  */
93
- getServiceTrips(serviceId: number, date: string, options?: ApiCallOptions): Promise<ErrorResponse | ServiceTripsResponse>;
135
+ getServiceTrips(serviceId: number, dateLong: number, options?: ApiCallOptions): Promise<ErrorResponse | ServiceTripsResponse>;
94
136
  /**
95
137
  * This method creates a service cart for the given parameters.
96
138
  * @returns The created cart
97
139
  */
98
140
  createCart(request: CreateUpdateCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | ServiceCart>;
99
- /** @deprecated Use {@link createCart} instead. */
100
- createServiceCart(serviceCart: CreateServiceCartRequest, options?: ApiCallOptions): Promise<ErrorResponse | ServiceCart>;
101
141
  /**
102
142
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
103
143
  * @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
@@ -121,7 +121,7 @@ var ServiceBooking = /** @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 ServiceBooking = /** @class */ (function (_super) {
134
134
  };
135
135
  ServiceBooking.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 ServiceBooking = /** @class */ (function (_super) {
164
164
  };
165
165
  ServiceBooking.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();
@@ -248,11 +255,15 @@ var ServiceBooking = /** @class */ (function (_super) {
248
255
  * @param date The date on which to get the tours, in ISO string format
249
256
  * @returns {ServiceTripsResponse} The returned information about the tour (tripId and hour)
250
257
  */
251
- ServiceBooking.prototype.getServiceTrips = function (serviceId, date, options) {
258
+ ServiceBooking.prototype.getServiceTrips = function (serviceId, dateLong, options) {
252
259
  return __awaiter(this, void 0, void 0, function () {
253
260
  var searchParams, url;
254
261
  return __generator(this, function (_a) {
255
- searchParams = new URLSearchParams({ serviceId: serviceId.toString(), date: date });
262
+ searchParams = new URLSearchParams({
263
+ serviceId: serviceId.toString(),
264
+ dateLong: dateLong.toString(),
265
+ date: "null"
266
+ });
256
267
  url = "".concat(this.config.API_ENDPOINT, "/v3_booking/services/trips?").concat(searchParams);
257
268
  return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
258
269
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
@@ -298,57 +309,6 @@ var ServiceBooking = /** @class */ (function (_super) {
298
309
  });
299
310
  });
300
311
  };
301
- /** @deprecated Use {@link createCart} instead. */
302
- ServiceBooking.prototype.createServiceCart = function (serviceCart, options) {
303
- return __awaiter(this, void 0, void 0, function () {
304
- var url;
305
- var _this = this;
306
- return __generator(this, function (_a) {
307
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/services/carts");
308
- return [2 /*return*/, this.callPostApi(url, serviceCart, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
309
- var cartDueDate;
310
- return __generator(this, function (_a) {
311
- switch (_a.label) {
312
- case 0:
313
- // Check for errors
314
- if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
315
- // If there was an error, reset cartGuid and remove it from the mts-storage
316
- this.resetBooking();
317
- return [2 /*return*/, response];
318
- }
319
- if (!response.cart) return [3 /*break*/, 1];
320
- // Save the local data
321
- this.cart = response.cart;
322
- this.cartGuid = response.cart.guid;
323
- // Save the cartGuid in the mts-storage
324
- this.getStorage().getState().updateCartGuid(response.cart.guid);
325
- // Fill the booking process status
326
- this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
327
- cartDueDate = new Date();
328
- cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
329
- this.bookingDueDate = cartDueDate;
330
- // Update the sellerId. This is particularly important in Linkavel
331
- this.updateSellerId(response.cart.sellerId);
332
- return [2 /*return*/, response.cart];
333
- case 1:
334
- // Fetch & update local properties
335
- return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
336
- case 2:
337
- // Fetch & update local properties
338
- _a.sent();
339
- if (!this.cart) {
340
- // Should already be handled, but just in case
341
- throw new Error("Could not fetch cart");
342
- }
343
- // Update storage
344
- this.getStorage().getState().updateCartGuid(response.cartGuid);
345
- return [2 /*return*/, this.cart];
346
- }
347
- });
348
- }); })];
349
- });
350
- });
351
- };
352
312
  //#region PersonDetails data API
353
313
  /**
354
314
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
@@ -18,7 +18,49 @@ export declare class SubscriptionBooking extends Booking {
18
18
  } & {
19
19
  updateCartGuid: (cartGuid: string | undefined) => void;
20
20
  resetState: () => void;
21
- }>, "persist"> & {
21
+ }>, "setState" | "persist"> & {
22
+ setState(partial: ({
23
+ cartGuid: string | undefined;
24
+ } & {
25
+ updateCartGuid: (cartGuid: string | undefined) => void;
26
+ resetState: () => void;
27
+ }) | Partial<{
28
+ cartGuid: string | undefined;
29
+ } & {
30
+ updateCartGuid: (cartGuid: string | undefined) => void;
31
+ resetState: () => void;
32
+ }> | ((state: {
33
+ cartGuid: string | undefined;
34
+ } & {
35
+ updateCartGuid: (cartGuid: string | undefined) => void;
36
+ resetState: () => void;
37
+ }) => ({
38
+ cartGuid: string | undefined;
39
+ } & {
40
+ updateCartGuid: (cartGuid: string | undefined) => void;
41
+ resetState: () => void;
42
+ }) | Partial<{
43
+ cartGuid: string | undefined;
44
+ } & {
45
+ updateCartGuid: (cartGuid: string | undefined) => void;
46
+ resetState: () => void;
47
+ }>), replace?: false | undefined): unknown;
48
+ setState(state: ({
49
+ cartGuid: string | undefined;
50
+ } & {
51
+ updateCartGuid: (cartGuid: string | undefined) => void;
52
+ resetState: () => void;
53
+ }) | ((state: {
54
+ cartGuid: string | undefined;
55
+ } & {
56
+ updateCartGuid: (cartGuid: string | undefined) => void;
57
+ resetState: () => void;
58
+ }) => {
59
+ cartGuid: string | undefined;
60
+ } & {
61
+ updateCartGuid: (cartGuid: string | undefined) => void;
62
+ resetState: () => void;
63
+ }), replace: true): unknown;
22
64
  persist: {
23
65
  setOptions: (options: Partial<import("zustand/middleware").PersistOptions<{
24
66
  cartGuid: string | undefined;
@@ -30,7 +72,7 @@ export declare class SubscriptionBooking extends Booking {
30
72
  } & {
31
73
  updateCartGuid: (cartGuid: string | undefined) => void;
32
74
  resetState: () => void;
33
- }>>) => void;
75
+ }, unknown>>) => void;
34
76
  clearStorage: () => void;
35
77
  rehydrate: () => Promise<void> | void;
36
78
  hasHydrated: () => boolean;
@@ -56,7 +98,7 @@ export declare class SubscriptionBooking extends Booking {
56
98
  } & {
57
99
  updateCartGuid: (cartGuid: string | undefined) => void;
58
100
  resetState: () => void;
59
- }>>;
101
+ }, unknown>>;
60
102
  };
61
103
  }>;
62
104
  getCart(): SubscriptionCart | undefined;