mts-booking-library 1.2.1 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,10 +29,11 @@ export declare abstract class Booking {
29
29
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
30
30
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
31
31
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
32
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
32
33
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
33
34
  * @param {number} [resellerId=undefined] The id of the reseller.
34
35
  */
35
- constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, bookingType: Booking.BookingTypes, debug?: boolean, language?: string, sellerId?: number, resellerId?: number);
36
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, bookingType: Booking.BookingTypes, debug?: boolean, language?: string, access_token?: string, sellerId?: number, resellerId?: number);
36
37
  /**
37
38
  * This method allows to renew the access token for calling MTS APIs
38
39
  * @param {string} access_token The new access token
@@ -61,10 +61,11 @@ var Booking = /** @class */ (function () {
61
61
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
62
62
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
63
63
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
64
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
64
65
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
65
66
  * @param {number} [resellerId=undefined] The id of the reseller.
66
67
  */
67
- function Booking(env, sub_key, onCartExpiration, bookingType, debug, language, sellerId, resellerId) {
68
+ function Booking(env, sub_key, onCartExpiration, bookingType, debug, language, access_token, sellerId, resellerId) {
68
69
  if (debug === void 0) { debug = false; }
69
70
  if (language === void 0) { language = Booking.Languages.EN; }
70
71
  this.language = Booking.Languages.EN;
@@ -80,7 +81,7 @@ var Booking = /** @class */ (function () {
80
81
  this.bookingStepsToStatus = new Map();
81
82
  this.sellerId = sellerId || undefined;
82
83
  this.resellerId = resellerId || undefined;
83
- this.config = (0, config_1.setConfig)(env, sub_key, debug);
84
+ this.config = (0, config_1.setConfig)(env, sub_key, debug, access_token);
84
85
  this.bookingType = bookingType;
85
86
  this.onCartExpiration = onCartExpiration;
86
87
  this.changeLanguage(language);
@@ -15,10 +15,11 @@ export declare class JourneyBooking extends Booking {
15
15
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
16
16
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
17
17
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
18
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
18
19
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
19
20
  * @param {number} [resellerId=undefined] The id of the reseller.
20
21
  */
21
- constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, language?: string, sellerId?: number, resellerId?: number);
22
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, language?: string, access_token?: string, sellerId?: number, resellerId?: number);
22
23
  getCart(): JourneyCart | undefined;
23
24
  private fetchAndSetCart;
24
25
  private createCartTimer;
@@ -64,15 +64,16 @@ var JourneyBooking = /** @class */ (function (_super) {
64
64
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
65
65
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
66
66
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
67
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
67
68
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
68
69
  * @param {number} [resellerId=undefined] The id of the reseller.
69
70
  */
70
- function JourneyBooking(env, sub_key, onCartExpiration, debug, language, sellerId, resellerId) {
71
+ function JourneyBooking(env, sub_key, onCartExpiration, debug, language, access_token, sellerId, resellerId) {
71
72
  if (debug === void 0) { debug = false; }
72
73
  if (language === void 0) { language = booking_1.Booking.Languages.EN; }
73
74
  var _this =
74
75
  // Call Booking constructor
75
- _super.call(this, env, sub_key, onCartExpiration, booking_1.Booking.BookingTypes.MLP, debug, language, sellerId, resellerId) || this;
76
+ _super.call(this, env, sub_key, onCartExpiration, booking_1.Booking.BookingTypes.MLP, debug, language, access_token, sellerId, resellerId) || this;
76
77
  var cartId = localStorage.getItem("cartId");
77
78
  if (cartId) {
78
79
  _this.fetchAndSetCart(parseInt(cartId));
@@ -90,6 +91,7 @@ var JourneyBooking = /** @class */ (function (_super) {
90
91
  var cartDate = new Date(cart.bookingDueDate);
91
92
  if (cartDate > new Date()) {
92
93
  _this.cart = cart;
94
+ _this.cartId = cart.id;
93
95
  _this.bookingDueDate = cartDate; // See Booking class
94
96
  // Fill the booking process status
95
97
  _this.bookingStepsToStatus = new Map(Object.entries(cart.stepsToStatus).map(function (_a) {
@@ -115,6 +117,7 @@ var JourneyBooking = /** @class */ (function (_super) {
115
117
  // Put actions that have to be done when timer expires here
116
118
  _this.bookingStepsToStatus = new Map();
117
119
  _this.cart = undefined;
120
+ _this.cartId = undefined;
118
121
  _this.bookingDueDate = undefined; // See Booking class
119
122
  _this.onCartExpiration();
120
123
  }, expiringDate.valueOf() - new Date().valueOf());
@@ -211,6 +214,7 @@ var JourneyBooking = /** @class */ (function (_super) {
211
214
  return response;
212
215
  }
213
216
  _this.cart = response.cart;
217
+ _this.cartId = response.cart.id;
214
218
  // Save the cartId in the localStorage
215
219
  localStorage.setItem("cartId", response.cart.id.toString());
216
220
  // Fill the booking process status
@@ -13,10 +13,11 @@ export declare class ServiceBooking extends Booking {
13
13
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
14
14
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
15
15
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
16
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
16
17
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
17
18
  * @param {number} [resellerId=undefined] The id of the reseller.
18
19
  */
19
- constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, language?: string, sellerId?: number, resellerId?: number);
20
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, language?: string, access_token?: string, sellerId?: number, resellerId?: number);
20
21
  getCart(): ServiceCart | undefined;
21
22
  private fetchAndSetCart;
22
23
  private createCartTimer;
@@ -75,15 +75,16 @@ var ServiceBooking = /** @class */ (function (_super) {
75
75
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
76
76
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
77
77
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
78
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
78
79
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
79
80
  * @param {number} [resellerId=undefined] The id of the reseller.
80
81
  */
81
- function ServiceBooking(env, sub_key, onCartExpiration, debug, language, sellerId, resellerId) {
82
+ function ServiceBooking(env, sub_key, onCartExpiration, debug, language, access_token, sellerId, resellerId) {
82
83
  if (debug === void 0) { debug = false; }
83
84
  if (language === void 0) { language = booking_1.Booking.Languages.EN; }
84
85
  var _this =
85
86
  // Call Booking constructor
86
- _super.call(this, env, sub_key, onCartExpiration, booking_1.Booking.BookingTypes.SERVICE, debug, language, sellerId, resellerId) || this;
87
+ _super.call(this, env, sub_key, onCartExpiration, booking_1.Booking.BookingTypes.SERVICE, debug, language, access_token, sellerId, resellerId) || this;
87
88
  var cartId = localStorage.getItem("cartId");
88
89
  if (cartId) {
89
90
  _this.fetchAndSetCart(parseInt(cartId));
@@ -101,6 +102,7 @@ var ServiceBooking = /** @class */ (function (_super) {
101
102
  var cartDate = new Date(cart.bookingDueDate);
102
103
  if (cartDate > new Date()) {
103
104
  _this.cart = cart;
105
+ _this.cartId = cart.id;
104
106
  _this.bookingDueDate = cartDate; // See Booking class
105
107
  // Fill the booking process status
106
108
  _this.bookingStepsToStatus = new Map(Object.entries(cart.stepsToStatus).map(function (_a) {
@@ -125,6 +127,7 @@ var ServiceBooking = /** @class */ (function (_super) {
125
127
  localStorage.removeItem("cartId");
126
128
  // Put actions that have to be done when timer expires here
127
129
  _this.cart = undefined;
130
+ _this.cartId = undefined;
128
131
  _this.bookingDueDate = undefined; // See Booking class
129
132
  _this.onCartExpiration();
130
133
  }, expiringDate.valueOf() - new Date().valueOf());
@@ -215,6 +218,7 @@ var ServiceBooking = /** @class */ (function (_super) {
215
218
  }
216
219
  // Save the local data
217
220
  _this.cart = response.cart;
221
+ _this.cartId = response.cart.id;
218
222
  // Save the cartId in the localStorage
219
223
  localStorage.setItem("cartId", response.cart.id.toString());
220
224
  // Fill the booking process status
@@ -16,10 +16,11 @@ export declare class SubscriptionBooking extends Booking {
16
16
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
17
17
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
18
18
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
19
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
19
20
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
20
21
  * @param {number} [resellerId=undefined] The id of the reseller.
21
22
  */
22
- constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, language?: string, sellerId?: number, resellerId?: number);
23
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, language?: string, access_token?: string, sellerId?: number, resellerId?: number);
23
24
  getCart(): Cart | undefined;
24
25
  private fetchAndSetCart;
25
26
  private createCartTimer;
@@ -64,15 +64,16 @@ var SubscriptionBooking = /** @class */ (function (_super) {
64
64
  * @param {Booking.BookingTypes} bookingType The type of booking. Can be "MLP", "SERVICE" or "MLP_SUBSCRIPTION"
65
65
  * @param {boolean} [debug=false] If true, the app will run in debug mode (meaning that will print requests and responses in the console)
66
66
  * @param {string} [language=Booking.Languages.EN] The language in which the app is running. Can be "it", "en", "fr", "de" or "es"
67
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
67
68
  * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
68
69
  * @param {number} [resellerId=undefined] The id of the reseller.
69
70
  */
70
- function SubscriptionBooking(env, sub_key, onCartExpiration, debug, language, sellerId, resellerId) {
71
+ function SubscriptionBooking(env, sub_key, onCartExpiration, debug, language, access_token, sellerId, resellerId) {
71
72
  if (debug === void 0) { debug = false; }
72
73
  if (language === void 0) { language = booking_1.Booking.Languages.EN; }
73
74
  var _this =
74
75
  // Call Booking constructor
75
- _super.call(this, env, sub_key, onCartExpiration, booking_1.Booking.BookingTypes.MLP_SUBSCRIPTION, debug, language, sellerId, resellerId) || this;
76
+ _super.call(this, env, sub_key, onCartExpiration, booking_1.Booking.BookingTypes.MLP_SUBSCRIPTION, debug, language, access_token, sellerId, resellerId) || this;
76
77
  var cartId = localStorage.getItem("cartId");
77
78
  if (cartId) {
78
79
  _this.fetchAndSetCart(parseInt(cartId));
@@ -90,6 +91,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
90
91
  var cartDate = new Date(cart.bookingDueDate);
91
92
  if (cartDate > new Date()) {
92
93
  _this.cart = cart;
94
+ _this.cartId = cart.id;
93
95
  _this.bookingDueDate = cartDate; // See Booking class
94
96
  // Fill the booking process status
95
97
  _this.bookingStepsToStatus = new Map(Object.entries(cart.stepsToStatus).map(function (_a) {
@@ -115,6 +117,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
115
117
  // Put actions that have to be done when timer expires here
116
118
  _this.bookingStepsToStatus = new Map();
117
119
  _this.cart = undefined;
120
+ _this.cartId = undefined;
118
121
  _this.bookingDueDate = undefined; // See Booking class
119
122
  _this.onCartExpiration();
120
123
  }, expiringDate.valueOf() - new Date().valueOf());
@@ -260,6 +263,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
260
263
  return response;
261
264
  }
262
265
  _this.cart = response.cart;
266
+ _this.cartId = response.cart.id;
263
267
  // Save the cartId in the localStorage
264
268
  localStorage.setItem("cartId", response.cart.id.toString());
265
269
  // Fill the booking process status
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",