mts-booking-library 2.3.2 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/booking/booking.js +1 -7
- package/lib/booking/journeyBooking.js +3 -5
- package/lib/booking/serviceBooking.js +2 -5
- package/lib/booking/subscriptionBooking.d.ts +2 -1
- package/lib/booking/subscriptionBooking.js +4 -5
- package/lib/booking/tplBooking.js +2 -5
- package/lib/config.d.ts +5 -5
- package/lib/config.js +5 -1
- package/lib/types/common/Person.d.ts +36 -15
- package/lib/types/common/Person.js +11 -1
- package/package.json +3 -3
package/lib/booking/booking.js
CHANGED
@@ -102,13 +102,7 @@ var Booking = /** @class */ (function () {
|
|
102
102
|
* @param {string} access_token The new access token
|
103
103
|
*/
|
104
104
|
Booking.prototype.renewAccessToken = function (access_token) {
|
105
|
-
var newConfig = {
|
106
|
-
ENV: this.config.ENV,
|
107
|
-
OCP_SUBSCRIPTION_KEY: this.config.OCP_SUBSCRIPTION_KEY,
|
108
|
-
DEBUG: this.config.DEBUG,
|
109
|
-
ACCESS_TOKEN: access_token,
|
110
|
-
DB_TYPE: this.config.DB_TYPE
|
111
|
-
};
|
105
|
+
var newConfig = __assign(__assign({}, (0, config_1.getConfig)()), { ACCESS_TOKEN: access_token });
|
112
106
|
(0, config_1.setConfig)(newConfig);
|
113
107
|
};
|
114
108
|
Booking.prototype.callGetApi = function (url, options) {
|
@@ -395,11 +395,9 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
395
395
|
}))
|
396
396
|
: null;
|
397
397
|
});
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
passengers: passengers
|
402
|
-
};
|
398
|
+
// Return the response
|
399
|
+
var res = __assign(__assign({}, response), { passengers: passengers });
|
400
|
+
return res;
|
403
401
|
})];
|
404
402
|
});
|
405
403
|
});
|
@@ -373,11 +373,8 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
373
373
|
// Check for errors
|
374
374
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response))
|
375
375
|
return response;
|
376
|
-
|
377
|
-
|
378
|
-
buyer: response.buyer,
|
379
|
-
passengers: []
|
380
|
-
};
|
376
|
+
// Return the response
|
377
|
+
return __assign(__assign({}, response), { passengers: [] });
|
381
378
|
})];
|
382
379
|
});
|
383
380
|
});
|
@@ -169,6 +169,7 @@ export declare namespace SubscriptionBooking {
|
|
169
169
|
CALENDAR_MONTH = "CALENDAR_MONTH",
|
170
170
|
CALENDAR_SIX_MONTHS = "CALENDAR_SIX_MONTHS",
|
171
171
|
ONE_YEAR = "ONE_YEAR",
|
172
|
-
CALENDAR_YEAR = "CALENDAR_YEAR"
|
172
|
+
CALENDAR_YEAR = "CALENDAR_YEAR",
|
173
|
+
FIVE_SECONDS = "FIVE_SECONDS"
|
173
174
|
}
|
174
175
|
}
|
@@ -421,11 +421,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
421
421
|
}))
|
422
422
|
: null;
|
423
423
|
});
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
passengers: passengers
|
428
|
-
};
|
424
|
+
// Return the response
|
425
|
+
var res = __assign(__assign({}, response), { passengers: passengers });
|
426
|
+
return res;
|
429
427
|
})];
|
430
428
|
});
|
431
429
|
});
|
@@ -782,5 +780,6 @@ exports.SubscriptionBooking = SubscriptionBooking;
|
|
782
780
|
ValidityTypes["CALENDAR_SIX_MONTHS"] = "CALENDAR_SIX_MONTHS";
|
783
781
|
ValidityTypes["ONE_YEAR"] = "ONE_YEAR";
|
784
782
|
ValidityTypes["CALENDAR_YEAR"] = "CALENDAR_YEAR";
|
783
|
+
ValidityTypes["FIVE_SECONDS"] = "FIVE_SECONDS";
|
785
784
|
})(ValidityTypes = SubscriptionBooking.ValidityTypes || (SubscriptionBooking.ValidityTypes = {}));
|
786
785
|
})(SubscriptionBooking || (exports.SubscriptionBooking = SubscriptionBooking = {}));
|
@@ -426,11 +426,8 @@ var TplBooking = /** @class */ (function (_super) {
|
|
426
426
|
// Check for errors
|
427
427
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response))
|
428
428
|
return response;
|
429
|
-
|
430
|
-
|
431
|
-
buyer: response.buyer,
|
432
|
-
passengers: null
|
433
|
-
};
|
429
|
+
// Return the response
|
430
|
+
return response;
|
434
431
|
})];
|
435
432
|
});
|
436
433
|
});
|
package/lib/config.d.ts
CHANGED
@@ -8,12 +8,12 @@ export type MTSConfig = {
|
|
8
8
|
ENV: MTSEnvs;
|
9
9
|
API_ENDPOINT: string;
|
10
10
|
OCP_SUBSCRIPTION_KEY: string;
|
11
|
-
ACCESS_TOKEN: string | undefined;
|
12
11
|
DEBUG: boolean;
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
ACCESS_TOKEN: string | undefined;
|
13
|
+
APP_VERSION: string | undefined;
|
14
|
+
OS: string | undefined;
|
15
|
+
DB_TYPE: string | undefined;
|
16
|
+
SESSION_ID: number | undefined;
|
17
17
|
};
|
18
18
|
export declare const setConfig: ({ ENV, OCP_SUBSCRIPTION_KEY, DEBUG, ACCESS_TOKEN, APP_VERSION, OS, DB_TYPE, SESSION_ID }: Omit<MTSConfig, "API_ENDPOINT">) => MTSConfig;
|
19
19
|
export declare const getConfig: () => MTSConfig;
|
package/lib/config.js
CHANGED
@@ -12,8 +12,12 @@ var config = {
|
|
12
12
|
ENV: MTSEnvs.PROD,
|
13
13
|
API_ENDPOINT: "https://prod-myticketsolutionapim.azure-api.net/api",
|
14
14
|
OCP_SUBSCRIPTION_KEY: "",
|
15
|
+
DEBUG: false,
|
15
16
|
ACCESS_TOKEN: undefined,
|
16
|
-
|
17
|
+
APP_VERSION: undefined,
|
18
|
+
OS: undefined,
|
19
|
+
DB_TYPE: undefined,
|
20
|
+
SESSION_ID: undefined
|
17
21
|
};
|
18
22
|
var setConfig = function (_a) {
|
19
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;
|
@@ -35,23 +35,30 @@ export type GetPersonRequest = {
|
|
35
35
|
personCode?: string;
|
36
36
|
phoneNumber?: string;
|
37
37
|
};
|
38
|
-
/**
|
39
|
-
* @description Represents a passenger in the response of the {@link Booking.getPassengersDetails} method. This type extends the {@link Person} type
|
40
|
-
* with the `outboundTariffs` and `returnTariffs` properties.
|
41
|
-
*
|
42
|
-
* @property {string} outboundNotes - The notes for the outbound trip.
|
43
|
-
* @property { Map<number, PassengerTariff>} outboundTariffs - A map containing the outbound tariffs for this passenger. The key is the trip id.
|
44
|
-
* For every trip, the first element the value is the suggested tariff. The other elements are the other tariffs, so that the user can adjust
|
45
|
-
* the tariff for the passenger.
|
46
|
-
* @property {string} returnNotes - The notes for the return trip.
|
47
|
-
* @property { Map<number, PassengerTariff>} returnTariffs - Same of `outboundTariffs`, but for the return trip.
|
48
|
-
*/
|
38
|
+
/** @description Represents a passenger in the response of the {@link Booking.getPassengersDetails} method. */
|
49
39
|
export type GetPassenger = Person & {
|
40
|
+
/** The notes for the outbound trip. */
|
50
41
|
outboundNotes: string | null;
|
42
|
+
/**
|
43
|
+
* A map containing the outbound tariffs for this passenger. The key is the trip id.
|
44
|
+
* For every trip, the first element the value is the suggested tariff. The other elements are the other tariffs, so that the user can adjust
|
45
|
+
* the tariff for the passenger.
|
46
|
+
* */
|
51
47
|
outboundTariffs: Map<number, PassengerTariff[]>;
|
48
|
+
/** The notes for the return trip. */
|
52
49
|
returnNotes: string | null;
|
50
|
+
/** Same of `outboundTariffs`, but for the return trip. */
|
53
51
|
returnTariffs: Map<number, PassengerTariff[]> | null;
|
52
|
+
/** Whether the passenger name and last name are required, optional or cannot be specified. */
|
53
|
+
passengerNameLastNameOption: PersonDataFieldStatus;
|
54
|
+
/** Whether the passenger email is required, optional or cannot be specified. */
|
55
|
+
passengerEmailOption: PersonDataFieldStatus;
|
56
|
+
/** Whether the passenger phone number is reuqired, optional or cannot be specified. */
|
57
|
+
passengerPhoneNumberOption: PersonDataFieldStatus;
|
58
|
+
/** Whether the passenger social security number is reuqired, optional or cannot be specified. */
|
59
|
+
passengerSSNOption: PersonDataFieldStatus;
|
54
60
|
};
|
61
|
+
/** @deprecated Use PersonDataFieldStatus */
|
55
62
|
export declare enum BuyerDataStatus {
|
56
63
|
/** The buyer data are optional. PersonDetails form shall be displayed, but the user can skip it. */
|
57
64
|
OPTIONAL = 0,
|
@@ -60,14 +67,28 @@ export declare enum BuyerDataStatus {
|
|
60
67
|
/** The buyer data cannot be specified. PersonDetails form shall not be displayed. */
|
61
68
|
CANNOT_BE_SPECIFIED = 2
|
62
69
|
}
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
export declare enum PersonDataFieldStatus {
|
71
|
+
/** The field (e.g. the buyer's email) is optional. The input shall be displayed, but the user can skip it. */
|
72
|
+
OPTIONAL = "OPTIONAL",
|
73
|
+
/** The field (e.g. the buyer's email) is required. the input shall be displayed and the user cannot skip it. */
|
74
|
+
REQUIRED = "REQUIRED",
|
75
|
+
/** The field (e.g. the buyer's email) cannot be specified. The input shall not be displayed. */
|
76
|
+
CANNOT_BE_SPECIFIED = "CANNOT_BE_SPECIFIED"
|
77
|
+
}
|
78
|
+
/** Represents the response of the {@link getBuyerPassengersDetails} method. */
|
66
79
|
export type GetBuyerPassengersDetailsResponse = {
|
67
|
-
/** Whether the form for the buyer data is required, optional or cannot be specified. */
|
80
|
+
/** @deprecated Whether the form for the buyer data is required, optional or cannot be specified. */
|
68
81
|
buyerDataStatus: BuyerDataStatus;
|
69
82
|
/** The {@link Person} object representing the buyer. */
|
70
83
|
buyer: PersonDetails | null;
|
84
|
+
/** Whether the buyer name and last name are required, optional or cannot be specified. */
|
85
|
+
buyerNameLastNameOption: PersonDataFieldStatus;
|
86
|
+
/** Whether the buyer email is required, optional or cannot be specified. */
|
87
|
+
buyerEmailOption: PersonDataFieldStatus;
|
88
|
+
/** Whether the buyer phone number is reuqired, optional or cannot be specified. */
|
89
|
+
buyerPhoneNumberOption: PersonDataFieldStatus;
|
90
|
+
/** Whether the buyer social security number is reuqired, optional or cannot be specified. */
|
91
|
+
buyerSSNOption: PersonDataFieldStatus;
|
71
92
|
/** An array of {@link GetPassenger} objects representing the passengers. */
|
72
93
|
passengers: GetPassenger[] | null;
|
73
94
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.BuyerDataStatus = exports.initializePerson = exports.DEFAULT_PERSON = void 0;
|
3
|
+
exports.PersonDataFieldStatus = exports.BuyerDataStatus = exports.initializePerson = exports.DEFAULT_PERSON = void 0;
|
4
4
|
exports.DEFAULT_PERSON = {
|
5
5
|
id: 0,
|
6
6
|
personCode: "",
|
@@ -16,6 +16,7 @@ var initializePerson = function (person) {
|
|
16
16
|
return person;
|
17
17
|
};
|
18
18
|
exports.initializePerson = initializePerson;
|
19
|
+
/** @deprecated Use PersonDataFieldStatus */
|
19
20
|
var BuyerDataStatus;
|
20
21
|
(function (BuyerDataStatus) {
|
21
22
|
/** The buyer data are optional. PersonDetails form shall be displayed, but the user can skip it. */
|
@@ -25,3 +26,12 @@ var BuyerDataStatus;
|
|
25
26
|
/** The buyer data cannot be specified. PersonDetails form shall not be displayed. */
|
26
27
|
BuyerDataStatus[BuyerDataStatus["CANNOT_BE_SPECIFIED"] = 2] = "CANNOT_BE_SPECIFIED";
|
27
28
|
})(BuyerDataStatus || (exports.BuyerDataStatus = BuyerDataStatus = {}));
|
29
|
+
var PersonDataFieldStatus;
|
30
|
+
(function (PersonDataFieldStatus) {
|
31
|
+
/** The field (e.g. the buyer's email) is optional. The input shall be displayed, but the user can skip it. */
|
32
|
+
PersonDataFieldStatus["OPTIONAL"] = "OPTIONAL";
|
33
|
+
/** The field (e.g. the buyer's email) is required. the input shall be displayed and the user cannot skip it. */
|
34
|
+
PersonDataFieldStatus["REQUIRED"] = "REQUIRED";
|
35
|
+
/** The field (e.g. the buyer's email) cannot be specified. The input shall not be displayed. */
|
36
|
+
PersonDataFieldStatus["CANNOT_BE_SPECIFIED"] = "CANNOT_BE_SPECIFIED";
|
37
|
+
})(PersonDataFieldStatus || (exports.PersonDataFieldStatus = PersonDataFieldStatus = {}));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.0",
|
4
4
|
"description": "Library for using MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
"node-localstorage": "^3.0.5",
|
23
23
|
"prettier": "^3.3.3",
|
24
24
|
"ts-jest": "^29.2.5",
|
25
|
-
"typescript": "^5.
|
25
|
+
"typescript": "^5.7.2"
|
26
26
|
},
|
27
27
|
"files": [
|
28
28
|
"lib/**/*"
|
@@ -33,7 +33,7 @@
|
|
33
33
|
],
|
34
34
|
"author": "Infoservice s.r.l.",
|
35
35
|
"dependencies": {
|
36
|
-
"@react-native-async-storage/async-storage": "^2.
|
36
|
+
"@react-native-async-storage/async-storage": "^2.1.0",
|
37
37
|
"axios": "^1.7.7",
|
38
38
|
"zustand": "^4.5.5"
|
39
39
|
}
|