mts-booking-library 1.2.23 → 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;
@@ -59,14 +59,14 @@ export declare enum GatewayTypes {
59
59
  * @property {string} WALLET: Only for Resellers: the ticket will be paid with the wallet balance
60
60
  * @property {string} CARD: Pay with card at the Seller/Reseller counter
61
61
  * @property {string} CASH: Pay with cash at the Seller/Reseller counter
62
- * @property {string} ONLINE: Pay online using payment gateways
62
+ * @property {string} ONLINE_CARD: Pay online using payment gateways
63
63
  */
64
64
  export declare enum PaymentMethods {
65
65
  CARD = "CARD",
66
66
  CASH = "CASH",
67
67
  CREDIT_FROM_CHANGE = "CREDIT_FROM_CHANGE",
68
68
  PAY_LATER = "PAY_LATER",
69
- ONLINE_CARD = "ONLINE CARD",
69
+ ONLINE_CARD = "ONLINE_CARD",
70
70
  WALLET = "WALLET",
71
71
  ZERO_COST = "ZERO_COST"
72
72
  }
@@ -19,7 +19,7 @@ var GatewayTypes;
19
19
  * @property {string} WALLET: Only for Resellers: the ticket will be paid with the wallet balance
20
20
  * @property {string} CARD: Pay with card at the Seller/Reseller counter
21
21
  * @property {string} CASH: Pay with cash at the Seller/Reseller counter
22
- * @property {string} ONLINE: Pay online using payment gateways
22
+ * @property {string} ONLINE_CARD: Pay online using payment gateways
23
23
  */
24
24
  var PaymentMethods;
25
25
  (function (PaymentMethods) {
@@ -27,7 +27,7 @@ var PaymentMethods;
27
27
  PaymentMethods["CASH"] = "CASH";
28
28
  PaymentMethods["CREDIT_FROM_CHANGE"] = "CREDIT_FROM_CHANGE";
29
29
  PaymentMethods["PAY_LATER"] = "PAY_LATER";
30
- PaymentMethods["ONLINE_CARD"] = "ONLINE CARD";
30
+ PaymentMethods["ONLINE_CARD"] = "ONLINE_CARD";
31
31
  PaymentMethods["WALLET"] = "WALLET";
32
32
  PaymentMethods["ZERO_COST"] = "ZERO_COST";
33
33
  })(PaymentMethods || (exports.PaymentMethods = PaymentMethods = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.2.23",
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",