mts-booking-library 3.6.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/booking/booking.d.ts +7 -1
- package/lib/booking/booking.js +15 -6
- package/lib/booking/journeyBooking.d.ts +1 -1
- package/lib/booking/journeyBooking.js +3 -2
- package/lib/booking/serviceBooking.d.ts +1 -1
- package/lib/booking/serviceBooking.js +3 -2
- package/lib/booking/subscriptionBooking.d.ts +1 -1
- package/lib/booking/subscriptionBooking.js +3 -2
- package/lib/booking/tplBooking.d.ts +22 -8
- package/lib/booking/tplBooking.js +66 -25
- package/lib/config.d.ts +8 -1
- package/lib/config.js +4 -2
- package/lib/index.d.ts +1 -1
- package/lib/types/tpl/SuperArea.d.ts +24 -0
- package/package.json +1 -1
package/lib/booking/booking.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare abstract class Booking {
|
|
|
28
28
|
/**
|
|
29
29
|
* This is the constructor of the Booking class. See {@link Booking.BookingConfig} for more information.
|
|
30
30
|
*/
|
|
31
|
-
constructor({ env, subKey, bookingType, debug, language, sessionId, accessToken, sellerId, resellerId, appVersion, os, dbType }: Omit<Booking.BookingConfig, "restoreState">);
|
|
31
|
+
constructor({ env, subKey, bookingType, debug, language, sessionId, accessToken, sellerId, resellerId, appVersion, os, dbType, useLegacyPermissions }: Omit<Booking.BookingConfig, "restoreState">);
|
|
32
32
|
/**
|
|
33
33
|
* This method allows to update the sellerId. It is mostly important for Linkavel, as we start with sellerId = 0
|
|
34
34
|
* but then it changes to the actual sellerId once the cart is created.
|
|
@@ -174,5 +174,11 @@ export declare namespace Booking {
|
|
|
174
174
|
appVersion?: string;
|
|
175
175
|
/** If this library is used from the MTS App, this is the operating system (android or ios) */
|
|
176
176
|
os?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Opt into the BE legacy authorization resolver. When provided the value is
|
|
179
|
+
* forwarded on every request (`useLegacyPermissions` body field for POST/PUT,
|
|
180
|
+
* query parameter for GET/DELETE). Leave undefined to defer to the BE default.
|
|
181
|
+
*/
|
|
182
|
+
useLegacyPermissions?: boolean;
|
|
177
183
|
};
|
|
178
184
|
}
|
package/lib/booking/booking.js
CHANGED
|
@@ -59,7 +59,7 @@ var Booking = /** @class */ (function () {
|
|
|
59
59
|
* This is the constructor of the Booking class. See {@link Booking.BookingConfig} for more information.
|
|
60
60
|
*/
|
|
61
61
|
function Booking(_a) {
|
|
62
|
-
var env = _a.env, subKey = _a.subKey, bookingType = _a.bookingType, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType;
|
|
62
|
+
var env = _a.env, subKey = _a.subKey, bookingType = _a.bookingType, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType, useLegacyPermissions = _a.useLegacyPermissions;
|
|
63
63
|
this.language = Booking.Languages.EN;
|
|
64
64
|
this.selectedCurrency = Booking.Currencies.EUR;
|
|
65
65
|
/**
|
|
@@ -81,7 +81,8 @@ var Booking = /** @class */ (function () {
|
|
|
81
81
|
APP_VERSION: appVersion,
|
|
82
82
|
OS: os,
|
|
83
83
|
DB_TYPE: dbType,
|
|
84
|
-
SESSION_ID: sessionId
|
|
84
|
+
SESSION_ID: sessionId,
|
|
85
|
+
USE_LEGACY_PERMISSIONS: useLegacyPermissions
|
|
85
86
|
});
|
|
86
87
|
this.bookingType = bookingType;
|
|
87
88
|
this.changeLanguage(language);
|
|
@@ -111,21 +112,27 @@ var Booking = /** @class */ (function () {
|
|
|
111
112
|
// Add sellerId, resellerId and language to the query string.
|
|
112
113
|
// If the last character of the url is a question mark (meaning that the query string is empty), don't add the "&" character.
|
|
113
114
|
// Otherwise, add it (as we are adding some parameters to the query string)
|
|
114
|
-
var completeUrl = "".concat(url).concat(url.slice(-1) === "?" ? "" : "&").concat(new URLSearchParams(__assign(__assign(__assign({ sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "0", resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0", language: this.language }, (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE }))
|
|
115
|
+
var completeUrl = "".concat(url).concat(url.slice(-1) === "?" ? "" : "&").concat(new URLSearchParams(__assign(__assign(__assign(__assign({ sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "0", resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0", language: this.language }, (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE })), (config.USE_LEGACY_PERMISSIONS !== undefined && {
|
|
116
|
+
useLegacyPermissions: String(config.USE_LEGACY_PERMISSIONS)
|
|
117
|
+
}))));
|
|
115
118
|
return (0, apiCall_1.makeGet)(completeUrl, options);
|
|
116
119
|
};
|
|
117
120
|
Booking.prototype.callPostApi = function (url, body, options) {
|
|
118
121
|
var _a, _b, _c, _d;
|
|
119
122
|
var config = (0, config_1.getConfig)();
|
|
120
123
|
// Add sellerId, resellerId and language to the query string
|
|
121
|
-
var completeBody = __assign(__assign(__assign(__assign(__assign({}, body), { sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 0, resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : 0, language: this.language }), (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE }))
|
|
124
|
+
var completeBody = __assign(__assign(__assign(__assign(__assign(__assign({}, body), { sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 0, resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : 0, language: this.language }), (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE })), (config.USE_LEGACY_PERMISSIONS !== undefined && {
|
|
125
|
+
useLegacyPermissions: config.USE_LEGACY_PERMISSIONS
|
|
126
|
+
}));
|
|
122
127
|
return (0, apiCall_1.makePost)(url, completeBody, options);
|
|
123
128
|
};
|
|
124
129
|
Booking.prototype.callPutApi = function (url, body, options) {
|
|
125
130
|
var _a, _b, _c, _d;
|
|
126
131
|
var config = (0, config_1.getConfig)();
|
|
127
132
|
// Add sellerId, resellerId and language to the query string
|
|
128
|
-
var completeBody = __assign(__assign(__assign(__assign(__assign({}, body), { sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 0, resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : 0, language: this.language }), (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE }))
|
|
133
|
+
var completeBody = __assign(__assign(__assign(__assign(__assign(__assign({}, body), { sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 0, resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : 0, language: this.language }), (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE })), (config.USE_LEGACY_PERMISSIONS !== undefined && {
|
|
134
|
+
useLegacyPermissions: config.USE_LEGACY_PERMISSIONS
|
|
135
|
+
}));
|
|
129
136
|
return (0, apiCall_1.makePut)(url, completeBody, options);
|
|
130
137
|
};
|
|
131
138
|
Booking.prototype.callDeleteApi = function (url, options) {
|
|
@@ -134,7 +141,9 @@ var Booking = /** @class */ (function () {
|
|
|
134
141
|
// Add sellerId, resellerId and language to the query string.
|
|
135
142
|
// If the last character of the url is a question mark (meaning that the query string is empty), don't add the "&" character.
|
|
136
143
|
// Otherwise, add it (as we are adding some parameters to the query string)
|
|
137
|
-
var completeUrl = "".concat(url).concat(url.slice(-1) === "?" ? "" : "&").concat(new URLSearchParams(__assign(__assign(__assign({ sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "0", resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0", language: this.language }, (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE }))
|
|
144
|
+
var completeUrl = "".concat(url).concat(url.slice(-1) === "?" ? "" : "&").concat(new URLSearchParams(__assign(__assign(__assign(__assign({ sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : "0", resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : "0", language: this.language }, (config.OS && { os: config.OS })), (config.APP_VERSION && { version: config.APP_VERSION })), (config.ENV === config_1.MTSEnvs.DEV && config.DB_TYPE && { databaseType: config.DB_TYPE })), (config.USE_LEGACY_PERMISSIONS !== undefined && {
|
|
145
|
+
useLegacyPermissions: String(config.USE_LEGACY_PERMISSIONS)
|
|
146
|
+
}))));
|
|
138
147
|
return (0, apiCall_1.makeDelete)(completeUrl, options);
|
|
139
148
|
};
|
|
140
149
|
Booking.prototype.getBookingStepsToStatus = function () {
|
|
@@ -28,7 +28,7 @@ export declare class JourneyBooking extends Booking {
|
|
|
28
28
|
/**
|
|
29
29
|
* This is the constructor of the JourneyBooking class. See {@link Booking.BookingConfig} for more information.
|
|
30
30
|
*/
|
|
31
|
-
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType }: Omit<Booking.BookingConfig, "bookingType">);
|
|
31
|
+
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType, useLegacyPermissions }: Omit<Booking.BookingConfig, "bookingType">);
|
|
32
32
|
getCart(): JourneyCart | undefined;
|
|
33
33
|
getStorage(): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<{
|
|
34
34
|
cartGuid: string | undefined;
|
|
@@ -105,7 +105,7 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
105
105
|
* This is the constructor of the JourneyBooking class. See {@link Booking.BookingConfig} for more information.
|
|
106
106
|
*/
|
|
107
107
|
function JourneyBooking(_a) {
|
|
108
|
-
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType;
|
|
108
|
+
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType, useLegacyPermissions = _a.useLegacyPermissions;
|
|
109
109
|
// Call Booking constructor
|
|
110
110
|
var _this = _super.call(this, {
|
|
111
111
|
env: env,
|
|
@@ -119,7 +119,8 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
|
119
119
|
resellerId: resellerId,
|
|
120
120
|
appVersion: appVersion,
|
|
121
121
|
os: os,
|
|
122
|
-
dbType: dbType
|
|
122
|
+
dbType: dbType,
|
|
123
|
+
useLegacyPermissions: useLegacyPermissions
|
|
123
124
|
}) || this;
|
|
124
125
|
// Set cartGuid
|
|
125
126
|
var cartGuid = _this.getStorage().getState().cartGuid;
|
|
@@ -12,7 +12,7 @@ export declare class ServiceBooking extends Booking {
|
|
|
12
12
|
/**
|
|
13
13
|
* This is the constructor of the ServiceBooking class. See {@link Booking.BookingConfig} for more information.
|
|
14
14
|
*/
|
|
15
|
-
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType }: Omit<Booking.BookingConfig, "bookingType">);
|
|
15
|
+
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType, useLegacyPermissions }: Omit<Booking.BookingConfig, "bookingType">);
|
|
16
16
|
getStorage(): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<{
|
|
17
17
|
cartGuid: string | undefined;
|
|
18
18
|
} & {
|
|
@@ -85,7 +85,7 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
85
85
|
* This is the constructor of the ServiceBooking class. See {@link Booking.BookingConfig} for more information.
|
|
86
86
|
*/
|
|
87
87
|
function ServiceBooking(_a) {
|
|
88
|
-
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType;
|
|
88
|
+
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType, useLegacyPermissions = _a.useLegacyPermissions;
|
|
89
89
|
// Call Booking constructor
|
|
90
90
|
var _this = _super.call(this, {
|
|
91
91
|
env: env,
|
|
@@ -99,7 +99,8 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
|
99
99
|
resellerId: resellerId,
|
|
100
100
|
appVersion: appVersion,
|
|
101
101
|
os: os,
|
|
102
|
-
dbType: dbType
|
|
102
|
+
dbType: dbType,
|
|
103
|
+
useLegacyPermissions: useLegacyPermissions
|
|
103
104
|
}) || this;
|
|
104
105
|
// Set cartGuid
|
|
105
106
|
var cartGuid = _this.getStorage().getState().cartGuid;
|
|
@@ -12,7 +12,7 @@ export declare class SubscriptionBooking extends Booking {
|
|
|
12
12
|
/**
|
|
13
13
|
* This is the constructor of the ServiceBooking class. See {@link Booking.BookingConfig} for more information.
|
|
14
14
|
*/
|
|
15
|
-
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType }: Omit<Booking.BookingConfig, "bookingType">);
|
|
15
|
+
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType, useLegacyPermissions }: Omit<Booking.BookingConfig, "bookingType">);
|
|
16
16
|
getStorage(): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<{
|
|
17
17
|
cartGuid: string | undefined;
|
|
18
18
|
} & {
|
|
@@ -85,7 +85,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
85
85
|
* This is the constructor of the ServiceBooking class. See {@link Booking.BookingConfig} for more information.
|
|
86
86
|
*/
|
|
87
87
|
function SubscriptionBooking(_a) {
|
|
88
|
-
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType;
|
|
88
|
+
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType, useLegacyPermissions = _a.useLegacyPermissions;
|
|
89
89
|
// Call Booking constructor
|
|
90
90
|
var _this = _super.call(this, {
|
|
91
91
|
env: env,
|
|
@@ -99,7 +99,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
|
99
99
|
resellerId: resellerId,
|
|
100
100
|
appVersion: appVersion,
|
|
101
101
|
os: os,
|
|
102
|
-
dbType: dbType
|
|
102
|
+
dbType: dbType,
|
|
103
|
+
useLegacyPermissions: useLegacyPermissions
|
|
103
104
|
}) || this;
|
|
104
105
|
// Set cartGuid
|
|
105
106
|
var cartGuid = _this.getStorage().getState().cartGuid;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ErrorResponse } from "../types/ErrorResponse";
|
|
2
2
|
import { CreateUpdateCartRequest } from "../types/common/Cart";
|
|
3
3
|
import { City } from "../types/common/City";
|
|
4
|
-
import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
|
4
|
+
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
|
5
5
|
import { AddReductionRequest } from "../types/common/Reduction";
|
|
6
6
|
import { TariffType, TermsType } from "../types/common/Tariffs";
|
|
7
7
|
import { GetTariffsResponse } from "../types/tpl/GetTariffsResponse";
|
|
@@ -20,7 +20,7 @@ export declare class TplBooking extends Booking {
|
|
|
20
20
|
/**
|
|
21
21
|
* This is the constructor of the TplBooking class. See {@link Booking.BookingConfig} for more information.
|
|
22
22
|
*/
|
|
23
|
-
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType }: Omit<Booking.BookingConfig, "bookingType">);
|
|
23
|
+
constructor({ env, subKey, debug, language, sessionId, restoreState, accessToken, sellerId, resellerId, appVersion, os, dbType, useLegacyPermissions }: Omit<Booking.BookingConfig, "bookingType">);
|
|
24
24
|
getStorage(): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<{
|
|
25
25
|
cartGuid: string | undefined;
|
|
26
26
|
} & {
|
|
@@ -179,14 +179,28 @@ export declare class TplBooking extends Booking {
|
|
|
179
179
|
*/
|
|
180
180
|
getBuyerPassengersDetails(options?: ApiCallOptions): Promise<ErrorResponse | GetBuyerPassengersDetailsResponse>;
|
|
181
181
|
/**
|
|
182
|
-
* @description
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
182
|
+
* @description Update the buyer and (optionally) per-passenger data for a TPL cart.
|
|
183
|
+
*
|
|
184
|
+
* Two shapes are supported:
|
|
185
|
+
*
|
|
186
|
+
* 1. Legacy buyer-only / subscription form: pass `(buyer, subscriptionPersonCode?)`.
|
|
187
|
+
* Used by plain TPL bookings and by TPLSubscription, where only the buyer's data
|
|
188
|
+
* (plus optionally the subscription holder's PersonCode) is editable.
|
|
189
|
+
*
|
|
190
|
+
* 2. Full request form: pass an `EditPassengersDetailsRequest` (mirrors
|
|
191
|
+
* {@link JourneyBooking.updateBuyerPassengersDetails}). Used by TPL_TOUR
|
|
192
|
+
* bookings, where each ticket has its own passenger with Name/LastName/Email/
|
|
193
|
+
* PhoneNumber/Sex. Per-passenger `tripsToTariffs` is serialized to JSON like
|
|
194
|
+
* Journey does; pass an empty Map for TPL_TOUR (single Trip, fixed tariff).
|
|
195
|
+
*
|
|
196
|
+
* @param payload Either a {@link Person} (or null) for the legacy form, or an
|
|
197
|
+
* {@link EditPassengersDetailsRequest} for the full form.
|
|
198
|
+
* @param subscriptionPersonCode The person code of the passenger associated with the
|
|
199
|
+
* subscription. Required when the cart contains a TPLSubscription. Ignored when
|
|
200
|
+
* `payload` is an `EditPassengersDetailsRequest`.
|
|
187
201
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
|
188
202
|
*/
|
|
189
|
-
updateBuyerPassengersDetails(
|
|
203
|
+
updateBuyerPassengersDetails(payload: Person | null | EditPassengersDetailsRequest, subscriptionPersonCode?: string, options?: ApiCallOptions): Promise<ErrorResponse | boolean>;
|
|
190
204
|
/**
|
|
191
205
|
* @description This method allows to add a reduction to the whole cart or to a single trip in the cart.
|
|
192
206
|
* @param request The information about the reduction to add
|
|
@@ -86,13 +86,25 @@ var TplTariffClassificationType;
|
|
|
86
86
|
TplTariffClassificationType["TPL_TOUR"] = "TARIFF_TYPE_TPL_TOUR";
|
|
87
87
|
TplTariffClassificationType["TPL_SUBSCRIPTION"] = "TARIFF_TYPE_TPL_SUBSCRIPTION";
|
|
88
88
|
})(TplTariffClassificationType || (exports.TplTariffClassificationType = TplTariffClassificationType = {}));
|
|
89
|
+
/**
|
|
90
|
+
* Type guard for the full-request shape of
|
|
91
|
+
* {@link TplBooking.updateBuyerPassengersDetails}. `Person` does not declare a
|
|
92
|
+
* `passengers` field, so the presence of an array there discriminates the new
|
|
93
|
+
* TPL_TOUR contract from the legacy `(buyer, subscriptionPersonCode?)` form.
|
|
94
|
+
*/
|
|
95
|
+
function isEditPassengersDetailsRequest(payload) {
|
|
96
|
+
return (payload !== null &&
|
|
97
|
+
typeof payload === "object" &&
|
|
98
|
+
"passengers" in payload &&
|
|
99
|
+
Array.isArray(payload.passengers));
|
|
100
|
+
}
|
|
89
101
|
var TplBooking = /** @class */ (function (_super) {
|
|
90
102
|
__extends(TplBooking, _super);
|
|
91
103
|
/**
|
|
92
104
|
* This is the constructor of the TplBooking class. See {@link Booking.BookingConfig} for more information.
|
|
93
105
|
*/
|
|
94
106
|
function TplBooking(_a) {
|
|
95
|
-
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType;
|
|
107
|
+
var env = _a.env, subKey = _a.subKey, debug = _a.debug, language = _a.language, sessionId = _a.sessionId, restoreState = _a.restoreState, accessToken = _a.accessToken, sellerId = _a.sellerId, resellerId = _a.resellerId, appVersion = _a.appVersion, os = _a.os, dbType = _a.dbType, useLegacyPermissions = _a.useLegacyPermissions;
|
|
96
108
|
// Call Booking constructor
|
|
97
109
|
var _this = _super.call(this, {
|
|
98
110
|
env: env,
|
|
@@ -106,7 +118,8 @@ var TplBooking = /** @class */ (function (_super) {
|
|
|
106
118
|
resellerId: resellerId,
|
|
107
119
|
appVersion: appVersion,
|
|
108
120
|
os: os,
|
|
109
|
-
dbType: dbType
|
|
121
|
+
dbType: dbType,
|
|
122
|
+
useLegacyPermissions: useLegacyPermissions
|
|
110
123
|
}) || this;
|
|
111
124
|
// Set cartGuid
|
|
112
125
|
var cartGuid = _this.getStorage().getState().cartGuid;
|
|
@@ -253,7 +266,7 @@ var TplBooking = /** @class */ (function (_super) {
|
|
|
253
266
|
return __awaiter(this, void 0, void 0, function () {
|
|
254
267
|
var searchParams, url;
|
|
255
268
|
return __generator(this, function (_a) {
|
|
256
|
-
searchParams = new URLSearchParams(__assign(__assign(__assign({ includeBasicInfo: "true", includeImage: "true", includeAreaIds: "false", includeTariffIds: "false", includeRouteIds: "false", includeMultilingualDescriptions: "false" }, (request.cityId && { cityId: request.cityId.toString() })), (request.tripId && { tripId: request.tripId.toString() })), (request.type && { type: request.type })));
|
|
269
|
+
searchParams = new URLSearchParams(__assign(__assign(__assign({ includeBasicInfo: "true", includeImage: "true", includeAreaIds: "false", includeTariffIds: "false", includeRouteIds: "false", includeMultilingualDescriptions: request.includeMultilingualDescriptions ? "true" : "false" }, (request.cityId && { cityId: request.cityId.toString() })), (request.tripId && { tripId: request.tripId.toString() })), (request.type && { type: request.type })));
|
|
257
270
|
url = "".concat(this.config.API_ENDPOINT, "/v3_resources/superAreas?").concat(searchParams);
|
|
258
271
|
return [2 /*return*/, this.callGetApi(url, options).then(function (response) {
|
|
259
272
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.superAreas;
|
|
@@ -432,41 +445,69 @@ var TplBooking = /** @class */ (function (_super) {
|
|
|
432
445
|
});
|
|
433
446
|
};
|
|
434
447
|
/**
|
|
435
|
-
* @description
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
448
|
+
* @description Update the buyer and (optionally) per-passenger data for a TPL cart.
|
|
449
|
+
*
|
|
450
|
+
* Two shapes are supported:
|
|
451
|
+
*
|
|
452
|
+
* 1. Legacy buyer-only / subscription form: pass `(buyer, subscriptionPersonCode?)`.
|
|
453
|
+
* Used by plain TPL bookings and by TPLSubscription, where only the buyer's data
|
|
454
|
+
* (plus optionally the subscription holder's PersonCode) is editable.
|
|
455
|
+
*
|
|
456
|
+
* 2. Full request form: pass an `EditPassengersDetailsRequest` (mirrors
|
|
457
|
+
* {@link JourneyBooking.updateBuyerPassengersDetails}). Used by TPL_TOUR
|
|
458
|
+
* bookings, where each ticket has its own passenger with Name/LastName/Email/
|
|
459
|
+
* PhoneNumber/Sex. Per-passenger `tripsToTariffs` is serialized to JSON like
|
|
460
|
+
* Journey does; pass an empty Map for TPL_TOUR (single Trip, fixed tariff).
|
|
461
|
+
*
|
|
462
|
+
* @param payload Either a {@link Person} (or null) for the legacy form, or an
|
|
463
|
+
* {@link EditPassengersDetailsRequest} for the full form.
|
|
464
|
+
* @param subscriptionPersonCode The person code of the passenger associated with the
|
|
465
|
+
* subscription. Required when the cart contains a TPLSubscription. Ignored when
|
|
466
|
+
* `payload` is an `EditPassengersDetailsRequest`.
|
|
440
467
|
* @returns An {@link ErrorResponse} object in case of error, true otherwise.
|
|
441
468
|
*/
|
|
442
|
-
TplBooking.prototype.updateBuyerPassengersDetails = function (
|
|
469
|
+
TplBooking.prototype.updateBuyerPassengersDetails = function (payload, subscriptionPersonCode, options) {
|
|
443
470
|
return __awaiter(this, void 0, void 0, function () {
|
|
444
|
-
var buyerPassengersDetails, request, url;
|
|
471
|
+
var buyerPassengersDetails, request, buyerDetails, url;
|
|
445
472
|
var _this = this;
|
|
446
473
|
return __generator(this, function (_a) {
|
|
447
474
|
// First check that it is possible to call this API
|
|
448
475
|
if (!this.cart) {
|
|
449
476
|
throw Error("Cart is not initialized yet");
|
|
450
477
|
}
|
|
451
|
-
if (this.cart.bookings.some(function (b) { return b.info.isSubscription && b.type === TplBooking.BookingTypes.TPL; }) &&
|
|
452
|
-
!subscriptionPersonCode) {
|
|
453
|
-
throw Error("The subscriptionPersonCode is required when updating a subscription");
|
|
454
|
-
}
|
|
455
478
|
buyerPassengersDetails = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.BUYER_PASSENGERS);
|
|
456
479
|
if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
|
|
457
480
|
throw Error("The status of the cart does not allow to call this API");
|
|
458
481
|
}
|
|
459
|
-
|
|
460
|
-
cartGuid: this.cart.guid
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
482
|
+
if (isEditPassengersDetailsRequest(payload)) {
|
|
483
|
+
request = __assign(__assign({}, payload), { cartGuid: this.cart.guid });
|
|
484
|
+
// Mirror JourneyBooking: convert per-passenger tripsToTariffs Map → JSON
|
|
485
|
+
// object. Mutates in-place; safe because `request` is a fresh shallow copy
|
|
486
|
+
// and the payload's passengers are read immediately before the API call.
|
|
487
|
+
payload.passengers.forEach(function (passenger, passengerIndex) {
|
|
488
|
+
var _a;
|
|
489
|
+
var tripsToTariffsToJson = {};
|
|
490
|
+
(_a = passenger.tripsToTariffs) === null || _a === void 0 ? void 0 : _a.forEach(function (value, key) {
|
|
491
|
+
tripsToTariffsToJson[String(key)] = value;
|
|
492
|
+
});
|
|
493
|
+
request.passengers[passengerIndex].tripsToTariffs =
|
|
494
|
+
tripsToTariffsToJson;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
buyerDetails = payload;
|
|
499
|
+
if (this.cart.bookings.some(function (b) { return b.info.isSubscription && b.type === TplBooking.BookingTypes.TPL; }) &&
|
|
500
|
+
!subscriptionPersonCode) {
|
|
501
|
+
throw Error("The subscriptionPersonCode is required when updating a subscription");
|
|
502
|
+
}
|
|
503
|
+
request = {
|
|
504
|
+
cartGuid: this.cart.guid,
|
|
505
|
+
buyer: buyerDetails,
|
|
506
|
+
passengers: subscriptionPersonCode
|
|
507
|
+
? [{ personCode: subscriptionPersonCode }]
|
|
508
|
+
: []
|
|
509
|
+
};
|
|
510
|
+
}
|
|
470
511
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/details");
|
|
471
512
|
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) {
|
|
472
513
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response))
|
package/lib/config.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export type MTSConfig = {
|
|
|
14
14
|
OS: string | undefined;
|
|
15
15
|
DB_TYPE: string | undefined;
|
|
16
16
|
SESSION_ID: number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Per-call opt-in for the BE legacy authorization resolver. When set,
|
|
19
|
+
* `useLegacyPermissions` is added to every POST/PUT body and propagated as
|
|
20
|
+
* `useLegacyPermissions` on GET/DELETE query strings. Leave undefined to let
|
|
21
|
+
* the BE pick its own default (currently legacy at the time of writing).
|
|
22
|
+
*/
|
|
23
|
+
USE_LEGACY_PERMISSIONS: boolean | undefined;
|
|
17
24
|
};
|
|
18
|
-
export declare const setConfig: ({ ENV, OCP_SUBSCRIPTION_KEY, DEBUG, ACCESS_TOKEN, APP_VERSION, OS, DB_TYPE, SESSION_ID }: Omit<MTSConfig, "API_ENDPOINT">) => MTSConfig;
|
|
25
|
+
export declare const setConfig: ({ ENV, OCP_SUBSCRIPTION_KEY, DEBUG, ACCESS_TOKEN, APP_VERSION, OS, DB_TYPE, SESSION_ID, USE_LEGACY_PERMISSIONS }: Omit<MTSConfig, "API_ENDPOINT">) => MTSConfig;
|
|
19
26
|
export declare const getConfig: () => MTSConfig;
|
package/lib/config.js
CHANGED
|
@@ -17,10 +17,11 @@ var config = {
|
|
|
17
17
|
APP_VERSION: undefined,
|
|
18
18
|
OS: undefined,
|
|
19
19
|
DB_TYPE: undefined,
|
|
20
|
-
SESSION_ID: undefined
|
|
20
|
+
SESSION_ID: undefined,
|
|
21
|
+
USE_LEGACY_PERMISSIONS: undefined
|
|
21
22
|
};
|
|
22
23
|
var setConfig = function (_a) {
|
|
23
|
-
var ENV = _a.ENV, OCP_SUBSCRIPTION_KEY = _a.OCP_SUBSCRIPTION_KEY, DEBUG = _a.DEBUG, ACCESS_TOKEN = _a.ACCESS_TOKEN, APP_VERSION = _a.APP_VERSION, OS = _a.OS, DB_TYPE = _a.DB_TYPE, SESSION_ID = _a.SESSION_ID;
|
|
24
|
+
var ENV = _a.ENV, OCP_SUBSCRIPTION_KEY = _a.OCP_SUBSCRIPTION_KEY, DEBUG = _a.DEBUG, ACCESS_TOKEN = _a.ACCESS_TOKEN, APP_VERSION = _a.APP_VERSION, OS = _a.OS, DB_TYPE = _a.DB_TYPE, SESSION_ID = _a.SESSION_ID, USE_LEGACY_PERMISSIONS = _a.USE_LEGACY_PERMISSIONS;
|
|
24
25
|
config.DB_TYPE = undefined;
|
|
25
26
|
// First, set the environment
|
|
26
27
|
config.ENV = ENV.toUpperCase();
|
|
@@ -48,6 +49,7 @@ var setConfig = function (_a) {
|
|
|
48
49
|
// Set app variables
|
|
49
50
|
config.OS = OS;
|
|
50
51
|
config.APP_VERSION = APP_VERSION;
|
|
52
|
+
config.USE_LEGACY_PERMISSIONS = USE_LEGACY_PERMISSIONS;
|
|
51
53
|
return config;
|
|
52
54
|
};
|
|
53
55
|
exports.setConfig = setConfig;
|
package/lib/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { Service, ServiceTrip } from "./types/services/Service";
|
|
|
27
27
|
export { ServiceCart, ServiceBookingType } from "./types/services/ServiceCart";
|
|
28
28
|
export { ServiceInfo } from "./types/services/ServiceInfo";
|
|
29
29
|
export { GetTariffsResponse } from "./types/tpl/GetTariffsResponse";
|
|
30
|
-
export { SuperArea, GetSuperAreasRequest, GetCitiesRequest, SuperAreasTypeFilter } from "./types/tpl/SuperArea";
|
|
30
|
+
export { SuperArea, MTSStringDTO, GetSuperAreasRequest, GetCitiesRequest, SuperAreasTypeFilter } from "./types/tpl/SuperArea";
|
|
31
31
|
export { TplCart, TplBookingType, TplBookingInfo } from "./types/tpl/TplCart";
|
|
32
32
|
export { Subscription } from "./types/subscriptions/Subscriptions";
|
|
33
33
|
export { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse, SubscriptionCalendarDayPeriodInfo } from "./types/subscriptions/SubscriptionAvailabilities";
|
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multilingual string returned by the backend. Each key holds the
|
|
3
|
+
* translation for that language; consumers should fall back to `it`
|
|
4
|
+
* when the active language is missing, matching the backend's
|
|
5
|
+
* `MTSStringDTO.GetValue` resolution rules.
|
|
6
|
+
*/
|
|
7
|
+
export type MTSStringDTO = {
|
|
8
|
+
en: string | null;
|
|
9
|
+
it: string | null;
|
|
10
|
+
fr: string | null;
|
|
11
|
+
de: string | null;
|
|
12
|
+
es: string | null;
|
|
13
|
+
};
|
|
1
14
|
/** This type represents a super area. It is the return object of the {@link TplBooking.getSuperAreas} method. */
|
|
2
15
|
export type SuperArea = {
|
|
3
16
|
/** The id of the super area in the database */
|
|
@@ -12,6 +25,11 @@ export type SuperArea = {
|
|
|
12
25
|
bookingProcessDescription: string;
|
|
13
26
|
/** The url of the image of the super area */
|
|
14
27
|
imageUrl: string;
|
|
28
|
+
/**
|
|
29
|
+
* LinkAvel-specific multilingual description. Only present when the
|
|
30
|
+
* request is made with `includeMultilingualDescriptions: true`.
|
|
31
|
+
*/
|
|
32
|
+
linkAvelDescription?: MTSStringDTO;
|
|
15
33
|
};
|
|
16
34
|
export declare enum SuperAreasTypeFilter {
|
|
17
35
|
/** No filter applied (default). */
|
|
@@ -33,6 +51,12 @@ export type GetSuperAreasRequest = {
|
|
|
33
51
|
* A super area cannot simultaneously be a tour and a regular super area.
|
|
34
52
|
*/
|
|
35
53
|
type?: SuperAreasTypeFilter;
|
|
54
|
+
/**
|
|
55
|
+
* When true, the response includes the multilingual `linkAvelDescription`
|
|
56
|
+
* field on each super area. Defaults to false to keep payloads minimal
|
|
57
|
+
* for callers that only need basic info.
|
|
58
|
+
*/
|
|
59
|
+
includeMultilingualDescriptions?: boolean;
|
|
36
60
|
};
|
|
37
61
|
/** Request options for {@link TplBooking.getCities}. */
|
|
38
62
|
export type GetCitiesRequest = {
|