mts-booking-library 1.2.1 → 1.2.2

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));
@@ -211,6 +212,7 @@ var JourneyBooking = /** @class */ (function (_super) {
211
212
  return response;
212
213
  }
213
214
  _this.cart = response.cart;
215
+ _this.cartId = response.cart.id;
214
216
  // Save the cartId in the localStorage
215
217
  localStorage.setItem("cartId", response.cart.id.toString());
216
218
  // 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));
@@ -215,6 +216,7 @@ var ServiceBooking = /** @class */ (function (_super) {
215
216
  }
216
217
  // Save the local data
217
218
  _this.cart = response.cart;
219
+ _this.cartId = response.cart.id;
218
220
  // Save the cartId in the localStorage
219
221
  localStorage.setItem("cartId", response.cart.id.toString());
220
222
  // 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));
@@ -260,6 +261,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
260
261
  return response;
261
262
  }
262
263
  _this.cart = response.cart;
264
+ _this.cartId = response.cart.id;
263
265
  // Save the cartId in the localStorage
264
266
  localStorage.setItem("cartId", response.cart.id.toString());
265
267
  // 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.2",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",