mts-booking-library 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/booking/booking.d.ts +2 -1
- package/lib/booking/booking.js +3 -2
- package/lib/booking/journeyBooking.d.ts +12 -2
- package/lib/booking/journeyBooking.js +42 -2
- package/lib/booking/serviceBooking.d.ts +2 -1
- package/lib/booking/serviceBooking.js +4 -2
- package/lib/booking/subscriptionBooking.d.ts +12 -2
- package/lib/booking/subscriptionBooking.js +42 -2
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/types/common/Person.d.ts +11 -6
- package/lib/types/common/Person.js +8 -1
- package/package.json +1 -1
package/lib/booking/booking.d.ts
CHANGED
@@ -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
|
package/lib/booking/booking.js
CHANGED
@@ -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);
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { MTSEnvs } from "../config";
|
2
2
|
import { ErrorResponse } from "../types/ErrorResponse";
|
3
|
-
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse } from "../types/common/Person";
|
3
|
+
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
4
4
|
import { BusMatrix } from "../types/journeys/BusMatrix";
|
5
5
|
import { CreateJourneyCartRequest, JourneyCart } from "../types/journeys/JourneyCart";
|
6
6
|
import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/JourneySearch";
|
@@ -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;
|
@@ -49,6 +50,15 @@ export declare class JourneyBooking extends Booking {
|
|
49
50
|
* as well as a list of the available tariffs for each trip.
|
50
51
|
*/
|
51
52
|
getBuyerPassengersDetails(): Promise<ErrorResponse | GetBuyerPassengersDetailsResponse>;
|
53
|
+
/**
|
54
|
+
* @description This method shall be called when the user wants to retrieve information about an esisting buyer.
|
55
|
+
* @param {string} [linkavelCardNumber=undefined] The linkavel card number of the buyer. This parameter is required if linkavelCardPhoneNumber is not set.
|
56
|
+
* A linkavelCardNumber is a string of 9 digits.
|
57
|
+
* @param {string} [linkavelCardPhoneNumber=undefined] The linkavel card phone number of the buyer. This parameter is required if linkavelCardNumber is not set.
|
58
|
+
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
59
|
+
* as well as a list of the available tariffs for each trip.
|
60
|
+
*/
|
61
|
+
getBuyer(linkavelCardNumber?: string, linkavelCardPhoneNumber?: string): Promise<ErrorResponse | Person>;
|
52
62
|
/**
|
53
63
|
* @description This methosd shall be called when the user wants to update the buyer and the passengers information.
|
54
64
|
* @param {EditPassengersDetailsRequest} passengersDetails The object containing the buyer and the passengers information.
|
@@ -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
|
@@ -268,6 +270,44 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
268
270
|
});
|
269
271
|
});
|
270
272
|
};
|
273
|
+
/**
|
274
|
+
* @description This method shall be called when the user wants to retrieve information about an esisting buyer.
|
275
|
+
* @param {string} [linkavelCardNumber=undefined] The linkavel card number of the buyer. This parameter is required if linkavelCardPhoneNumber is not set.
|
276
|
+
* A linkavelCardNumber is a string of 9 digits.
|
277
|
+
* @param {string} [linkavelCardPhoneNumber=undefined] The linkavel card phone number of the buyer. This parameter is required if linkavelCardNumber is not set.
|
278
|
+
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
279
|
+
* as well as a list of the available tariffs for each trip.
|
280
|
+
*/
|
281
|
+
JourneyBooking.prototype.getBuyer = function (linkavelCardNumber, linkavelCardPhoneNumber) {
|
282
|
+
return __awaiter(this, void 0, void 0, function () {
|
283
|
+
var buyerPassengersDetails, searchParams, url;
|
284
|
+
return __generator(this, function (_a) {
|
285
|
+
// First check that it is possible to call this API
|
286
|
+
if (!this.cart) {
|
287
|
+
throw Error("Cart is not initialized yet");
|
288
|
+
}
|
289
|
+
buyerPassengersDetails = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.BUYER_PASSENGERS);
|
290
|
+
if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
|
291
|
+
throw Error("The status of the cart does not allow to call this API");
|
292
|
+
}
|
293
|
+
if (!linkavelCardNumber && !linkavelCardPhoneNumber) {
|
294
|
+
throw Error("At least one of the parameters linkavelCardNumber and linkavelCardPhoneNumber must be set");
|
295
|
+
}
|
296
|
+
searchParams = new URLSearchParams({
|
297
|
+
linkavelCardNumber: linkavelCardNumber !== null && linkavelCardNumber !== void 0 ? linkavelCardNumber : "",
|
298
|
+
linkavelCardPhoneNumber: linkavelCardPhoneNumber !== null && linkavelCardPhoneNumber !== void 0 ? linkavelCardPhoneNumber : "",
|
299
|
+
});
|
300
|
+
url = "".concat(this.config.API_ENDPOINT, "/buyers?").concat(searchParams, "}");
|
301
|
+
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
302
|
+
// Check for errors
|
303
|
+
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
304
|
+
return response;
|
305
|
+
}
|
306
|
+
return response.buyers[0];
|
307
|
+
})];
|
308
|
+
});
|
309
|
+
});
|
310
|
+
};
|
271
311
|
/**
|
272
312
|
* @description This methosd shall be called when the user wants to update the buyer and the passengers information.
|
273
313
|
* @param {EditPassengersDetailsRequest} passengersDetails The object containing the buyer and the passengers information.
|
@@ -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
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MTSEnvs } from "../config";
|
2
2
|
import { ErrorResponse } from "../types/ErrorResponse";
|
3
3
|
import { Cart } from "../types/common/Cart";
|
4
|
-
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse } from "../types/common/Person";
|
4
|
+
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
5
5
|
import { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse } from "../types/subscriptions/SubscriptionAvailabilities";
|
6
6
|
import { CreateSubscriptionCartRequest, SubscriptionCart } from "../types/subscriptions/SubscriptionCart";
|
7
7
|
import { Subscription } from "../types/subscriptions/Subscriptions";
|
@@ -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;
|
@@ -72,6 +73,15 @@ export declare class SubscriptionBooking extends Booking {
|
|
72
73
|
* as well as a list of the available tariffs for each trip.
|
73
74
|
*/
|
74
75
|
getBuyerPassengersDetails(): Promise<ErrorResponse | GetBuyerPassengersDetailsResponse>;
|
76
|
+
/**
|
77
|
+
* @description This method shall be called when the user wants to retrieve information about an esisting buyer.
|
78
|
+
* @param {string} [linkavelCardNumber=undefined] The linkavel card number of the buyer. This parameter is required if linkavelCardPhoneNumber is not set.
|
79
|
+
* A linkavelCardNumber is a string of 9 digits.
|
80
|
+
* @param {string} [linkavelCardPhoneNumber=undefined] The linkavel card phone number of the buyer. This parameter is required if linkavelCardNumber is not set.
|
81
|
+
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
82
|
+
* as well as a list of the available tariffs for each trip.
|
83
|
+
*/
|
84
|
+
getBuyer(linkavelCardNumber?: string, linkavelCardPhoneNumber?: string): Promise<ErrorResponse | Person>;
|
75
85
|
/**
|
76
86
|
* @description This methosd shall be called when the user wants to update the buyer and the passengers information.
|
77
87
|
* @param {EditPassengersDetailsRequest} passengersDetails The object containing the buyer and the passengers information.
|
@@ -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
|
@@ -317,6 +319,44 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
317
319
|
});
|
318
320
|
});
|
319
321
|
};
|
322
|
+
/**
|
323
|
+
* @description This method shall be called when the user wants to retrieve information about an esisting buyer.
|
324
|
+
* @param {string} [linkavelCardNumber=undefined] The linkavel card number of the buyer. This parameter is required if linkavelCardPhoneNumber is not set.
|
325
|
+
* A linkavelCardNumber is a string of 9 digits.
|
326
|
+
* @param {string} [linkavelCardPhoneNumber=undefined] The linkavel card phone number of the buyer. This parameter is required if linkavelCardNumber is not set.
|
327
|
+
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
328
|
+
* as well as a list of the available tariffs for each trip.
|
329
|
+
*/
|
330
|
+
SubscriptionBooking.prototype.getBuyer = function (linkavelCardNumber, linkavelCardPhoneNumber) {
|
331
|
+
return __awaiter(this, void 0, void 0, function () {
|
332
|
+
var buyerPassengersDetails, searchParams, url;
|
333
|
+
return __generator(this, function (_a) {
|
334
|
+
// First check that it is possible to call this API
|
335
|
+
if (!this.cart) {
|
336
|
+
throw Error("Cart is not initialized yet");
|
337
|
+
}
|
338
|
+
buyerPassengersDetails = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.BUYER_PASSENGERS);
|
339
|
+
if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
|
340
|
+
throw Error("The status of the cart does not allow to call this API");
|
341
|
+
}
|
342
|
+
if (!linkavelCardNumber && !linkavelCardPhoneNumber) {
|
343
|
+
throw Error("At least one of the parameters linkavelCardNumber and linkavelCardPhoneNumber must be set");
|
344
|
+
}
|
345
|
+
searchParams = new URLSearchParams({
|
346
|
+
linkavelCardNumber: linkavelCardNumber !== null && linkavelCardNumber !== void 0 ? linkavelCardNumber : "",
|
347
|
+
linkavelCardPhoneNumber: linkavelCardPhoneNumber !== null && linkavelCardPhoneNumber !== void 0 ? linkavelCardPhoneNumber : "",
|
348
|
+
});
|
349
|
+
url = "".concat(this.config.API_ENDPOINT, "/buyers?").concat(searchParams, "}");
|
350
|
+
return [2 /*return*/, this.callGetApi(url).then(function (response) {
|
351
|
+
// Check for errors
|
352
|
+
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
353
|
+
return response;
|
354
|
+
}
|
355
|
+
return response.buyers[0];
|
356
|
+
})];
|
357
|
+
});
|
358
|
+
});
|
359
|
+
};
|
320
360
|
/**
|
321
361
|
* @description This methosd shall be called when the user wants to update the buyer and the passengers information.
|
322
362
|
* @param {EditPassengersDetailsRequest} passengersDetails The object containing the buyer and the passengers information.
|
package/lib/index.d.ts
CHANGED
@@ -2,7 +2,8 @@ export { Booking } from "./booking/booking";
|
|
2
2
|
export { JourneyBooking } from "./booking/journeyBooking";
|
3
3
|
export { ServiceBooking } from "./booking/serviceBooking";
|
4
4
|
export { SubscriptionBooking } from "./booking/subscriptionBooking";
|
5
|
-
export { Person,
|
5
|
+
export { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
|
6
|
+
export { EditPassengerRequestType, EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse } from "./types/common/Person";
|
6
7
|
export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
|
7
8
|
export { Reduction, AddReductionRequest } from "./types/common/Reduction";
|
8
9
|
export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
|
package/lib/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_CREATE_JOURNEY_CART = exports.SeatStatus = exports.BusCellTypes = exports.PaymentMethods = exports.GatewayTypes = exports.DEFAULT_PERSON = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
|
3
|
+
exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_CREATE_JOURNEY_CART = exports.SeatStatus = exports.BusCellTypes = exports.PaymentMethods = exports.GatewayTypes = exports.initializePerson = exports.DEFAULT_PERSON = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
|
4
4
|
//#region Export Booking classes
|
5
5
|
var booking_1 = require("./booking/booking");
|
6
6
|
Object.defineProperty(exports, "Booking", { enumerable: true, get: function () { return booking_1.Booking; } });
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "SubscriptionBooking", { enumerable: true, get: f
|
|
15
15
|
// @note: Cart is not exported because it is extended by other types
|
16
16
|
var Person_1 = require("./types/common/Person");
|
17
17
|
Object.defineProperty(exports, "DEFAULT_PERSON", { enumerable: true, get: function () { return Person_1.DEFAULT_PERSON; } });
|
18
|
+
Object.defineProperty(exports, "initializePerson", { enumerable: true, get: function () { return Person_1.initializePerson; } });
|
18
19
|
var Payment_1 = require("./types/common/Payment");
|
19
20
|
Object.defineProperty(exports, "GatewayTypes", { enumerable: true, get: function () { return Payment_1.GatewayTypes; } });
|
20
21
|
Object.defineProperty(exports, "PaymentMethods", { enumerable: true, get: function () { return Payment_1.PaymentMethods; } });
|
@@ -18,6 +18,7 @@ export type Person = {
|
|
18
18
|
notes?: string;
|
19
19
|
};
|
20
20
|
export declare const DEFAULT_PERSON: Person;
|
21
|
+
export declare const initializePerson: (person?: Person | undefined | null) => Person;
|
21
22
|
/**
|
22
23
|
* @description Represents the response of the {@link getBuyerPassengersDetails} method.
|
23
24
|
*
|
@@ -31,18 +32,22 @@ export type GetBuyerPassengersDetailsResponse = {
|
|
31
32
|
passengers: Person[];
|
32
33
|
tariffs: Map<number, PassengerTariff>;
|
33
34
|
};
|
35
|
+
/**
|
36
|
+
* @description Represents the type of the passengers array in {@link EditPassengersDetailsRequest}.
|
37
|
+
*/
|
38
|
+
export type EditPassengerRequestType = Person & {
|
39
|
+
tripsToTariffs: {
|
40
|
+
[tripId: number]: number;
|
41
|
+
};
|
42
|
+
};
|
34
43
|
/**
|
35
44
|
* @description Represents the passengers details.
|
36
45
|
* This type shall be used as request for the {@link updatePassengersDetails} method.
|
37
46
|
*
|
38
|
-
* @property {
|
47
|
+
* @property {EditPassengerRequestType[]} passengers - An array of {@link Person} extended by the map `tripsToTariffs` objects representing the passengers.
|
39
48
|
* @property {Person} buyer - The {@link Person} object representing the buyer.
|
40
49
|
*/
|
41
50
|
export type EditPassengersDetailsRequest = {
|
42
|
-
passengers:
|
43
|
-
tripsToTariffs: {
|
44
|
-
[tripId: number]: number;
|
45
|
-
};
|
46
|
-
};
|
51
|
+
passengers: EditPassengerRequestType[];
|
47
52
|
buyer: Person;
|
48
53
|
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
// This module contains the types to manage the passengers information
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.DEFAULT_PERSON = void 0;
|
4
|
+
exports.initializePerson = exports.DEFAULT_PERSON = void 0;
|
5
5
|
exports.DEFAULT_PERSON = {
|
6
6
|
id: 0,
|
7
7
|
name: '',
|
@@ -9,3 +9,10 @@ exports.DEFAULT_PERSON = {
|
|
9
9
|
email: '',
|
10
10
|
phoneNumber: ''
|
11
11
|
};
|
12
|
+
var initializePerson = function (person) {
|
13
|
+
if (!person) {
|
14
|
+
return exports.DEFAULT_PERSON;
|
15
|
+
}
|
16
|
+
return person;
|
17
|
+
};
|
18
|
+
exports.initializePerson = initializePerson;
|