@vulog/aima-booking 1.1.88 → 1.1.91

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/README.md CHANGED
@@ -1,26 +1,308 @@
1
1
  # @vulog/aima-booking
2
2
 
3
+ Booking management module for the AIMA platform. This module provides functionality to manage booking requests, stations, and subscription bookings.
4
+
5
+ ## Installation
6
+
3
7
  ```bash
4
- npm i @vulog/aima-client @vulog/aima-core @vulog/aima-booking
8
+ npm install @vulog/aima-client @vulog/aima-core @vulog/aima-booking
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Initialize Client
14
+
15
+ ```javascript
16
+ import { getClient } from '@vulog/aima-client';
17
+ import {
18
+ getBookingRequests,
19
+ getScheduleBookingRequests,
20
+ getSubscriptionBookingRequests,
21
+ getSATBookingRequests,
22
+ getBookingRequestById,
23
+ getBookingRequestByTrip,
24
+ getSubscriptionBookingRequestById,
25
+ getStations,
26
+ getStationById
27
+ } from '@vulog/aima-booking';
28
+
29
+ const client = getClient({
30
+ apiKey: 'your-api-key',
31
+ baseUrl: 'https://your-api-base-url',
32
+ clientId: 'your-client-id',
33
+ clientSecret: 'your-client-secret',
34
+ fleetId: 'your-fleet-id',
35
+ });
36
+ ```
37
+
38
+ ## API Reference
39
+
40
+ ### Booking Requests
41
+
42
+ #### getBookingRequests
43
+
44
+ Retrieve booking requests with optional filtering.
45
+
46
+ ```javascript
47
+ const bookingRequests = await getBookingRequests(client, 'ONGOING', {
48
+ limit: 50,
49
+ offset: 0,
50
+ userId: 'user-uuid-here'
51
+ });
52
+ ```
53
+
54
+ **Parameters:**
55
+ - `client`: AIMA client instance
56
+ - `status`: Booking request status ('ONGOING', 'COMPLETED', 'CANCELLED', 'EXPIRED')
57
+ - `filters`: Optional filter object
58
+ - `limit`: Maximum number of results
59
+ - `offset`: Number of results to skip
60
+ - `userId`: Filter by user ID
61
+ - `vehicleId`: Filter by vehicle ID
62
+ - `stationId`: Filter by station ID
63
+
64
+ #### getScheduleBookingRequests
65
+
66
+ Get scheduled booking requests.
67
+
68
+ ```javascript
69
+ const scheduledRequests = await getScheduleBookingRequests(client, {
70
+ startDate: '2024-01-01T00:00:00Z',
71
+ endDate: '2024-01-31T23:59:59Z'
72
+ });
73
+ ```
74
+
75
+ #### getSubscriptionBookingRequests
76
+
77
+ Get subscription-based booking requests.
78
+
79
+ ```javascript
80
+ const subscriptionRequests = await getSubscriptionBookingRequests(client, {
81
+ status: 'ACTIVE',
82
+ userId: 'user-uuid-here'
83
+ });
84
+ ```
85
+
86
+ #### getSATBookingRequests
87
+
88
+ Get SAT (Scheduled Access Time) booking requests.
89
+
90
+ ```javascript
91
+ const satRequests = await getSATBookingRequests(client, 'PENDING');
92
+ ```
93
+
94
+ ### Individual Booking Requests
95
+
96
+ #### getBookingRequestById
97
+
98
+ Retrieve a specific booking request by ID.
99
+
100
+ ```javascript
101
+ const bookingRequest = await getBookingRequestById(client, 'bb493049-5b4f-43ea-8a65-964a13aec549');
102
+ ```
103
+
104
+ #### getBookingRequestByTrip
105
+
106
+ Get booking request associated with a trip.
107
+
108
+ ```javascript
109
+ const bookingRequest = await getBookingRequestByTrip(client, '33E8E42710144E15A5CC447E4D3524F4');
110
+ ```
111
+
112
+ #### getSubscriptionBookingRequestById
113
+
114
+ Get subscription booking request by ID.
115
+
116
+ ```javascript
117
+ const subscriptionRequest = await getSubscriptionBookingRequestById(client, 'b7faa2a2-e8fc-4a29-8de7-09ce783b9797');
118
+ ```
119
+
120
+ ### Stations
121
+
122
+ #### getStations
123
+
124
+ Retrieve stations with optional includes.
125
+
126
+ ```javascript
127
+ const stations = await getStations(client, ['OPEN_HOUR', 'INFO']);
128
+ ```
129
+
130
+ **Parameters:**
131
+ - `client`: AIMA client instance
132
+ - `includes`: Array of data to include ('OPEN_HOUR', 'INFO', 'VEHICLES', 'ZONES')
133
+
134
+ #### getStationById
135
+
136
+ Get a specific station by ID.
137
+
138
+ ```javascript
139
+ const station = await getStationById(client, 'station-id-here', ['OPEN_HOUR', 'INFO']);
140
+ ```
141
+
142
+ ## Types
143
+
144
+ ### BookingRequest
145
+
146
+ ```typescript
147
+ interface BookingRequest {
148
+ id: string;
149
+ userId: string;
150
+ vehicleId: string;
151
+ stationId: string;
152
+ status: 'PENDING' | 'ONGOING' | 'COMPLETED' | 'CANCELLED' | 'EXPIRED';
153
+ startTime: string;
154
+ endTime: string;
155
+ createdAt: string;
156
+ updatedAt: string;
157
+ }
158
+ ```
159
+
160
+ ### Station
161
+
162
+ ```typescript
163
+ interface Station {
164
+ id: string;
165
+ name: string;
166
+ address: string;
167
+ coordinates: {
168
+ latitude: number;
169
+ longitude: number;
170
+ };
171
+ isActive: boolean;
172
+ openHours: OpenHours[];
173
+ info: StationInfo;
174
+ vehicles: Vehicle[];
175
+ zones: Zone[];
176
+ }
177
+ ```
178
+
179
+ ### BookingRequestStatus
180
+
181
+ ```typescript
182
+ type BookingRequestStatus = 'PENDING' | 'ONGOING' | 'COMPLETED' | 'CANCELLED' | 'EXPIRED';
183
+ ```
184
+
185
+ ### ServiceType
186
+
187
+ ```typescript
188
+ type ServiceType = 'CAR_SHARING' | 'BIKE_SHARING' | 'SCOOTER_SHARING' | 'MULTIMODAL';
5
189
  ```
6
190
 
191
+ ## Error Handling
192
+
193
+ All functions include validation and will throw appropriate errors if:
194
+ - Required parameters are missing
195
+ - Invalid booking request or station IDs are provided
196
+ - Invalid status values are used
197
+ - Network errors occur
198
+
199
+ ## Examples
200
+
201
+ ### Complete Booking Management Workflow
202
+
7
203
  ```javascript
8
204
  import { getClient } from '@vulog/aima-client';
9
- import { getBookingRequests } from '@vulog/aima-booking';
205
+ import {
206
+ getBookingRequests,
207
+ getStations,
208
+ getBookingRequestById
209
+ } from '@vulog/aima-booking';
10
210
 
11
211
  const client = getClient({
12
- apiKey: '...',
13
- baseUrl: '...',
14
- clientId: '...',
15
- clientSecret: '...',
16
- fleetId: '...',
212
+ apiKey: 'your-api-key',
213
+ baseUrl: 'https://your-api-base-url',
214
+ clientId: 'your-client-id',
215
+ clientSecret: 'your-client-secret',
216
+ fleetId: 'your-fleet-id',
17
217
  });
18
218
 
19
- const response = await getBookingRequests(client, 'ONGOING');
219
+ async function bookingWorkflow() {
220
+ try {
221
+ // Get all ongoing booking requests
222
+ const ongoingRequests = await getBookingRequests(client, 'ONGOING');
223
+ console.log(`Found ${ongoingRequests.length} ongoing booking requests`);
224
+
225
+ // Get stations with full information
226
+ const stations = await getStations(client, ['OPEN_HOUR', 'INFO', 'VEHICLES']);
227
+ console.log(`Found ${stations.length} stations`);
228
+
229
+ // Get specific booking request
230
+ const bookingRequest = await getBookingRequestById(client, 'bb493049-5b4f-43ea-8a65-964a13aec549');
231
+ console.log('Booking request details:', bookingRequest);
232
+
233
+ return { ongoingRequests, stations, bookingRequest };
234
+ } catch (error) {
235
+ console.error('Booking workflow error:', error);
236
+ throw error;
237
+ }
238
+ }
239
+ ```
20
240
 
21
- const station = await getStations(client, ['OPEN_HOUR', 'INFO']);
241
+ ### Station Analysis
22
242
 
23
- const br1 = await getBookingRequestById(client, 'bb493049-5b4f-43ea-8a65-964a13aec549');
24
- const br2 = await getBookingRequestByTrip(client, '33E8E42710144E15A5CC447E4D3524F4');
25
- const sub = await getSubscriptionBookingRequestById(client, 'b7faa2a2-e8fc-4a29-8de7-09ce783b9797');
243
+ ```javascript
244
+ async function analyzeStations(client) {
245
+ try {
246
+ const stations = await getStations(client, ['OPEN_HOUR', 'INFO', 'VEHICLES']);
247
+
248
+ const analysis = {
249
+ totalStations: stations.length,
250
+ activeStations: stations.filter(s => s.isActive).length,
251
+ stationsWithVehicles: stations.filter(s => s.vehicles && s.vehicles.length > 0).length,
252
+ averageVehiclesPerStation: stations.reduce((sum, s) => sum + (s.vehicles?.length || 0), 0) / stations.length,
253
+ stationsByZone: stations.reduce((acc, station) => {
254
+ station.zones?.forEach(zone => {
255
+ acc[zone.name] = (acc[zone.name] || 0) + 1;
256
+ });
257
+ return acc;
258
+ }, {})
259
+ };
260
+
261
+ console.log('Station Analysis:');
262
+ console.log(`Total Stations: ${analysis.totalStations}`);
263
+ console.log(`Active Stations: ${analysis.activeStations}`);
264
+ console.log(`Stations with Vehicles: ${analysis.stationsWithVehicles}`);
265
+ console.log(`Average Vehicles per Station: ${analysis.averageVehiclesPerStation.toFixed(2)}`);
266
+ console.log('Stations by Zone:', analysis.stationsByZone);
267
+
268
+ return analysis;
269
+ } catch (error) {
270
+ console.error('Station analysis error:', error);
271
+ throw error;
272
+ }
273
+ }
274
+ ```
275
+
276
+ ### Booking Request Monitoring
277
+
278
+ ```javascript
279
+ async function monitorBookingRequests(client) {
280
+ try {
281
+ const [ongoing, completed, cancelled] = await Promise.all([
282
+ getBookingRequests(client, 'ONGOING'),
283
+ getBookingRequests(client, 'COMPLETED'),
284
+ getBookingRequests(client, 'CANCELLED')
285
+ ]);
286
+
287
+ const monitoring = {
288
+ ongoing: ongoing.length,
289
+ completed: completed.length,
290
+ cancelled: cancelled.length,
291
+ total: ongoing.length + completed.length + cancelled.length,
292
+ completionRate: completed.length / (completed.length + cancelled.length) * 100
293
+ };
294
+
295
+ console.log('Booking Request Monitoring:');
296
+ console.log(`Ongoing: ${monitoring.ongoing}`);
297
+ console.log(`Completed: ${monitoring.completed}`);
298
+ console.log(`Cancelled: ${monitoring.cancelled}`);
299
+ console.log(`Total: ${monitoring.total}`);
300
+ console.log(`Completion Rate: ${monitoring.completionRate.toFixed(2)}%`);
301
+
302
+ return monitoring;
303
+ } catch (error) {
304
+ console.error('Booking monitoring error:', error);
305
+ throw error;
306
+ }
307
+ }
26
308
  ```
package/dist/index.d.mts CHANGED
@@ -104,6 +104,47 @@ type SATBookingRequest = BaseBookingRequest & {
104
104
  trip: any | null;
105
105
  warning: string | null;
106
106
  };
107
+ type GeoInfo = {
108
+ name: string;
109
+ coordinates: {
110
+ latitude: number;
111
+ longitude: number;
112
+ };
113
+ geoProperties: {
114
+ [key: string]: any;
115
+ };
116
+ };
117
+ type Service = {
118
+ id: string;
119
+ models: {
120
+ id: number;
121
+ vehicles: string[];
122
+ }[];
123
+ };
124
+ type ServiceInfo = {
125
+ services: Service[];
126
+ };
127
+ type Days = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
128
+ type DayOpeningHours = {
129
+ id: number;
130
+ closed: boolean;
131
+ openAt: string;
132
+ closeAt: string;
133
+ };
134
+ type Timetable = Record<Days, DayOpeningHours[]>;
135
+ type OpeningHours = {
136
+ alwaysOpen: boolean;
137
+ timetable: Timetable;
138
+ };
139
+ type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
140
+ id: string;
141
+ zoneId: string;
142
+ poiId: string;
143
+ modificationDate: string;
144
+ fleetId: string;
145
+ openingHours?: OpeningHours;
146
+ [key: string]: any;
147
+ };
107
148
 
108
149
  declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL"]>;
109
150
  type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
@@ -146,49 +187,12 @@ declare const getBookingRequestById: (client: Client, id: string) => Promise<Boo
146
187
  declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
147
188
  declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
148
189
 
149
- declare const IncludeSchema: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
150
- type Include = z.infer<typeof IncludeSchema>;
151
- type Days = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
152
- type DayOpeningHours = {
153
- id: number;
154
- closed: boolean;
155
- openAt: string;
156
- closeAt: string;
157
- };
158
- type Timetable = Record<Days, DayOpeningHours[]>;
159
- type OpeningHours = {
160
- alwaysOpen: boolean;
161
- timetable: Timetable;
162
- };
163
- type GeoInfo = {
164
- name: string;
165
- coordinates: {
166
- latitude: number;
167
- longitude: number;
168
- };
169
- geoProperties: {
170
- [key: string]: any;
171
- };
172
- };
173
- type Service = {
174
- id: string;
175
- models: {
176
- id: number;
177
- vehicles: string[];
178
- }[];
179
- };
180
- type ServiceInfo = {
181
- services: Service[];
182
- };
183
- type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
184
- id: string;
185
- zoneId: string;
186
- poiId: string;
187
- modificationDate: string;
188
- fleetId: string;
189
- openingHours?: OpeningHours;
190
- [key: string]: any;
191
- };
190
+ declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
191
+ type Include = z.infer<typeof IncludeSchema$1>;
192
192
  declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
193
193
 
194
- export { type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type DayOpeningHours, type Days, type Include, type OpeningHours, type SATBookingRequestStatus, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getSATBookingRequests, getScheduleBookingRequests, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
194
+ declare const IncludeSchema: z.ZodEnum<["INFO", "SERVICES"]>;
195
+ type IncludeStation = z.infer<typeof IncludeSchema>;
196
+ declare const getStationById: (client: Client, id: string, includes?: IncludeStation[]) => Promise<Station | null>;
197
+
198
+ export { type BaseBookingRequest, type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type CustomPrice, type DayOpeningHours, type Days, type GeoInfo, type Include, type IncludeStation, type OpeningHours, type PaymentReceipts, type SATBookingRequest, type SATBookingRequestStatus, type Service, type ServiceInfo, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getSATBookingRequests, getScheduleBookingRequests, getStationById, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
package/dist/index.d.ts CHANGED
@@ -104,6 +104,47 @@ type SATBookingRequest = BaseBookingRequest & {
104
104
  trip: any | null;
105
105
  warning: string | null;
106
106
  };
107
+ type GeoInfo = {
108
+ name: string;
109
+ coordinates: {
110
+ latitude: number;
111
+ longitude: number;
112
+ };
113
+ geoProperties: {
114
+ [key: string]: any;
115
+ };
116
+ };
117
+ type Service = {
118
+ id: string;
119
+ models: {
120
+ id: number;
121
+ vehicles: string[];
122
+ }[];
123
+ };
124
+ type ServiceInfo = {
125
+ services: Service[];
126
+ };
127
+ type Days = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
128
+ type DayOpeningHours = {
129
+ id: number;
130
+ closed: boolean;
131
+ openAt: string;
132
+ closeAt: string;
133
+ };
134
+ type Timetable = Record<Days, DayOpeningHours[]>;
135
+ type OpeningHours = {
136
+ alwaysOpen: boolean;
137
+ timetable: Timetable;
138
+ };
139
+ type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
140
+ id: string;
141
+ zoneId: string;
142
+ poiId: string;
143
+ modificationDate: string;
144
+ fleetId: string;
145
+ openingHours?: OpeningHours;
146
+ [key: string]: any;
147
+ };
107
148
 
108
149
  declare const BookingRequestStatusSchema: z.ZodEnum<["ALERT", "UPCOMING", "ONGOING", "COMPLETED", "CANCELLED", "PENDING_APPROVAL"]>;
109
150
  type BookingRequestStatus = z.infer<typeof BookingRequestStatusSchema>;
@@ -146,49 +187,12 @@ declare const getBookingRequestById: (client: Client, id: string) => Promise<Boo
146
187
  declare const getBookingRequestByTrip: (client: Client, tripId: string) => Promise<BookingRequest>;
147
188
  declare const getSubscriptionBookingRequestById: (client: Client, id: string) => Promise<BookingRequest>;
148
189
 
149
- declare const IncludeSchema: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
150
- type Include = z.infer<typeof IncludeSchema>;
151
- type Days = 'MONDAY' | 'TUESDAY' | 'WEDNESDAY' | 'THURSDAY' | 'FRIDAY' | 'SATURDAY' | 'SUNDAY';
152
- type DayOpeningHours = {
153
- id: number;
154
- closed: boolean;
155
- openAt: string;
156
- closeAt: string;
157
- };
158
- type Timetable = Record<Days, DayOpeningHours[]>;
159
- type OpeningHours = {
160
- alwaysOpen: boolean;
161
- timetable: Timetable;
162
- };
163
- type GeoInfo = {
164
- name: string;
165
- coordinates: {
166
- latitude: number;
167
- longitude: number;
168
- };
169
- geoProperties: {
170
- [key: string]: any;
171
- };
172
- };
173
- type Service = {
174
- id: string;
175
- models: {
176
- id: number;
177
- vehicles: string[];
178
- }[];
179
- };
180
- type ServiceInfo = {
181
- services: Service[];
182
- };
183
- type Station = Partial<GeoInfo> & Partial<ServiceInfo> & {
184
- id: string;
185
- zoneId: string;
186
- poiId: string;
187
- modificationDate: string;
188
- fleetId: string;
189
- openingHours?: OpeningHours;
190
- [key: string]: any;
191
- };
190
+ declare const IncludeSchema$1: z.ZodEnum<["INFO", "OPEN_HOUR", "SERVICES"]>;
191
+ type Include = z.infer<typeof IncludeSchema$1>;
192
192
  declare const getStations: (client: Client, includes?: Include[]) => Promise<Station[]>;
193
193
 
194
- export { type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type DayOpeningHours, type Days, type Include, type OpeningHours, type SATBookingRequestStatus, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getSATBookingRequests, getScheduleBookingRequests, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
194
+ declare const IncludeSchema: z.ZodEnum<["INFO", "SERVICES"]>;
195
+ type IncludeStation = z.infer<typeof IncludeSchema>;
196
+ declare const getStationById: (client: Client, id: string, includes?: IncludeStation[]) => Promise<Station | null>;
197
+
198
+ export { type BaseBookingRequest, type BookingRequest, type BookingRequestFilters, type BookingRequestStatus, type CustomPrice, type DayOpeningHours, type Days, type GeoInfo, type Include, type IncludeStation, type OpeningHours, type PaymentReceipts, type SATBookingRequest, type SATBookingRequestStatus, type Service, type ServiceInfo, type ServiceType, type Station, type Timetable, getBookingRequestById, getBookingRequestByTrip, getBookingRequests, getSATBookingRequests, getScheduleBookingRequests, getStationById, getStations, getSubscriptionBookingRequestById, getSubscriptionBookingRequests };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  getBookingRequests: () => getBookingRequests,
26
26
  getSATBookingRequests: () => getSATBookingRequests,
27
27
  getScheduleBookingRequests: () => getScheduleBookingRequests,
28
+ getStationById: () => getStationById,
28
29
  getStations: () => getStations,
29
30
  getSubscriptionBookingRequestById: () => getSubscriptionBookingRequestById,
30
31
  getSubscriptionBookingRequests: () => getSubscriptionBookingRequests
@@ -304,6 +305,110 @@ var getStations = async (client, includes = []) => {
304
305
  }
305
306
  return stations;
306
307
  };
308
+
309
+ // src/getStation.ts
310
+ var import_zod5 = require("zod");
311
+ var IncludeSchema2 = import_zod5.z.enum(["INFO", "SERVICES"]);
312
+ var IncludesSchema2 = import_zod5.z.array(IncludeSchema2);
313
+ var getStationById = async (client, id, includes = []) => {
314
+ const resultIncludes = IncludesSchema2.safeParse(includes);
315
+ if (!resultIncludes.success) {
316
+ throw new TypeError("Invalid includes", {
317
+ cause: resultIncludes.error.issues
318
+ });
319
+ }
320
+ const station = await client.get(`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/stations/${id}`).then(({ data, status }) => {
321
+ if (status === 200) {
322
+ return Object.keys(data).reduce((acc, key) => {
323
+ if (key === "stationTimetableDTO") {
324
+ if (data.stationTimetableDTO?.stationId) {
325
+ acc.openingHours = {
326
+ alwaysOpen: data.stationTimetableDTO.alwaysOpen,
327
+ timetable: Object.keys(data.stationTimetableDTO.timetable).reduce(
328
+ (timetable, val) => {
329
+ timetable[val] = data.stationTimetableDTO.timetable[val].map(
330
+ (day) => ({
331
+ id: day.id,
332
+ closed: day.closed,
333
+ openAt: day.openAt,
334
+ closeAt: day.closeAt
335
+ })
336
+ );
337
+ return timetable;
338
+ },
339
+ {}
340
+ )
341
+ };
342
+ }
343
+ return acc;
344
+ }
345
+ acc[key] = data[key];
346
+ return acc;
347
+ }, {});
348
+ }
349
+ if (status === 400) {
350
+ return null;
351
+ }
352
+ return null;
353
+ }).catch((error) => {
354
+ if (error.formattedError?.status === 400) {
355
+ return null;
356
+ }
357
+ throw error;
358
+ });
359
+ if (station && includes.includes("INFO")) {
360
+ const poi = await client.get(
361
+ `/boapi/proxy/geoloc/fleets/${client.clientOptions.fleetId}/pois/${station.poiId}`,
362
+ {
363
+ headers: { accept: "application/vnd.geo+json" }
364
+ }
365
+ ).then(
366
+ ({ data }) => data.features.reduce(
367
+ (max, current) => {
368
+ if (current.properties.Version > max.version) {
369
+ const {
370
+ geometry: {
371
+ coordinates: [longitude, latitude]
372
+ },
373
+ properties
374
+ } = current;
375
+ return {
376
+ version: current.properties.Version,
377
+ name: properties.name,
378
+ coordinates: { latitude, longitude },
379
+ geoProperties: properties
380
+ };
381
+ }
382
+ return max;
383
+ },
384
+ { version: -1 }
385
+ )
386
+ );
387
+ if (station.poiId && poi) {
388
+ poi.version = void 0;
389
+ Object.assign(station, poi);
390
+ station.name = station.geoProperties?.name;
391
+ }
392
+ }
393
+ if (station && includes.includes("SERVICES")) {
394
+ const services = await client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/stations/details?showTimetable=false`).then(
395
+ ({ data }) => data.stations.reduce((acc, service) => {
396
+ if (!acc[service.station.id]) {
397
+ acc[service.station.id] = { services: [] };
398
+ }
399
+ acc[service.station.id].services.push({
400
+ id: service.serviceId,
401
+ models: service.station.models
402
+ });
403
+ return acc;
404
+ }, {})
405
+ );
406
+ if (services[station.id]) {
407
+ Object.assign(station, services[station.id]);
408
+ }
409
+ }
410
+ return station;
411
+ };
307
412
  // Annotate the CommonJS export names for ESM import in node:
308
413
  0 && (module.exports = {
309
414
  getBookingRequestById,
@@ -311,6 +416,7 @@ var getStations = async (client, includes = []) => {
311
416
  getBookingRequests,
312
417
  getSATBookingRequests,
313
418
  getScheduleBookingRequests,
419
+ getStationById,
314
420
  getStations,
315
421
  getSubscriptionBookingRequestById,
316
422
  getSubscriptionBookingRequests