mts-booking-library 1.2.24 → 1.2.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -165,10 +165,14 @@ var Booking = /** @class */ (function () {
165
165
  throw Error("Cart is not initialized yet");
166
166
  }
167
167
  currentStepStatus = this.bookingStepsToStatus.get(bookingStep);
168
- if (!currentStepStatus || currentStepStatus[2]) {
168
+ // Booking step is not present in the map, then it is not required and it is already completed
169
+ if (!currentStepStatus)
170
+ return [2 /*return*/, true];
171
+ // Booking step is required, cannot be marked as completed
172
+ if (currentStepStatus[2]) {
169
173
  throw Error("The step ".concat(bookingStep, " cannot be marked as completed because it is required"));
170
174
  }
171
- // Booking step is already completedm, no need to call the API
175
+ // Booking step is already completed, no need to call the API
172
176
  if (currentStepStatus[0])
173
177
  return [2 /*return*/, true];
174
178
  url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cartId, "/bookingSteps");
@@ -251,6 +251,9 @@ var JourneyBooking = /** @class */ (function (_super) {
251
251
  return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
252
252
  // Check for errors
253
253
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
254
+ // If there was an error, reset cartId and remove it from the localStorage
255
+ _this.cartId = undefined;
256
+ localStorage.removeItem("cartId");
254
257
  return response;
255
258
  }
256
259
  _this.cart = response.cart;
@@ -250,6 +250,9 @@ var ServiceBooking = /** @class */ (function (_super) {
250
250
  return [2 /*return*/, this.callPostApi(url, serviceCart).then(function (response) {
251
251
  // Check for errors
252
252
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
253
+ // If there was an error, reset cartId and remove it from the localStorage
254
+ _this.cartId = undefined;
255
+ localStorage.removeItem("cartId");
253
256
  return response;
254
257
  }
255
258
  // Save the local data
@@ -313,6 +313,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
313
313
  return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
314
314
  // Check for errors
315
315
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
316
+ // If there was an error, reset cartId and remove it from the localStorage
317
+ _this.cartId = undefined;
318
+ localStorage.removeItem("cartId");
316
319
  return response;
317
320
  }
318
321
  _this.cart = response.cart;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.2.24",
3
+ "version": "1.2.25",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",