mts-booking-library 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/config.d.ts +16 -0
- package/lib/config.js +18 -7
- package/lib/index.d.ts +90 -24
- package/lib/index.js +136 -17
- package/lib/types/Cart.d.ts +1 -1
- package/lib/types/Journey.d.ts +8 -0
- package/lib/types/Journey.js +2 -0
- package/lib/types/JourneySearch.d.ts +9 -0
- package/lib/types/JourneySearch.js +2 -0
- package/lib/types/Journeys/BusMatrix.d.ts +0 -0
- package/lib/types/Journeys/BusMatrix.js +1 -0
- package/lib/types/Journeys/Journey.d.ts +8 -0
- package/lib/types/Journeys/Journey.js +2 -0
- package/lib/types/Journeys/JourneySearch.d.ts +10 -0
- package/lib/types/Journeys/JourneySearch.js +12 -0
- package/lib/types/Journeys/Stop.d.ts +7 -0
- package/lib/types/Journeys/Stop.js +2 -0
- package/lib/types/Journeys/Trip.d.ts +9 -0
- package/lib/types/Journeys/Trip.js +2 -0
- package/lib/types/Subscriptions/Subscrptions.d.ts +12 -0
- package/lib/types/Subscriptions/Subscrptions.js +2 -0
- package/lib/types/Subscriptions/ValidityTypes.d.ts +6 -0
- package/lib/types/Subscriptions/ValidityTypes.js +10 -0
- package/lib/types/Tour.d.ts +1 -0
- package/lib/types/Tours/Tour.d.ts +18 -0
- package/lib/types/Tours/Tour.js +2 -0
- package/lib/types/Trip.d.ts +6 -12
- package/package.json +7 -7
package/lib/config.d.ts
CHANGED
@@ -1,4 +1,20 @@
|
|
1
|
+
export declare const setConfig: (env: "dev" | "stag" | "prod", sub_key: string) => {
|
2
|
+
API_ENDPOINT: string;
|
3
|
+
OCP_SUBSCRIPTION_KEY: string;
|
4
|
+
} | {
|
5
|
+
API_ENDPOINT: string;
|
6
|
+
OCP_SUBSCRIPTION_KEY: string;
|
7
|
+
} | {
|
8
|
+
API_ENDPOINT: string;
|
9
|
+
OCP_SUBSCRIPTION_KEY: string;
|
10
|
+
};
|
1
11
|
export declare const getConfig: () => {
|
2
12
|
API_ENDPOINT: string;
|
3
13
|
OCP_SUBSCRIPTION_KEY: string;
|
14
|
+
} | {
|
15
|
+
API_ENDPOINT: string;
|
16
|
+
OCP_SUBSCRIPTION_KEY: string;
|
17
|
+
} | {
|
18
|
+
API_ENDPOINT: string;
|
19
|
+
OCP_SUBSCRIPTION_KEY: string;
|
4
20
|
};
|
package/lib/config.js
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getConfig = void 0;
|
4
|
-
var MODE = "test";
|
3
|
+
exports.getConfig = exports.setConfig = void 0;
|
5
4
|
var config = {
|
5
|
+
dev: {
|
6
|
+
API_ENDPOINT: "https://myticketsolutionapim.azure-api.net/api/dev",
|
7
|
+
OCP_SUBSCRIPTION_KEY: ""
|
8
|
+
},
|
9
|
+
stag: {
|
10
|
+
API_ENDPOINT: "https://myticketsolutionapim.azure-api.net/api/stag",
|
11
|
+
OCP_SUBSCRIPTION_KEY: ""
|
12
|
+
},
|
6
13
|
prod: {
|
7
14
|
API_ENDPOINT: "https://myticketsolutionapim.azure-api.net/api/",
|
8
|
-
|
9
|
-
test: {
|
10
|
-
API_ENDPOINT: "https://myticketsolutionapim.azure-api.net/api/dev",
|
11
|
-
OCP_SUBSCRIPTION_KEY: "6bfc2f70b9d643a1892ffd930a32ae3b"
|
15
|
+
OCP_SUBSCRIPTION_KEY: ""
|
12
16
|
}
|
13
17
|
};
|
18
|
+
var global_env = "dev";
|
19
|
+
var setConfig = function (env, sub_key) {
|
20
|
+
global_env = env;
|
21
|
+
config[global_env].OCP_SUBSCRIPTION_KEY = sub_key;
|
22
|
+
return config[global_env];
|
23
|
+
};
|
24
|
+
exports.setConfig = setConfig;
|
14
25
|
var getConfig = function () {
|
15
|
-
return config[
|
26
|
+
return config[global_env];
|
16
27
|
};
|
17
28
|
exports.getConfig = getConfig;
|
package/lib/index.d.ts
CHANGED
@@ -1,37 +1,74 @@
|
|
1
|
-
import { Cart, TourCart,
|
1
|
+
import { Cart, TourCart, JourneyCart } from "./types/Cart";
|
2
2
|
import { Details } from "./types/Details";
|
3
|
-
import { Tour } from "./types/Tour";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
|
7
|
-
|
8
|
-
onCartExpiration: () => void;
|
9
|
-
};
|
10
|
-
type StopNames = string[];
|
3
|
+
import { Tour, TourTrip } from "./types/Tours/Tour";
|
4
|
+
import { JourneySearch } from "./types/Journeys/JourneySearch";
|
5
|
+
import { Subscription } from "./types/Subscriptions/Subscrptions";
|
6
|
+
import { ValidityTypes } from "./types/Subscriptions/ValidityTypes";
|
7
|
+
import { Journey } from "./types/Journeys/Journey";
|
11
8
|
export declare class Booking {
|
12
9
|
readonly sellerId?: number | undefined;
|
13
10
|
private readonly config;
|
14
11
|
private cart?;
|
15
12
|
private cartStatus;
|
16
13
|
private onCartExpiration;
|
17
|
-
|
14
|
+
/**
|
15
|
+
* This is the constructor of the Booking class.
|
16
|
+
* @param {string} env The environment in which the app is running. Can be "dev", "stag" or "prod"
|
17
|
+
* @param {string} sub_key The subscription key for using the APIs
|
18
|
+
* @param {() => void} onCartExpiration A callback function that will be called when the cart expires
|
19
|
+
* @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
|
20
|
+
*/
|
21
|
+
constructor(env: "dev" | "stag" | "prod", sub_key: string, onCartExpiration: () => void, sellerId?: number);
|
18
22
|
getCartStatus(): Booking.CartStatus;
|
19
23
|
getCart(): Cart | undefined;
|
20
24
|
private fetchAndSetCart;
|
21
25
|
private createCartTimer;
|
22
26
|
getCartExpirationTimeInMs(): Promise<number>;
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
/**
|
28
|
+
* This method returns the list of cities in which the seller offers tours.
|
29
|
+
* If the sellerId is not set or it is 0, it will return the list of cities for all sellers.
|
30
|
+
* @returns {string[]} The list of possible cities
|
31
|
+
*/
|
32
|
+
getTourCities(): Promise<string[]>;
|
33
|
+
/**
|
34
|
+
* This method returns the tours sold by this seller in the given city.
|
35
|
+
* If the sellerId is not set or it is 0, it will return the tours in the given city for all sellers.
|
36
|
+
* @param {string} [cityName=undefined] The name of the selected city (as returned by {@link getTourCities})
|
37
|
+
* @param {Booking.Currencies} currency The currency in which the prices should be returned
|
38
|
+
* @returns {Tour[]} The returned tours
|
39
|
+
*/
|
40
|
+
getTours(currency: Booking.Currencies, cityName?: string): Promise<Tour[]>;
|
41
|
+
/**
|
42
|
+
* This method returns the tours available for the given date. This method can be used if the seller wants the user to book a specific date
|
43
|
+
* and/or a specific hour for the tour.
|
44
|
+
* You should call this method only if {@link Tour.isDateOptional} or {@link Tour.isDateRequired} is true for the selected tour.
|
45
|
+
* @param {number} tourId The id of the selected tour (can be retrieved in the object {@link Tour} returned by {@link getTours})
|
46
|
+
* @param {Date} date The date on which to get the tours
|
47
|
+
* @returns {TourTrip[]} The returned information about the tour (tripId and hour)
|
48
|
+
*/
|
49
|
+
getToursTrips(tourId: number, date: Date): Promise<TourTrip[]>;
|
29
50
|
createTourCart(tourCart: TourCart): Promise<Cart>;
|
30
51
|
fetchCart(cartId: number): Promise<Cart>;
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
52
|
+
/**
|
53
|
+
* This method returns the possible departures for all journeys (MLP) sold by this seller.
|
54
|
+
* @returns {string[]} The list of possible departures
|
55
|
+
*/
|
56
|
+
getJourneysDepartures(): Promise<string[]>;
|
57
|
+
/**
|
58
|
+
* This method returns the possible destination for the journeys sold by this seller that start at the selected departure.
|
59
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
|
60
|
+
* @returns {string[]} The list of possible destinations
|
61
|
+
*/
|
62
|
+
getJourneysDestinations(departureStopName: string): Promise<string[]>;
|
63
|
+
/**
|
64
|
+
* This method returns the journeys that match the given parameters.
|
65
|
+
* Note that it will always return the journeys for the one-way trip.
|
66
|
+
* If you want to get the journeys for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
|
67
|
+
* @param {JourneySearch} params an object of type {@link JourneySearch} containing the parameters of the search
|
68
|
+
* @returns {Journey[]} The returned journeys that match the given parameters
|
69
|
+
*/
|
70
|
+
getJourneys(params: JourneySearch): Promise<Journey[]>;
|
71
|
+
createJourneyCart(tripCart: JourneyCart): Promise<Cart>;
|
35
72
|
getBusMatrix(params: {
|
36
73
|
tripId: number;
|
37
74
|
departureStopId: number;
|
@@ -42,10 +79,40 @@ export declare class Booking {
|
|
42
79
|
departureStopId: number;
|
43
80
|
destinationStopId: number;
|
44
81
|
}): Promise<any>;
|
45
|
-
|
82
|
+
movePassengers(params: {
|
46
83
|
tripId: number;
|
47
84
|
seatsIds: number[];
|
48
85
|
}): Promise<any>;
|
86
|
+
/**
|
87
|
+
* This method returns the possible departures for all subscriptions sold by this seller.
|
88
|
+
* @returns {string[]} The list of possible departures
|
89
|
+
*/
|
90
|
+
getSubscriptionsDepartures(): Promise<string[]>;
|
91
|
+
/**
|
92
|
+
* This method returns the possible destination for the subscriptions sold by this seller that start at the selected departure.
|
93
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
|
94
|
+
* @returns {string[]} The list of possible destinations
|
95
|
+
*/
|
96
|
+
getSubscrptionsDestinations(departureStopName: string): Promise<string[]>;
|
97
|
+
/**
|
98
|
+
* This method returns the possible validity types for the subscriptions sold by this seller between the selected departure and destination.
|
99
|
+
* The validity type is the duration of the subscription (1 week, 1 month, etc.). See {@link ValidityTypes} for more details.
|
100
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
|
101
|
+
* @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
|
102
|
+
* @returns {ValidityTypes[]} The list of possible validity types
|
103
|
+
*/
|
104
|
+
getSubscrptionsValidityTypes(departureStopName: string, destinationStopName: string): Promise<ValidityTypes[]>;
|
105
|
+
/**
|
106
|
+
* This method returns the subscriptions that match the given parameters.
|
107
|
+
* Note that it will always return the subscription for the one-way trip.
|
108
|
+
* If you want to get the subscription for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
|
109
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
|
110
|
+
* @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
|
111
|
+
* @param {string} validityType The validity type (as returned by {@link getSubscriptionsValidityTypes})
|
112
|
+
* @returns {Array<Subscription>} The subscriptions that match the given parameters
|
113
|
+
*/
|
114
|
+
getSubscrptions(departureStopName: string, destinationStopName: string, validityType: string): Promise<Subscription[]>;
|
115
|
+
getSubscrptionAvailabilities(departureStopName: string, destinationStopName: string, validityType: string): Promise<Subscription[]>;
|
49
116
|
getPassengersDetails(): Promise<any>;
|
50
117
|
updatePassengersDetails(passengersDetails: Details): Promise<any>;
|
51
118
|
}
|
@@ -58,10 +125,9 @@ export declare namespace Booking {
|
|
58
125
|
enum CartStatus {
|
59
126
|
EMPTY = "EMPTY",
|
60
127
|
CREATION = "CREATION",
|
61
|
-
SEAT = "SEATS",
|
62
|
-
EXTRAS = "EXTRAS",
|
63
128
|
PASSENGERS = "PASSENGERS",
|
129
|
+
SEATS = "SEATS",
|
130
|
+
EXTRAS = "EXTRAS",
|
64
131
|
PAYMENT = "PAYMENT"
|
65
132
|
}
|
66
133
|
}
|
67
|
-
export {};
|
package/lib/index.js
CHANGED
@@ -55,11 +55,18 @@ if (typeof localStorage === "undefined" || localStorage === null) {
|
|
55
55
|
global.localStorage = new LocalStorage("./scratch");
|
56
56
|
}
|
57
57
|
var Booking = /** @class */ (function () {
|
58
|
-
|
58
|
+
/**
|
59
|
+
* This is the constructor of the Booking class.
|
60
|
+
* @param {string} env The environment in which the app is running. Can be "dev", "stag" or "prod"
|
61
|
+
* @param {string} sub_key The subscription key for using the APIs
|
62
|
+
* @param {() => void} onCartExpiration A callback function that will be called when the cart expires
|
63
|
+
* @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
|
64
|
+
*/
|
65
|
+
function Booking(env, sub_key, onCartExpiration, sellerId) {
|
59
66
|
this.cartStatus = Booking.CartStatus.EMPTY;
|
60
|
-
this.sellerId =
|
61
|
-
this.config = (0, config_1.
|
62
|
-
this.onCartExpiration =
|
67
|
+
this.sellerId = sellerId || undefined;
|
68
|
+
this.config = (0, config_1.setConfig)(env, sub_key);
|
69
|
+
this.onCartExpiration = onCartExpiration;
|
63
70
|
var cartId = localStorage.getItem("cartId");
|
64
71
|
if (cartId) {
|
65
72
|
this.fetchAndSetCart(parseInt(cartId));
|
@@ -115,7 +122,12 @@ var Booking = /** @class */ (function () {
|
|
115
122
|
});
|
116
123
|
});
|
117
124
|
};
|
118
|
-
// Tours config
|
125
|
+
// #region Tours config
|
126
|
+
/**
|
127
|
+
* This method returns the list of cities in which the seller offers tours.
|
128
|
+
* If the sellerId is not set or it is 0, it will return the list of cities for all sellers.
|
129
|
+
* @returns {string[]} The list of possible cities
|
130
|
+
*/
|
119
131
|
Booking.prototype.getTourCities = function () {
|
120
132
|
return __awaiter(this, void 0, void 0, function () {
|
121
133
|
var url;
|
@@ -125,15 +137,30 @@ var Booking = /** @class */ (function () {
|
|
125
137
|
});
|
126
138
|
});
|
127
139
|
};
|
128
|
-
|
140
|
+
/**
|
141
|
+
* This method returns the tours sold by this seller in the given city.
|
142
|
+
* If the sellerId is not set or it is 0, it will return the tours in the given city for all sellers.
|
143
|
+
* @param {string} [cityName=undefined] The name of the selected city (as returned by {@link getTourCities})
|
144
|
+
* @param {Booking.Currencies} currency The currency in which the prices should be returned
|
145
|
+
* @returns {Tour[]} The returned tours
|
146
|
+
*/
|
147
|
+
Booking.prototype.getTours = function (currency, cityName) {
|
129
148
|
return __awaiter(this, void 0, void 0, function () {
|
130
149
|
var url;
|
131
150
|
return __generator(this, function (_a) {
|
132
|
-
url = "".concat(this.config.API_ENDPOINT, "/booking/tours?").concat(new URLSearchParams(__assign(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), (
|
151
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/tours?").concat(new URLSearchParams(__assign(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), (cityName && { cityName: cityName })), { currency: currency })));
|
133
152
|
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
134
153
|
});
|
135
154
|
});
|
136
155
|
};
|
156
|
+
/**
|
157
|
+
* This method returns the tours available for the given date. This method can be used if the seller wants the user to book a specific date
|
158
|
+
* and/or a specific hour for the tour.
|
159
|
+
* You should call this method only if {@link Tour.isDateOptional} or {@link Tour.isDateRequired} is true for the selected tour.
|
160
|
+
* @param {number} tourId The id of the selected tour (can be retrieved in the object {@link Tour} returned by {@link getTours})
|
161
|
+
* @param {Date} date The date on which to get the tours
|
162
|
+
* @returns {TourTrip[]} The returned information about the tour (tripId and hour)
|
163
|
+
*/
|
137
164
|
Booking.prototype.getToursTrips = function (tourId, date) {
|
138
165
|
return __awaiter(this, void 0, void 0, function () {
|
139
166
|
var url;
|
@@ -158,6 +185,7 @@ var Booking = /** @class */ (function () {
|
|
158
185
|
});
|
159
186
|
});
|
160
187
|
};
|
188
|
+
//#endregion
|
161
189
|
Booking.prototype.fetchCart = function (cartId) {
|
162
190
|
return __awaiter(this, void 0, void 0, function () {
|
163
191
|
var url;
|
@@ -167,8 +195,12 @@ var Booking = /** @class */ (function () {
|
|
167
195
|
});
|
168
196
|
});
|
169
197
|
};
|
170
|
-
|
171
|
-
|
198
|
+
//#region Journeys config
|
199
|
+
/**
|
200
|
+
* This method returns the possible departures for all journeys (MLP) sold by this seller.
|
201
|
+
* @returns {string[]} The list of possible departures
|
202
|
+
*/
|
203
|
+
Booking.prototype.getJourneysDepartures = function () {
|
172
204
|
return __awaiter(this, void 0, void 0, function () {
|
173
205
|
var url;
|
174
206
|
return __generator(this, function (_a) {
|
@@ -177,7 +209,12 @@ var Booking = /** @class */ (function () {
|
|
177
209
|
});
|
178
210
|
});
|
179
211
|
};
|
180
|
-
|
212
|
+
/**
|
213
|
+
* This method returns the possible destination for the journeys sold by this seller that start at the selected departure.
|
214
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
|
215
|
+
* @returns {string[]} The list of possible destinations
|
216
|
+
*/
|
217
|
+
Booking.prototype.getJourneysDestinations = function (departureStopName) {
|
181
218
|
return __awaiter(this, void 0, void 0, function () {
|
182
219
|
var url;
|
183
220
|
return __generator(this, function (_a) {
|
@@ -186,16 +223,26 @@ var Booking = /** @class */ (function () {
|
|
186
223
|
});
|
187
224
|
});
|
188
225
|
};
|
189
|
-
|
226
|
+
/**
|
227
|
+
* This method returns the journeys that match the given parameters.
|
228
|
+
* Note that it will always return the journeys for the one-way trip.
|
229
|
+
* If you want to get the journeys for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
|
230
|
+
* @param {JourneySearch} params an object of type {@link JourneySearch} containing the parameters of the search
|
231
|
+
* @returns {Journey[]} The returned journeys that match the given parameters
|
232
|
+
*/
|
233
|
+
Booking.prototype.getJourneys = function (params) {
|
190
234
|
return __awaiter(this, void 0, void 0, function () {
|
191
235
|
var url;
|
192
236
|
return __generator(this, function (_a) {
|
237
|
+
if (params.departureStopName === undefined || params.destinationStopName === undefined) {
|
238
|
+
throw Error("Fields departureStopName and destinationStopName are required");
|
239
|
+
}
|
193
240
|
url = "".concat(this.config.API_ENDPOINT, "/booking/journeys?").concat(new URLSearchParams(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), { departureStopName: params.departureStopName, destinationStopName: params.destinationStopName, passengersNumber: params.passengersNumber.toString(), date: params.date.toDateString(), currency: params.currency, isRoundtrip: params.isRoundtrip.toString() })));
|
194
241
|
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
195
242
|
});
|
196
243
|
});
|
197
244
|
};
|
198
|
-
Booking.prototype.
|
245
|
+
Booking.prototype.createJourneyCart = function (tripCart) {
|
199
246
|
return __awaiter(this, void 0, void 0, function () {
|
200
247
|
var url;
|
201
248
|
var _this = this;
|
@@ -231,7 +278,7 @@ var Booking = /** @class */ (function () {
|
|
231
278
|
});
|
232
279
|
});
|
233
280
|
};
|
234
|
-
Booking.prototype.
|
281
|
+
Booking.prototype.movePassengers = function (params) {
|
235
282
|
return __awaiter(this, void 0, void 0, function () {
|
236
283
|
var url;
|
237
284
|
return __generator(this, function (_a) {
|
@@ -243,6 +290,79 @@ var Booking = /** @class */ (function () {
|
|
243
290
|
});
|
244
291
|
});
|
245
292
|
};
|
293
|
+
//#endregion
|
294
|
+
//#region Subscriptions config
|
295
|
+
/**
|
296
|
+
* This method returns the possible departures for all subscriptions sold by this seller.
|
297
|
+
* @returns {string[]} The list of possible departures
|
298
|
+
*/
|
299
|
+
Booking.prototype.getSubscriptionsDepartures = function () {
|
300
|
+
return __awaiter(this, void 0, void 0, function () {
|
301
|
+
var url;
|
302
|
+
return __generator(this, function (_a) {
|
303
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/departures?").concat(new URLSearchParams(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() }))));
|
304
|
+
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
305
|
+
});
|
306
|
+
});
|
307
|
+
};
|
308
|
+
/**
|
309
|
+
* This method returns the possible destination for the subscriptions sold by this seller that start at the selected departure.
|
310
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
|
311
|
+
* @returns {string[]} The list of possible destinations
|
312
|
+
*/
|
313
|
+
Booking.prototype.getSubscrptionsDestinations = function (departureStopName) {
|
314
|
+
return __awaiter(this, void 0, void 0, function () {
|
315
|
+
var url;
|
316
|
+
return __generator(this, function (_a) {
|
317
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/destinations?").concat(new URLSearchParams(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), { departureStopName: departureStopName })));
|
318
|
+
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
319
|
+
});
|
320
|
+
});
|
321
|
+
};
|
322
|
+
/**
|
323
|
+
* This method returns the possible validity types for the subscriptions sold by this seller between the selected departure and destination.
|
324
|
+
* The validity type is the duration of the subscription (1 week, 1 month, etc.). See {@link ValidityTypes} for more details.
|
325
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
|
326
|
+
* @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
|
327
|
+
* @returns {ValidityTypes[]} The list of possible validity types
|
328
|
+
*/
|
329
|
+
Booking.prototype.getSubscrptionsValidityTypes = function (departureStopName, destinationStopName) {
|
330
|
+
return __awaiter(this, void 0, void 0, function () {
|
331
|
+
var url;
|
332
|
+
return __generator(this, function (_a) {
|
333
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/validityTypes?").concat(new URLSearchParams(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), { departureStopName: departureStopName, destinationStopName: destinationStopName })));
|
334
|
+
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
335
|
+
});
|
336
|
+
});
|
337
|
+
};
|
338
|
+
/**
|
339
|
+
* This method returns the subscriptions that match the given parameters.
|
340
|
+
* Note that it will always return the subscription for the one-way trip.
|
341
|
+
* If you want to get the subscription for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
|
342
|
+
* @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
|
343
|
+
* @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
|
344
|
+
* @param {string} validityType The validity type (as returned by {@link getSubscriptionsValidityTypes})
|
345
|
+
* @returns {Array<Subscription>} The subscriptions that match the given parameters
|
346
|
+
*/
|
347
|
+
Booking.prototype.getSubscrptions = function (departureStopName, destinationStopName, validityType) {
|
348
|
+
return __awaiter(this, void 0, void 0, function () {
|
349
|
+
var url;
|
350
|
+
return __generator(this, function (_a) {
|
351
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/search?").concat(new URLSearchParams(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), { departureStopName: departureStopName, destinationStopName: destinationStopName, validityType: validityType })));
|
352
|
+
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
353
|
+
});
|
354
|
+
});
|
355
|
+
};
|
356
|
+
Booking.prototype.getSubscrptionAvailabilities = function (departureStopName, destinationStopName, validityType) {
|
357
|
+
return __awaiter(this, void 0, void 0, function () {
|
358
|
+
var url;
|
359
|
+
return __generator(this, function (_a) {
|
360
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/search?").concat(new URLSearchParams(__assign(__assign({}, (this.sellerId && { sellerId: this.sellerId.toString() })), { departureStopName: departureStopName, destinationStopName: destinationStopName, validityType: validityType })));
|
361
|
+
return [2 /*return*/, (0, apiCall_1.makeGet)(url)];
|
362
|
+
});
|
363
|
+
});
|
364
|
+
};
|
365
|
+
//#endregion
|
246
366
|
Booking.prototype.getPassengersDetails = function () {
|
247
367
|
return __awaiter(this, void 0, void 0, function () {
|
248
368
|
var url;
|
@@ -281,10 +401,9 @@ exports.Booking = Booking;
|
|
281
401
|
(function (CartStatus) {
|
282
402
|
CartStatus["EMPTY"] = "EMPTY";
|
283
403
|
CartStatus["CREATION"] = "CREATION";
|
284
|
-
CartStatus["SEAT"] = "SEATS";
|
285
|
-
CartStatus["EXTRAS"] = "EXTRAS";
|
286
404
|
CartStatus["PASSENGERS"] = "PASSENGERS";
|
405
|
+
CartStatus["SEATS"] = "SEATS";
|
406
|
+
CartStatus["EXTRAS"] = "EXTRAS";
|
287
407
|
CartStatus["PAYMENT"] = "PAYMENT";
|
288
408
|
})(CartStatus = Booking.CartStatus || (Booking.CartStatus = {}));
|
289
|
-
})(Booking
|
290
|
-
exports.Booking = Booking;
|
409
|
+
})(Booking || (exports.Booking = Booking = {}));
|
package/lib/types/Cart.d.ts
CHANGED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { Booking } from "../..";
|
2
|
+
export type JourneySearch = {
|
3
|
+
departureStopName: string | undefined;
|
4
|
+
destinationStopName: string | undefined;
|
5
|
+
passengersNumber: number;
|
6
|
+
date: Date;
|
7
|
+
currency: Booking.Currencies;
|
8
|
+
isRoundtrip: boolean;
|
9
|
+
};
|
10
|
+
export declare const DefaultJourneySearch: JourneySearch;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.DefaultJourneySearch = void 0;
|
4
|
+
var __1 = require("../..");
|
5
|
+
exports.DefaultJourneySearch = {
|
6
|
+
departureStopName: "",
|
7
|
+
destinationStopName: "",
|
8
|
+
passengersNumber: 1,
|
9
|
+
date: new Date(Date.UTC(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 1)),
|
10
|
+
currency: __1.Booking.Currencies.EUR,
|
11
|
+
isRoundtrip: false,
|
12
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export type Subscription = {
|
2
|
+
departurePhysicalAgencyStopId: number;
|
3
|
+
departureStopName: string;
|
4
|
+
destinationPhysicalAgencyStopId: number;
|
5
|
+
destinationStopName: string;
|
6
|
+
departureTime: string;
|
7
|
+
destinationTime: string;
|
8
|
+
lineName: string;
|
9
|
+
routeId: number;
|
10
|
+
routeName: string;
|
11
|
+
sellerId: number;
|
12
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ValidityTypes = void 0;
|
4
|
+
var ValidityTypes;
|
5
|
+
(function (ValidityTypes) {
|
6
|
+
ValidityTypes["WORKING_WEEK"] = "WORKING_WEEK";
|
7
|
+
ValidityTypes["WEEKLY"] = "WEEKLY";
|
8
|
+
ValidityTypes["MONTHLY"] = "MONTHLY";
|
9
|
+
ValidityTypes["YEARLY"] = "YEARLY";
|
10
|
+
})(ValidityTypes || (exports.ValidityTypes = ValidityTypes = {}));
|
package/lib/types/Tour.d.ts
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Info } from "../Info";
|
2
|
+
import { Line } from "../Line";
|
3
|
+
import { TariffMatrix, TariffType, TermsType } from "../TermsAndTariffs";
|
4
|
+
export type Tour = {
|
5
|
+
id: number;
|
6
|
+
line: Line;
|
7
|
+
info: Info;
|
8
|
+
tariffsMatrix: TariffMatrix;
|
9
|
+
tariffTypes: TariffType[];
|
10
|
+
termsTypes: TermsType[];
|
11
|
+
isDateOptional: boolean;
|
12
|
+
isDateRequired: boolean;
|
13
|
+
isTripMandatory: boolean;
|
14
|
+
};
|
15
|
+
export type TourTrip = {
|
16
|
+
tripId: number;
|
17
|
+
hour: Date;
|
18
|
+
};
|
package/lib/types/Trip.d.ts
CHANGED
@@ -1,15 +1,9 @@
|
|
1
|
-
import { Info } from "./Info";
|
2
|
-
import { Stop } from "./Stop";
|
3
1
|
import { TariffMatrix, TariffType, TermsType } from "./TermsAndTariffs";
|
4
2
|
export type Trip = {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
tariffsMatrix: TariffMatrix;
|
12
|
-
tariffTypes: TariffType[];
|
13
|
-
termsTypes: TermsType[];
|
14
|
-
}[];
|
3
|
+
id: number;
|
4
|
+
departureStopName: string;
|
5
|
+
destinationStopName: string;
|
6
|
+
tariffsMatrix: TariffMatrix;
|
7
|
+
tariffTypes: TariffType[];
|
8
|
+
termsTypes: TermsType[];
|
15
9
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"description": "Library for use MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -14,10 +14,10 @@
|
|
14
14
|
},
|
15
15
|
"license": "ISC",
|
16
16
|
"devDependencies": {
|
17
|
-
"@types/jest": "^29.5.
|
18
|
-
"jest": "^29.
|
19
|
-
"ts-jest": "^29.1.
|
20
|
-
"typescript": "^5.
|
17
|
+
"@types/jest": "^29.5.4",
|
18
|
+
"jest": "^29.7.0",
|
19
|
+
"ts-jest": "^29.1.1",
|
20
|
+
"typescript": "^5.2.2"
|
21
21
|
},
|
22
22
|
"files": [
|
23
23
|
"lib/**/*"
|
@@ -28,7 +28,7 @@
|
|
28
28
|
],
|
29
29
|
"author": "M",
|
30
30
|
"dependencies": {
|
31
|
-
"axios": "^1.
|
32
|
-
"node-localstorage": "^
|
31
|
+
"axios": "^1.5.0",
|
32
|
+
"node-localstorage": "^3.0.5"
|
33
33
|
}
|
34
34
|
}
|