mts-booking-library 1.3.3 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,13 +22,22 @@
22
22
  // }
23
23
  // test("search_tpl", async () => {
24
24
  // const booking = new SubscriptionBooking(MTSEnvs.TEST, sub_key!, true, SubscriptionBooking.Languages.EN, access_token, sellerId);
25
- // // First, get the departures
25
+ // // First, get the departures and destinations
26
26
  // const departures = await booking.getSubscriptionsDepartures() as string[];
27
27
  // expect(departures.length).toBeGreaterThan(0);
28
- // expect(departures).toContain("APT TREVISO CANOVA");
29
- // const selectedDeparture = "APT TREVISO CANOVA";
30
- // const destinations = await booking.getJourneysDestinations(selectedDeparture);
31
- // expect(destinations).toContain("MESTRE FFSS");
28
+ // expect(departures).toContain("BARDOLINO AUTOSTAZIONE");
29
+ // const selectedDeparture = "BARDOLINO AUTOSTAZIONE";
30
+ // const destinations = await booking.getSubscriptionsDestinations(selectedDeparture) as string[];
31
+ // expect(destinations.length).toBeGreaterThan(0);
32
+ // expect(destinations).toContain("GARDA AUTOSTAZIONE");
33
+ // const selectedDestination = "GARDA AUTOSTAZIONE";
34
+ // // Then get the validity types
35
+ // const validityTypes = await booking.getSubscriptionsValidityTypes(selectedDeparture, selectedDestination) as SubscriptionBooking.ValidityTypes[];
36
+ // expect(validityTypes.length).toBeGreaterThan(0);
37
+ // for (const validityType of validityTypes) {
38
+ // // Check that all returned validity types are valid
39
+ // expect(Object.values(SubscriptionBooking.ValidityTypes).includes(validityType)).toBe(true);
40
+ // }
32
41
  // }, timeOut);
33
42
  // const createCart = async (booking: ServiceBooking): Promise<ServiceCart> => {
34
43
  // const servicesResponse = await booking.getServices(ServiceBooking.Currencies.EUR);
@@ -274,7 +274,9 @@ var JourneyBooking = /** @class */ (function (_super) {
274
274
  _this.getStorage().getState().updateCartId(response.cart.id);
275
275
  // Fill the booking process status
276
276
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
277
- _this.bookingDueDate = new Date(response.cart.bookingDueDate);
277
+ var cartDueDate = new Date();
278
+ cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
279
+ _this.bookingDueDate = cartDueDate;
278
280
  // Update the sellerId. This is particularly important in Linkavel
279
281
  _this.updateSellerId(response.cart.sellerId);
280
282
  return response.cart;
@@ -275,7 +275,9 @@ var ServiceBooking = /** @class */ (function (_super) {
275
275
  _this.getStorage().getState().updateCartId(response.cart.id);
276
276
  // Fill the booking process status
277
277
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
278
- _this.bookingDueDate = new Date(response.cart.bookingDueDate);
278
+ var cartDueDate = new Date();
279
+ cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
280
+ _this.bookingDueDate = cartDueDate;
279
281
  // Update the sellerId. This is particularly important in Linkavel
280
282
  _this.updateSellerId(response.cart.sellerId);
281
283
  return response.cart;
@@ -177,8 +177,13 @@ export declare namespace SubscriptionBooking {
177
177
  const createBooking: (env: MTSEnvs, sub_key: string, debug: boolean, language: string, access_token?: string, sellerId?: number, resellerId?: number) => Promise<SubscriptionBooking>;
178
178
  enum ValidityTypes {
179
179
  WORKING_WEEK = "WORKING_WEEK",
180
- WEEKLY = "WEEKLY",
181
- MONTHLY = "MONTHLY",
182
- YEARLY = "YEARLY"
180
+ ONE_WEEK = "ONE_WEEK",
181
+ CALENDAR_WEEK = "CALENDAR_WEEK",
182
+ FIFTEEN_DAYS = "FIFTEEN_DAYS",
183
+ ONE_MONTH = "ONE_MONTH",
184
+ CALENDAR_MONTH = "CALENDAR_MONTH",
185
+ CALENDAR_SIX_MONTHS = "CALENDAR_SIX_MONTHS",
186
+ ONE_YEAR = "ONE_YEAR",
187
+ CALENDAR_YEAR = "CALENDAR_YEAR"
183
188
  }
184
189
  }
@@ -172,7 +172,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
172
172
  if (response.cart.hasIssuedTickets) {
173
173
  _this.resetBooking();
174
174
  }
175
- return response;
175
+ return response.cart;
176
176
  })];
177
177
  });
178
178
  });
@@ -329,7 +329,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
329
329
  _this.getStorage().getState().updateCartId(response.cart.id);
330
330
  // Fill the booking process status
331
331
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
332
- _this.bookingDueDate = new Date(response.cart.bookingDueDate);
332
+ var cartDueDate = new Date();
333
+ cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
334
+ _this.bookingDueDate = cartDueDate;
333
335
  // Update the sellerId. This is particularly important in Linkavel
334
336
  _this.updateSellerId(response.cart.sellerId);
335
337
  return response.cart;
@@ -748,8 +750,13 @@ exports.SubscriptionBooking = SubscriptionBooking;
748
750
  var ValidityTypes;
749
751
  (function (ValidityTypes) {
750
752
  ValidityTypes["WORKING_WEEK"] = "WORKING_WEEK";
751
- ValidityTypes["WEEKLY"] = "WEEKLY";
752
- ValidityTypes["MONTHLY"] = "MONTHLY";
753
- ValidityTypes["YEARLY"] = "YEARLY";
753
+ ValidityTypes["ONE_WEEK"] = "ONE_WEEK";
754
+ ValidityTypes["CALENDAR_WEEK"] = "CALENDAR_WEEK";
755
+ ValidityTypes["FIFTEEN_DAYS"] = "FIFTEEN_DAYS";
756
+ ValidityTypes["ONE_MONTH"] = "ONE_MONTH";
757
+ ValidityTypes["CALENDAR_MONTH"] = "CALENDAR_MONTH";
758
+ ValidityTypes["CALENDAR_SIX_MONTHS"] = "CALENDAR_SIX_MONTHS";
759
+ ValidityTypes["ONE_YEAR"] = "ONE_YEAR";
760
+ ValidityTypes["CALENDAR_YEAR"] = "CALENDAR_YEAR";
754
761
  })(ValidityTypes = SubscriptionBooking.ValidityTypes || (SubscriptionBooking.ValidityTypes = {}));
755
762
  })(SubscriptionBooking || (exports.SubscriptionBooking = SubscriptionBooking = {}));
@@ -308,7 +308,9 @@ var TplBooking = /** @class */ (function (_super) {
308
308
  _this.getStorage().getState().updateCartId(response.cart.id);
309
309
  // Fill the booking process status
310
310
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
311
- _this.bookingDueDate = new Date(response.cart.bookingDueDate);
311
+ var cartDueDate = new Date();
312
+ cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
313
+ _this.bookingDueDate = cartDueDate;
312
314
  // Update the sellerId. This is particularly important in Linkavel
313
315
  _this.updateSellerId(response.cart.sellerId);
314
316
  return response.cart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "@types/jest": "^29.5.12",
18
18
  "jest": "^29.7.0",
19
19
  "ts-jest": "^29.1.2",
20
- "typescript": "^5.4.3"
20
+ "typescript": "^5.4.5"
21
21
  },
22
22
  "files": [
23
23
  "lib/**/*"