mts-booking-library 1.2.28 → 1.2.30

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,7 @@ export declare abstract class Booking {
39
39
  * @param sellerId The id of the seller.
40
40
  */
41
41
  updateSellerId(sellerId: number): void;
42
+ getSellerId(): number | undefined;
42
43
  /**
43
44
  * This method allows to renew the access token for calling MTS APIs
44
45
  * @param {string} access_token The new access token
@@ -93,6 +93,9 @@ var Booking = /** @class */ (function () {
93
93
  Booking.prototype.updateSellerId = function (sellerId) {
94
94
  this.sellerId = sellerId;
95
95
  };
96
+ Booking.prototype.getSellerId = function () {
97
+ return this.sellerId;
98
+ };
96
99
  /**
97
100
  * This method allows to renew the access token for calling MTS APIs
98
101
  * @param {string} access_token The new access token
@@ -72,6 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
72
  };
73
73
  Object.defineProperty(exports, "__esModule", { value: true });
74
74
  exports.JourneyBooking = void 0;
75
+ var config_1 = require("../config");
75
76
  var ErrorResponse_1 = require("../types/ErrorResponse");
76
77
  var Reduction_1 = require("../types/common/Reduction");
77
78
  var processBookingSteps_1 = require("../utils/processBookingSteps");
@@ -108,7 +109,15 @@ var JourneyBooking = /** @class */ (function (_super) {
108
109
  this.cartId = undefined;
109
110
  this.bookingStepsToStatus = new Map();
110
111
  this.bookingDueDate = undefined;
111
- localStorage.removeItem("cartId");
112
+ try {
113
+ localStorage.removeItem("cartId");
114
+ }
115
+ catch (e) {
116
+ if (this.config.ENV !== config_1.MTSEnvs.TEST) {
117
+ throw new Error("Error while deleting cartId from localStorage");
118
+ }
119
+ console.log(e);
120
+ }
112
121
  };
113
122
  JourneyBooking.prototype.fetchAndSetCart = function (cartId) {
114
123
  return __awaiter(this, void 0, void 0, function () {
@@ -122,6 +131,8 @@ var JourneyBooking = /** @class */ (function (_super) {
122
131
  _this.cart = cart;
123
132
  _this.cartId = cart.id;
124
133
  _this.bookingDueDate = cartDate; // See Booking class
134
+ // Update the sellerId. This is particularly important in Linkavel
135
+ _this.updateSellerId(cart.sellerId);
125
136
  // Fill the booking process status
126
137
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
127
138
  }
@@ -256,6 +267,8 @@ var JourneyBooking = /** @class */ (function (_super) {
256
267
  // Fill the booking process status
257
268
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
258
269
  _this.bookingDueDate = new Date(response.cart.bookingDueDate);
270
+ // Update the sellerId. This is particularly important in Linkavel
271
+ _this.updateSellerId(response.cart.sellerId);
259
272
  return response.cart;
260
273
  })];
261
274
  });
@@ -72,6 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
72
  };
73
73
  Object.defineProperty(exports, "__esModule", { value: true });
74
74
  exports.ServiceBooking = void 0;
75
+ var config_1 = require("../config");
75
76
  var ErrorResponse_1 = require("../types/ErrorResponse");
76
77
  var Reduction_1 = require("../types/common/Reduction");
77
78
  var processBookingSteps_1 = require("../utils/processBookingSteps");
@@ -108,7 +109,15 @@ var ServiceBooking = /** @class */ (function (_super) {
108
109
  this.cartId = undefined;
109
110
  this.bookingStepsToStatus = new Map();
110
111
  this.bookingDueDate = undefined;
111
- localStorage.removeItem("cartId");
112
+ try {
113
+ localStorage.removeItem("cartId");
114
+ }
115
+ catch (e) {
116
+ if (this.config.ENV !== config_1.MTSEnvs.TEST) {
117
+ throw new Error("Error while deleting cartId from localStorage");
118
+ }
119
+ console.log(e);
120
+ }
112
121
  };
113
122
  ServiceBooking.prototype.fetchAndSetCart = function (cartId) {
114
123
  return __awaiter(this, void 0, void 0, function () {
@@ -122,6 +131,8 @@ var ServiceBooking = /** @class */ (function (_super) {
122
131
  _this.cart = cart;
123
132
  _this.cartId = cart.id;
124
133
  _this.bookingDueDate = cartDate; // See Booking class
134
+ // Update the sellerId. This is particularly important in Linkavel
135
+ _this.updateSellerId(cart.sellerId);
125
136
  // Fill the booking process status
126
137
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
127
138
  }
@@ -257,6 +268,8 @@ var ServiceBooking = /** @class */ (function (_super) {
257
268
  // Fill the booking process status
258
269
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
259
270
  _this.bookingDueDate = new Date(response.cart.bookingDueDate);
271
+ // Update the sellerId. This is particularly important in Linkavel
272
+ _this.updateSellerId(response.cart.sellerId);
260
273
  return response.cart;
261
274
  })];
262
275
  });
@@ -72,6 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
72
72
  };
73
73
  Object.defineProperty(exports, "__esModule", { value: true });
74
74
  exports.SubscriptionBooking = void 0;
75
+ var config_1 = require("../config");
75
76
  var ErrorResponse_1 = require("../types/ErrorResponse");
76
77
  var Reduction_1 = require("../types/common/Reduction");
77
78
  var processBookingSteps_1 = require("../utils/processBookingSteps");
@@ -108,7 +109,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
108
109
  this.cartId = undefined;
109
110
  this.bookingStepsToStatus = new Map();
110
111
  this.bookingDueDate = undefined;
111
- localStorage.removeItem("cartId");
112
+ try {
113
+ localStorage.removeItem("cartId");
114
+ }
115
+ catch (e) {
116
+ if (this.config.ENV !== config_1.MTSEnvs.TEST) {
117
+ throw new Error("Error while deleting cartId from localStorage");
118
+ }
119
+ console.log(e);
120
+ }
112
121
  };
113
122
  SubscriptionBooking.prototype.fetchAndSetCart = function (cartId) {
114
123
  return __awaiter(this, void 0, void 0, function () {
@@ -122,6 +131,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
122
131
  _this.cart = cart;
123
132
  _this.cartId = cart.id;
124
133
  _this.bookingDueDate = cartDate; // See Booking class
134
+ // Update the sellerId. This is particularly important in Linkavel
135
+ _this.updateSellerId(cart.sellerId);
125
136
  // Fill the booking process status
126
137
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
127
138
  }
@@ -311,6 +322,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
311
322
  // Fill the booking process status
312
323
  _this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
313
324
  _this.bookingDueDate = new Date(response.cart.bookingDueDate);
325
+ // Update the sellerId. This is particularly important in Linkavel
326
+ _this.updateSellerId(response.cart.sellerId);
314
327
  return response.cart;
315
328
  })];
316
329
  });
package/lib/config.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare enum MTSEnvs {
2
+ TEST = "TEST",
2
3
  DEV = "DEV",
3
4
  STAGING = "STAGING",
4
5
  PROD = "PROD"
package/lib/config.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getConfig = exports.setConfig = exports.MTSEnvs = void 0;
4
4
  var MTSEnvs;
5
5
  (function (MTSEnvs) {
6
+ MTSEnvs["TEST"] = "TEST";
6
7
  MTSEnvs["DEV"] = "DEV";
7
8
  MTSEnvs["STAGING"] = "STAGING";
8
9
  MTSEnvs["PROD"] = "PROD";
@@ -18,6 +19,7 @@ var setConfig = function (env, sub_key, debug, access_token) {
18
19
  // First, set the environment
19
20
  config.ENV = env.toUpperCase();
20
21
  switch (config.ENV) {
22
+ case MTSEnvs.TEST:
21
23
  case MTSEnvs.DEV:
22
24
  config.API_ENDPOINT = "https://myticketsolutionapim.azure-api.net/api/dev";
23
25
  break;
@@ -12,6 +12,8 @@ import { Extra } from "./Extra";
12
12
  * @property {boolean} hasIssuedTickets - A boolean telling whether the cart has issued tickets. Note that if this is the case,
13
13
  * the cart will be null because it is not possible to add tickets to an issued cart. Thus, all data should be reset.
14
14
  * @property {number} sellerId The id of the seller of the tickets in the cart
15
+ * @property {string} sellerPrivacyUrl The url redirecting to the privacy policy of the seller
16
+ * @property {string} sellerTermsUrl The url redirecting to the terms and conditions of the seller
15
17
  * @property {Map<string, boolean[]>} stepsToStatus This data structure describes the steps of the booking process.
16
18
  * The keys of this dictionary represent the booking steps. See ... for the list of possible steps. If the
17
19
  * key is present, then the booking step shall be displayed. The value is a list of 3 booleans:
@@ -20,23 +22,33 @@ import { Extra } from "./Extra";
20
22
  * - The third tells whether the section is required.
21
23
  * @property {Booking.Currencies} currency The currency of the cart. See {@link Booking.Currencies}
22
24
  * @property {string} bookingDueDate The date and time when the cart expires
25
+ * @property {Reduction[]} reductions The list of reductions applied to the cart
26
+ * @property {Extra[]} extras The list of extras services of the cart
27
+ * @property {string} sellingMethod The selling method of the cart (LinkAvel, Backoffice)
28
+ * @property {number} totalValue The total value of the cart, meaning the sum of the nominal prices of all tickets. It is expressed in the currency of the cart.
29
+ * @property {number} totalResellerFee The total reseller fee of the cart, meaning the sum of the reseller fees of all tickets. It is expressed in the currency of the cart.
30
+ * @property {number} totalCreditFromChange The total credit from change of the cart. This is non zero only during the change process, and represents
31
+ * the credit that the user has from the previous cart. It is expressed in the currency of the cart.
32
+ * @property {number} totalAmountToPay The total amount to pay of the cart, meaning the amount that the user has to pay to complete the booking. This is
33
+ * what is displayed in the payment page. It is expressed in the currency of the cart.
23
34
  */
24
35
  export type Cart = {
25
36
  id: number;
26
37
  sellerId: number;
38
+ sellerPrivacyUrl: string;
39
+ sellerTermsUrl: string;
27
40
  cartCode: string;
28
41
  hasIssuedTickets: boolean;
29
42
  stepsToStatus: Map<string, boolean[]>;
30
43
  currency: Booking.Currencies;
31
44
  bookingDueDate: string;
32
- buyerId: number;
33
45
  reductions: Reduction[];
46
+ extras: Extra[];
34
47
  sellingMethod: string;
35
48
  totalValue: number;
36
49
  totalResellerFee?: number;
37
50
  totalCreditFromChange: number;
38
51
  totalAmountToPay: number;
39
- extras: Extra[];
40
52
  };
41
53
  /**
42
54
  * Base response type for the booking process. All APIs that update the cart, share this.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.2.28",
3
+ "version": "1.2.30",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",