mts-booking-library 1.3.14 → 1.3.15
Sign up to get free protection for your applications and to get access to all the features.
@@ -103,11 +103,13 @@ export declare class TplBooking extends Booking {
|
|
103
103
|
getTariffs(superAreaId: number, termsTypeId: number | null, onlyTickets: boolean, onlySubscriptions: boolean): Promise<ErrorResponse | GetTariffsResponse>;
|
104
104
|
/**
|
105
105
|
* This method allows to create a TPL cart.
|
106
|
-
* @param
|
107
|
-
* @param
|
108
|
-
* @param
|
106
|
+
* @param tariffIdToQuantity A map that associates a tariff id (the one chosen by the user) to the number of tickets to buy for that tariff.
|
107
|
+
* @param currency The currency in which the ticket is priced.
|
108
|
+
* @param startDate The start date of the ticket. This is optional and should be used only for subscriptions.
|
109
|
+
* @param isCurrentPeriod Whether the subscription is for the current period. This is optional and should be used only for subscriptions.
|
110
|
+
* @param renewSubscriptionTicketPNR The PNR of the subscription ticket to renew. This is optional and should be used only for subscriptions.
|
109
111
|
*/
|
110
|
-
createTplCart(tariffIdToQuantity: Map<number, number>, currency: Booking.Currencies, startDate?: string): Promise<ErrorResponse | TplCart>;
|
112
|
+
createTplCart(tariffIdToQuantity: Map<number, number>, currency: Booking.Currencies, startDate?: string, isCurrentPeriod?: boolean, renewSubscriptionTicketPNR?: string): Promise<ErrorResponse | TplCart>;
|
111
113
|
/**
|
112
114
|
* @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
|
113
115
|
* @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
|
@@ -313,11 +313,13 @@ var TplBooking = /** @class */ (function (_super) {
|
|
313
313
|
};
|
314
314
|
/**
|
315
315
|
* This method allows to create a TPL cart.
|
316
|
-
* @param
|
317
|
-
* @param
|
318
|
-
* @param
|
316
|
+
* @param tariffIdToQuantity A map that associates a tariff id (the one chosen by the user) to the number of tickets to buy for that tariff.
|
317
|
+
* @param currency The currency in which the ticket is priced.
|
318
|
+
* @param startDate The start date of the ticket. This is optional and should be used only for subscriptions.
|
319
|
+
* @param isCurrentPeriod Whether the subscription is for the current period. This is optional and should be used only for subscriptions.
|
320
|
+
* @param renewSubscriptionTicketPNR The PNR of the subscription ticket to renew. This is optional and should be used only for subscriptions.
|
319
321
|
*/
|
320
|
-
TplBooking.prototype.createTplCart = function (tariffIdToQuantity, currency, startDate) {
|
322
|
+
TplBooking.prototype.createTplCart = function (tariffIdToQuantity, currency, startDate, isCurrentPeriod, renewSubscriptionTicketPNR) {
|
321
323
|
return __awaiter(this, void 0, void 0, function () {
|
322
324
|
var url, processedTariffIdToQuantity, request;
|
323
325
|
var _this = this;
|
@@ -327,7 +329,7 @@ var TplBooking = /** @class */ (function (_super) {
|
|
327
329
|
tariffIdToQuantity.forEach(function (value, key) {
|
328
330
|
processedTariffIdToQuantity[key] = value;
|
329
331
|
});
|
330
|
-
request = __assign({ tariffIdToQuantity: processedTariffIdToQuantity, currency: currency }, (startDate && { startDate: startDate }));
|
332
|
+
request = __assign(__assign(__assign({ tariffIdToQuantity: processedTariffIdToQuantity, currency: currency }, (startDate !== undefined && { startDate: startDate })), (isCurrentPeriod !== undefined && { isCurrentPeriod: isCurrentPeriod })), (renewSubscriptionTicketPNR !== undefined && { renewSubscriptionTicketPNR: renewSubscriptionTicketPNR }));
|
331
333
|
// Call the API
|
332
334
|
return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
|
333
335
|
// Check for errors
|
@@ -37,23 +37,22 @@ export type GetPassenger = Person & {
|
|
37
37
|
returnTariffs: Map<number, PassengerTariff[]> | null;
|
38
38
|
};
|
39
39
|
export declare enum BuyerDataStatus {
|
40
|
+
/** The buyer data are optional. Buyer form shall be displayed, but the user can skip it. */
|
40
41
|
OPTIONAL = 0,
|
42
|
+
/** The buyer data are required. Buyer form shall be displayed and the user cannot skip it. */
|
41
43
|
REQUIRED = 1,
|
44
|
+
/** The buyer data cannot be specified. Buyer form shall not be displayed. */
|
42
45
|
CANNOT_BE_SPECIFIED = 2
|
43
46
|
}
|
44
47
|
/**
|
45
|
-
*
|
46
|
-
*
|
47
|
-
* @property {BuyerDataStatus} buyerDataStatus - Whether the for for the buyer data are required, optional or cannot be specified.
|
48
|
-
* - `OPTIONAL`: The buyer data are optional. Buyer form shall be displayed, but the user can skip it.
|
49
|
-
* - `REQUIRED`: The buyer data are required. Buyer form shall be displayed and the user cannot skip it.
|
50
|
-
* - `CANNOT_BE_SPECIFIED`: The buyer data cannot be specified. Buyer form shall not be displayed.
|
51
|
-
* @property {Person} buyer - The {@link Person} object representing the buyer.
|
52
|
-
* @property {GetPassenger[]} passengers - An array of {@link GetPassenger} objects representing the passengers.
|
48
|
+
* Represents the response of the {@link getBuyerPassengersDetails} method.
|
53
49
|
*/
|
54
50
|
export type GetBuyerPassengersDetailsResponse = {
|
51
|
+
/** Whether the form for the buyer data is required, optional or cannot be specified. */
|
55
52
|
buyerDataStatus: BuyerDataStatus;
|
53
|
+
/** The {@link Person} object representing the buyer. */
|
56
54
|
buyer: Person;
|
55
|
+
/** An array of {@link GetPassenger} objects representing the passengers. */
|
57
56
|
passengers: GetPassenger[];
|
58
57
|
};
|
59
58
|
/**
|
@@ -18,7 +18,10 @@ var initializePerson = function (person) {
|
|
18
18
|
exports.initializePerson = initializePerson;
|
19
19
|
var BuyerDataStatus;
|
20
20
|
(function (BuyerDataStatus) {
|
21
|
+
/** The buyer data are optional. Buyer form shall be displayed, but the user can skip it. */
|
21
22
|
BuyerDataStatus[BuyerDataStatus["OPTIONAL"] = 0] = "OPTIONAL";
|
23
|
+
/** The buyer data are required. Buyer form shall be displayed and the user cannot skip it. */
|
22
24
|
BuyerDataStatus[BuyerDataStatus["REQUIRED"] = 1] = "REQUIRED";
|
25
|
+
/** The buyer data cannot be specified. Buyer form shall not be displayed. */
|
23
26
|
BuyerDataStatus[BuyerDataStatus["CANNOT_BE_SPECIFIED"] = 2] = "CANNOT_BE_SPECIFIED";
|
24
27
|
})(BuyerDataStatus || (exports.BuyerDataStatus = BuyerDataStatus = {}));
|
@@ -1,17 +1,43 @@
|
|
1
1
|
/**
|
2
2
|
* This represents a tariff, which defined the price to pay for a certain ticket.
|
3
|
-
* @param {number} id - The id of the tariff.
|
4
|
-
* @param {number} tariffTypeId - The id of the tariff type.
|
5
|
-
* @param {number} termsTypeId - The id of the terms type.
|
6
|
-
* @param {number} value - The value of the tariff (in the currency specified in the {@link Booking} object).
|
7
|
-
* @param {number} quantity - The number of passengers to which this tariff applies.
|
8
3
|
*/
|
9
4
|
export type Tariff = {
|
5
|
+
/** The id of the tariff */
|
10
6
|
id: number;
|
7
|
+
/** The id of the tariff type */
|
11
8
|
tariffTypeId: number;
|
9
|
+
/** The id of the terms type */
|
12
10
|
termsTypeId: number;
|
11
|
+
/** The id of the tariff plan */
|
12
|
+
tariffPlanId: number;
|
13
|
+
/** The id of the seller */
|
14
|
+
sellerId: number;
|
15
|
+
/** The id of the associated segment, if any */
|
16
|
+
segmentId: number | null;
|
17
|
+
/** The id of the associated super area, if any */
|
18
|
+
superAreaId: number | null;
|
19
|
+
/** The id of the associated extra, if any */
|
20
|
+
extraId: number | null;
|
21
|
+
/** The value of the tariff (in the currency specified in the {@link Booking} object) */
|
13
22
|
value: number;
|
23
|
+
/** @deprecated Use {@link Tariff.valueCurrencies} instead */
|
24
|
+
currency: null;
|
25
|
+
/** The value of the tariff in the different currencies */
|
26
|
+
valueCurrencies: {
|
27
|
+
percentage: number | null;
|
28
|
+
eur: number | null;
|
29
|
+
usd: number | null;
|
30
|
+
chf: number | null;
|
31
|
+
id: number;
|
32
|
+
};
|
33
|
+
/** The number of passengers to which this tariff applies */
|
14
34
|
quantity: number;
|
35
|
+
/** The custom code for one-way tickets */
|
36
|
+
oneWayCode: string | null;
|
37
|
+
/** The custom code for round trip tickets */
|
38
|
+
roundTripCode: string | null;
|
39
|
+
/** Whether the tariff is active */
|
40
|
+
isActive: boolean;
|
15
41
|
};
|
16
42
|
/**
|
17
43
|
* This represents a tariff matrix, returned when searching Journeys or Services.
|
@@ -22,41 +48,57 @@ export type Tariff = {
|
|
22
48
|
export type TariffsMatrix = (Tariff | undefined)[][];
|
23
49
|
/**
|
24
50
|
* This represents a tariff type (e.g. "Adult", "Child", "Over65", ...).
|
25
|
-
* @param {number} id - The id of the tariff type in the db.
|
26
|
-
* @param {string} name - The name of the tariff type.
|
27
|
-
* @param {string} description - The description of the tariff type.
|
28
|
-
* @param {boolean} requiredPassengersName - Whether the passengers' names are required for this tariff type.
|
29
|
-
* @param {number} numberOfOccupiedSeats - The number of seats occupied by this tariff type.
|
30
|
-
* @param {string} bookingProcessDescription - A message to be shown to the user during the booking process that describes the tariff type,
|
31
|
-
* including info on the rules that apply to it.
|
32
51
|
*/
|
33
52
|
export type TariffType = {
|
53
|
+
/** The id of the tariff type in the db */
|
34
54
|
id: number;
|
55
|
+
/** The name of the tariff type */
|
35
56
|
name: string;
|
57
|
+
/** The description of the tariff type */
|
36
58
|
description: string;
|
59
|
+
/** Whether the passengers' names are required for this tariff type */
|
37
60
|
requiredPassengersName: boolean;
|
61
|
+
/** The number of seats occupied by this tariff type */
|
38
62
|
numberOfOccupiedSeats: number;
|
63
|
+
/**
|
64
|
+
* A message to be shown to the user during the booking process that describes the tariff type,
|
65
|
+
* including info on the rules that apply to it
|
66
|
+
*/
|
39
67
|
bookingProcessDescription: string;
|
40
68
|
};
|
41
69
|
/**
|
42
70
|
* This represents a terms type (e.g. "Standard", "Business", ...).
|
43
|
-
* @param {number} id - The id of the terms type in the db.
|
44
|
-
* @param {string} name - The name of the terms type.
|
45
|
-
* @param {string} description - The description of the terms type.
|
46
|
-
* @param {boolean} isRefundAllowed - Whether tickets refunds are allowed for this terms type.
|
47
|
-
* @param {boolean} isChangeAllowed - Whether changing the ticket is allowed for this terms type.
|
48
|
-
* @param {string} validationRulesString - A string containing the validation rules that apply to this terms type.
|
49
|
-
* @param {string} bookingProcessDescription - A message to be shown to the user during the booking process that describes the terms type,
|
50
|
-
* including info on the rules that apply to it.
|
51
71
|
*/
|
52
72
|
export type TermsType = {
|
73
|
+
/** The id of the terms type in the db */
|
53
74
|
id: number;
|
75
|
+
/** The name of the terms type */
|
54
76
|
name: string;
|
77
|
+
/** The description of the terms type */
|
55
78
|
description: string;
|
79
|
+
/** Whether tickets refunds are allowed for this terms type */
|
56
80
|
isRefundAllowed: boolean;
|
81
|
+
/** Whether changing the ticket is allowed for this terms type */
|
57
82
|
isChangeAllowed: boolean;
|
83
|
+
/** A string containing the validation rules that apply to this terms type */
|
58
84
|
validationRulesString: string;
|
85
|
+
/**
|
86
|
+
* A message to be shown to the user during the booking process that describes the terms type,
|
87
|
+
* including info on the rules that apply to it
|
88
|
+
*/
|
59
89
|
bookingProcessDescription: string;
|
90
|
+
/** Whether these terms are the default ones */
|
91
|
+
isDefault: boolean;
|
92
|
+
/** Whether the terms are for a subscription */
|
93
|
+
isSubscription: boolean;
|
94
|
+
/** Whether a start date can be selected for this ticket */
|
95
|
+
canSelectStartDate: boolean;
|
96
|
+
/** Whether a start date is mandatory for this ticket */
|
97
|
+
isStartDateMandatory: boolean;
|
98
|
+
/** The validation rule for these terms */
|
99
|
+
validationRule: any | null;
|
100
|
+
/** The rules associated with these terms */
|
101
|
+
rules: any | null;
|
60
102
|
};
|
61
103
|
export type TariffSummary = {
|
62
104
|
quantity: number;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.15",
|
4
4
|
"description": "Library for using MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"jest": "^29.7.0",
|
21
21
|
"prettier": "^3.3.3",
|
22
22
|
"ts-jest": "^29.2.3",
|
23
|
-
"typescript": "^5.5.
|
23
|
+
"typescript": "^5.5.4"
|
24
24
|
},
|
25
25
|
"files": [
|
26
26
|
"lib/**/*"
|