@vulog/aima-booking 1.2.30 → 1.2.31

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/dist/index.js DELETED
@@ -1,647 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- allocateVehicle: () => allocateVehicle,
34
- cancelBookingRequest: () => cancelBookingRequest,
35
- deallocateVehicle: () => deallocateVehicle,
36
- getAvailableVehicles: () => getAvailableVehicles,
37
- getBookingRequestById: () => getBookingRequestById,
38
- getBookingRequestByTrip: () => getBookingRequestByTrip,
39
- getBookingRequests: () => getBookingRequests,
40
- getBookingRequestsByUserId: () => getBookingRequestsByUserId,
41
- getSATBookingRequests: () => getSATBookingRequests,
42
- getScheduleBookingRequests: () => getScheduleBookingRequests,
43
- getStationById: () => getStationById,
44
- getStations: () => getStations,
45
- getSubscriptionBookingRequestById: () => getSubscriptionBookingRequestById,
46
- getSubscriptionBookingRequests: () => getSubscriptionBookingRequests,
47
- releaseBRPayment: () => releaseBRPayment,
48
- triggerBRPayment: () => triggerBRPayment,
49
- updateScheduleBooking: () => updateScheduleBooking
50
- });
51
- module.exports = __toCommonJS(index_exports);
52
-
53
- // src/getBookingRequests.ts
54
- var import_aima_core = require("@vulog/aima-core");
55
- var import_compat = require("es-toolkit/compat");
56
- var import_zod = require("zod");
57
- var BookingRequestStatusSchema = import_zod.z.enum([
58
- "ALERT",
59
- "UPCOMING",
60
- "ONGOING",
61
- "COMPLETED",
62
- "CANCELLED",
63
- "PENDING_APPROVAL",
64
- "CONFIRMED",
65
- "PENDING",
66
- "LATE"
67
- ]);
68
- var ServiceTypeSchema = import_zod.z.enum(["SUBSCRIPTION", "ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]);
69
- var getBookingRequests = async (client, status, options) => {
70
- const preparedOptions = options ? { ...options, filters: options.filters || {} } : { filters: {} };
71
- const resultStatus = BookingRequestStatusSchema.safeParse(status);
72
- if (!resultStatus.success) {
73
- throw new TypeError("Invalid status", {
74
- cause: resultStatus.error.issues
75
- });
76
- }
77
- const date = /* @__PURE__ */ new Date();
78
- date.setMilliseconds(0);
79
- const startDate = date.toISOString().replace(".000Z", "Z");
80
- date.setMonth(date.getMonth() + 2);
81
- const endDate = date.toISOString().replace(".000Z", "Z");
82
- const BookingRequestFiltersSchema = import_zod.z.object({
83
- serviceTypes: import_zod.z.array(ServiceTypeSchema).optional(),
84
- serviceIds: import_zod.z.array(import_zod.z.string().uuid()).optional(),
85
- userId: import_zod.z.string().uuid().optional(),
86
- modelId: import_zod.z.number().positive().optional(),
87
- vehicleId: import_zod.z.string().uuid().optional(),
88
- stationId: import_zod.z.string().uuid().optional(),
89
- creationDate: import_zod.z.string().date().optional(),
90
- startDate: import_zod.z.string().datetime({ offset: false, precision: 0 }).default(startDate),
91
- endDate: import_zod.z.string().datetime({ offset: false, precision: 0 }).default(endDate),
92
- includeProducts: import_zod.z.enum(["true", "false"]).optional()
93
- }).default({});
94
- const PaginableOptionsSchema = (0, import_aima_core.createPaginableOptionsSchema)(BookingRequestFiltersSchema).default({});
95
- const resultOptions = PaginableOptionsSchema.safeParse(preparedOptions);
96
- if (!resultOptions.success) {
97
- throw new TypeError("Invalid options", {
98
- cause: resultOptions.error.issues
99
- });
100
- }
101
- const finalOptions = resultOptions.data;
102
- const searchParams = new URLSearchParams();
103
- searchParams.append("page", finalOptions.page.toString());
104
- searchParams.append("size", finalOptions.pageSize.toString());
105
- Object.entries(finalOptions.filters).forEach(([key, value]) => {
106
- if (value === void 0) {
107
- return;
108
- }
109
- if (Array.isArray(value) && value.length > 0) {
110
- searchParams.append(key, value.join(","));
111
- return;
112
- }
113
- if ((0, import_compat.isNumber)(value)) {
114
- searchParams.append(key, value.toString());
115
- return;
116
- }
117
- searchParams.append(key, value);
118
- });
119
- return client.get(`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/status/${status}/filters?${searchParams.toString()}`).then(({ data, headers }) => {
120
- return {
121
- data,
122
- page: headers.number,
123
- pageSize: headers.size,
124
- total: headers.totalelements,
125
- totalPages: headers.totalpages
126
- };
127
- });
128
- };
129
- var getScheduleBookingRequests = async (client, status, options) => {
130
- return getBookingRequests(client, status, {
131
- ...options,
132
- filters: {
133
- ...options?.filters,
134
- serviceTypes: ["ROUND_TRIP_BOOKING", "SCHEDULED_BOOKING_STATION"]
135
- }
136
- });
137
- };
138
- var getSubscriptionBookingRequests = async (client, status, options) => {
139
- return getBookingRequests(client, status, {
140
- ...options,
141
- filters: {
142
- ...options?.filters,
143
- serviceTypes: ["SUBSCRIPTION"]
144
- }
145
- });
146
- };
147
-
148
- // src/getSATBookingRequests.ts
149
- var import_aima_core2 = require("@vulog/aima-core");
150
- var import_zod2 = require("zod");
151
- var SATBookingRequestStatusSchema = import_zod2.z.enum([
152
- "ALERT",
153
- "CANCELLED",
154
- "COMPLETED",
155
- "CONFIRMED",
156
- "LATE_RETURN",
157
- "ONGOING",
158
- "PENDING_PAYMENT",
159
- "PENDING",
160
- "UPCOMING_ALLOCATED",
161
- "UPCOMING_NOT_ALLOCATED"
162
- ]);
163
- var getSATBookingRequests = async (client, status, options) => {
164
- const resultStatus = SATBookingRequestStatusSchema.safeParse(status);
165
- if (!resultStatus.success) {
166
- throw new TypeError("Invalid status", {
167
- cause: resultStatus.error.issues
168
- });
169
- }
170
- const PaginableOptionsSchema = (0, import_aima_core2.createPaginableOptionsSchema)().default({});
171
- const resultOptions = PaginableOptionsSchema.safeParse(options);
172
- if (!resultOptions.success) {
173
- throw new TypeError("Invalid options", {
174
- cause: resultOptions.error.issues
175
- });
176
- }
177
- const finalOptions = resultOptions.data;
178
- const searchParams = new URLSearchParams();
179
- if (finalOptions.page) {
180
- searchParams.append("page", finalOptions.page.toString());
181
- }
182
- if (finalOptions.pageSize) {
183
- searchParams.append("size", finalOptions.pageSize.toString());
184
- }
185
- if (finalOptions.sortDirection && finalOptions.sort) {
186
- searchParams.append("sort", `${finalOptions.sort},${finalOptions.sortDirection}`);
187
- }
188
- if (finalOptions.sort && !finalOptions.sortDirection) {
189
- searchParams.append("sort", finalOptions.sort);
190
- }
191
- return client.get(`/boapi/proxy/user/scheduleATrip/fleets/${client.clientOptions.fleetId}/bookingrequests/status/${status}?${searchParams.toString()}`).then(({ data, headers }) => {
192
- return {
193
- data,
194
- page: headers.number,
195
- pageSize: headers.size,
196
- total: headers.totalelements,
197
- totalPages: headers.totalpages
198
- };
199
- });
200
- };
201
-
202
- // src/getBookingRequest.ts
203
- var import_zod3 = require("zod");
204
- var getBookingRequestById = async (client, id) => {
205
- const result = import_zod3.z.string().trim().min(1).uuid().safeParse(id);
206
- if (!result.success) {
207
- throw new TypeError("Invalid id", {
208
- cause: result.error.issues
209
- });
210
- }
211
- return client.get(
212
- `/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/${id}`
213
- ).then(({ data }) => data);
214
- };
215
- var getBookingRequestByTrip = async (client, tripId) => {
216
- const result = import_zod3.z.string().trim().min(1).safeParse(tripId);
217
- if (!result.success) {
218
- throw new TypeError("Invalid tripId", {
219
- cause: result.error.issues
220
- });
221
- }
222
- return client.get(
223
- `/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/trip/${tripId}`
224
- ).then(({ data }) => data);
225
- };
226
- var getSubscriptionBookingRequestById = async (client, id) => {
227
- const result = import_zod3.z.string().trim().min(1).uuid().safeParse(id);
228
- if (!result.success) {
229
- throw new TypeError("Invalid id", {
230
- cause: result.error.issues
231
- });
232
- }
233
- return client.get(
234
- `/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/subscription/bookingrequests/${id}`
235
- ).then(({ data: { stationId, ...data } }) => ({ station: stationId, ...data }));
236
- };
237
-
238
- // src/getAvailableVehicles.ts
239
- var import_zod4 = require("zod");
240
- var isoDateTimeNoMs = import_zod4.z.string().trim().datetime({ precision: 0 });
241
- var getAvailableVehiclesSchema = import_zod4.z.object({
242
- stationId: import_zod4.z.string().trim().min(1),
243
- startDate: isoDateTimeNoMs
244
- });
245
- var getAvailableVehicles = async (client, stationId, startDate) => {
246
- const result = getAvailableVehiclesSchema.safeParse({ stationId, startDate });
247
- if (!result.success) {
248
- throw new TypeError("Invalid args", {
249
- cause: result.error.issues
250
- });
251
- }
252
- return client.get(
253
- `/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/subscription/stations/${stationId}/vehicles/available?startDate=${startDate}`
254
- ).then(({ data }) => data);
255
- };
256
-
257
- // src/getStations.ts
258
- var import_zod5 = require("zod");
259
- var IncludeSchema = import_zod5.z.enum(["INFO", "OPEN_HOUR", "SERVICES"]);
260
- var IncludesSchema = import_zod5.z.array(IncludeSchema);
261
- var getStations = async (client, includes = []) => {
262
- const resultIncludes = IncludesSchema.safeParse(includes);
263
- if (!resultIncludes.success) {
264
- throw new TypeError("Invalid includes", {
265
- cause: resultIncludes.error.issues
266
- });
267
- }
268
- const searchParams = new URLSearchParams();
269
- if (includes.includes("OPEN_HOUR")) {
270
- searchParams.append("showTimetable", "true");
271
- }
272
- const stations = await client.get(`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/stations${searchParams.size > 0 ? `?${searchParams.toString()}` : ""}`).then(
273
- ({ data }) => data.map(
274
- (station) => Object.keys(station).reduce((acc, key) => {
275
- if (key === "stationTimetableDTO") {
276
- if (station.stationTimetableDTO?.stationId) {
277
- acc.openingHours = {
278
- alwaysOpen: station.stationTimetableDTO.alwaysOpen,
279
- timetable: Object.keys(station.stationTimetableDTO.timetable).reduce(
280
- (timetable, val) => {
281
- timetable[val] = station.stationTimetableDTO.timetable[val].map(
282
- (day) => ({
283
- id: day.id,
284
- closed: day.closed,
285
- openAt: day.openAt,
286
- closeAt: day.closeAt
287
- })
288
- );
289
- return timetable;
290
- },
291
- {}
292
- )
293
- };
294
- }
295
- return acc;
296
- }
297
- acc[key] = station[key];
298
- return acc;
299
- }, {})
300
- )
301
- );
302
- if (includes.includes("INFO")) {
303
- const pois = await client.get(`/boapi/proxy/geoloc/fleets/${client.clientOptions.fleetId}/pois`, {
304
- headers: { accept: "application/vnd.geo+json" }
305
- }).then(
306
- ({ data }) => data.features.reduce((acc, poi) => {
307
- const {
308
- geometry: {
309
- coordinates: [longitude, latitude]
310
- },
311
- properties
312
- } = poi;
313
- acc[properties.poiId] = {
314
- name: properties.name,
315
- coordinates: { latitude, longitude },
316
- geoProperties: properties
317
- };
318
- return acc;
319
- }, {})
320
- );
321
- stations.forEach((station) => {
322
- if (station.poiId && pois[station.poiId]) {
323
- Object.assign(station, pois[station.poiId]);
324
- }
325
- });
326
- }
327
- if (includes.includes("SERVICES")) {
328
- const services = await client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/stations/details?size=1000`).then(
329
- ({ data }) => data.stations.reduce((acc, service) => {
330
- if (!acc[service.station.id]) {
331
- acc[service.station.id] = { services: [] };
332
- }
333
- acc[service.station.id].services.push({
334
- id: service.serviceId,
335
- models: service.station.models
336
- });
337
- return acc;
338
- }, {})
339
- );
340
- stations.forEach((station) => {
341
- if (services[station.id]) {
342
- Object.assign(station, services[station.id]);
343
- }
344
- });
345
- }
346
- return stations;
347
- };
348
-
349
- // src/getStation.ts
350
- var import_zod6 = require("zod");
351
- var IncludeSchema2 = import_zod6.z.enum(["INFO", "SERVICES"]);
352
- var IncludesSchema2 = import_zod6.z.array(IncludeSchema2);
353
- var getStationById = async (client, id, includes = []) => {
354
- const resultIncludes = IncludesSchema2.safeParse(includes);
355
- if (!resultIncludes.success) {
356
- throw new TypeError("Invalid includes", {
357
- cause: resultIncludes.error.issues
358
- });
359
- }
360
- const station = await client.get(`/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/stations/${id}`).then(({ data, status }) => {
361
- if (status === 200) {
362
- return Object.keys(data).reduce((acc, key) => {
363
- if (key === "stationTimetableDTO") {
364
- if (data.stationTimetableDTO?.stationId) {
365
- acc.openingHours = {
366
- alwaysOpen: data.stationTimetableDTO.alwaysOpen,
367
- timetable: Object.keys(data.stationTimetableDTO.timetable).reduce(
368
- (timetable, val) => {
369
- timetable[val] = data.stationTimetableDTO.timetable[val].map(
370
- (day) => ({
371
- id: day.id,
372
- closed: day.closed,
373
- openAt: day.openAt,
374
- closeAt: day.closeAt
375
- })
376
- );
377
- return timetable;
378
- },
379
- {}
380
- )
381
- };
382
- }
383
- return acc;
384
- }
385
- acc[key] = data[key];
386
- return acc;
387
- }, {});
388
- }
389
- if (status === 400) {
390
- return null;
391
- }
392
- return null;
393
- }).catch((error) => {
394
- if (error.formattedError?.status === 400) {
395
- return null;
396
- }
397
- throw error;
398
- });
399
- if (station && includes.includes("INFO")) {
400
- const poi = await client.get(
401
- `/boapi/proxy/geoloc/fleets/${client.clientOptions.fleetId}/pois/${station.poiId}`,
402
- {
403
- headers: { accept: "application/vnd.geo+json" }
404
- }
405
- ).then(
406
- ({ data }) => data.features.reduce(
407
- (max, current) => {
408
- if (current.properties.Version > max.version) {
409
- const {
410
- geometry: {
411
- coordinates: [longitude, latitude]
412
- },
413
- properties
414
- } = current;
415
- return {
416
- version: current.properties.Version,
417
- name: properties.name,
418
- coordinates: { latitude, longitude },
419
- geoProperties: properties
420
- };
421
- }
422
- return max;
423
- },
424
- { version: -1 }
425
- )
426
- );
427
- if (station.poiId && poi) {
428
- poi.version = void 0;
429
- Object.assign(station, poi);
430
- station.name = station.geoProperties?.name;
431
- }
432
- }
433
- if (station && includes.includes("SERVICES")) {
434
- const services = await client.get(`/boapi/proxy/user/fleets/${client.clientOptions.fleetId}/stations/details?showTimetable=false`).then(
435
- ({ data }) => data.stations.reduce((acc, service) => {
436
- if (!acc[service.station.id]) {
437
- acc[service.station.id] = { services: [] };
438
- }
439
- acc[service.station.id].services.push({
440
- id: service.serviceId,
441
- models: service.station.models
442
- });
443
- return acc;
444
- }, {})
445
- );
446
- if (services[station.id]) {
447
- Object.assign(station, services[station.id]);
448
- }
449
- }
450
- return station;
451
- };
452
-
453
- // src/allocateVehicle.ts
454
- var import_zod7 = __toESM(require("zod"));
455
- var allocateVehicleSchema = import_zod7.default.object({
456
- bookingRequestId: import_zod7.default.string().uuid(),
457
- vehicleId: import_zod7.default.string().uuid(),
458
- serviceId: import_zod7.default.string().uuid()
459
- });
460
- var allocateVehicle = async (client, bookingRequestId, vehicleId, serviceId) => {
461
- const resultPayload = allocateVehicleSchema.safeParse({ bookingRequestId, vehicleId, serviceId });
462
- if (!resultPayload.success) {
463
- throw new TypeError("Invalid args", {
464
- cause: resultPayload.error.issues
465
- });
466
- }
467
- return client.post(
468
- `boapi/proxy/user/scheduleATrip/fleets/${client.clientOptions.fleetId}/bookingrequests/${bookingRequestId}/allocate/${vehicleId}?serviceId=${serviceId}`
469
- ).then(({ data }) => data);
470
- };
471
-
472
- // src/deallocateVehicle.ts
473
- var import_zod8 = __toESM(require("zod"));
474
- var deallocateVehicleSchema = import_zod8.default.object({
475
- bookingRequestId: import_zod8.default.string().uuid(),
476
- vehicleId: import_zod8.default.string().uuid()
477
- });
478
- var deallocateVehicle = async (client, bookingRequestId, vehicleId) => {
479
- const resultPayload = deallocateVehicleSchema.safeParse({ bookingRequestId, vehicleId });
480
- if (!resultPayload.success) {
481
- throw new TypeError("Invalid args", {
482
- cause: resultPayload.error.issues
483
- });
484
- }
485
- return client.delete(
486
- `boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/${bookingRequestId}/vehicles/${vehicleId}`
487
- ).then(({ data }) => data);
488
- };
489
-
490
- // src/updateScheduleBooking.ts
491
- var import_zod9 = __toESM(require("zod"));
492
- var schema = import_zod9.default.object({
493
- id: import_zod9.default.string(),
494
- startDate: import_zod9.default.string().refine((date) => !Number.isNaN(Date.parse(date)), {
495
- message: "Invalid date"
496
- }).optional(),
497
- latitude: import_zod9.default.number().min(-90).max(90).optional(),
498
- longitude: import_zod9.default.number().min(-180).max(180).optional(),
499
- radius: import_zod9.default.number().min(0).optional(),
500
- userId: import_zod9.default.string().optional(),
501
- status: import_zod9.default.enum(["CONFIRMED", "CANCELLED", "PENDING"]).optional(),
502
- cityId: import_zod9.default.string().optional(),
503
- profileId: import_zod9.default.string().optional(),
504
- serviceId: import_zod9.default.string().optional(),
505
- warning: import_zod9.default.string().optional(),
506
- modelId: import_zod9.default.number().optional(),
507
- notes: import_zod9.default.string().optional(),
508
- bookingReferenceId: import_zod9.default.string().optional(),
509
- plannedReturnDate: import_zod9.default.string().refine((date) => !Number.isNaN(Date.parse(date)), {
510
- message: "Invalid date"
511
- }).optional()
512
- });
513
- var updateScheduleBooking = async (client, bookingRequestId, updateData) => {
514
- const result = schema.safeParse({ id: bookingRequestId, ...updateData });
515
- if (!result.success) {
516
- throw new TypeError("Invalid args", {
517
- cause: result.error.issues
518
- });
519
- }
520
- return client.post(
521
- `/boapi/proxy/user/scheduleATrip/fleets/${client.clientOptions.fleetId}/bookingrequests/${bookingRequestId}`,
522
- updateData
523
- ).then(({ data }) => data);
524
- };
525
-
526
- // src/triggerBRPayment.ts
527
- var import_zod10 = __toESM(require("zod"));
528
- var triggerBRPaymentSchema = import_zod10.default.object({
529
- bookingRequestId: import_zod10.default.string().uuid(),
530
- body: import_zod10.default.object({
531
- scope: import_zod10.default.enum(["RENTAL", "DEPOSIT"]),
532
- requiresActionReturnURL: import_zod10.default.string().url().optional(),
533
- online: import_zod10.default.boolean(),
534
- amountType: import_zod10.default.enum(["FIXED", "PERCENTAGE"]),
535
- amountValue: import_zod10.default.number().nonnegative(),
536
- preferredPaymentMethods: import_zod10.default.array(
537
- import_zod10.default.object({
538
- pspReference: import_zod10.default.string(),
539
- amount: import_zod10.default.number().default(0)
540
- })
541
- ).optional(),
542
- profileId: import_zod10.default.string().uuid()
543
- })
544
- });
545
- var triggerBRPayment = async (client, bookingRequestId, body) => {
546
- const resultPayload = triggerBRPaymentSchema.safeParse({ bookingRequestId, body });
547
- if (!resultPayload.success) {
548
- throw new TypeError("Invalid args", {
549
- cause: resultPayload.error.issues
550
- });
551
- }
552
- return client.post(
553
- `boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/${bookingRequestId}/payment`,
554
- resultPayload.data.body
555
- ).then(({ data }) => data).catch((error) => {
556
- throw new TypeError("Failed to trigger booking request payment", {
557
- cause: error
558
- });
559
- });
560
- };
561
-
562
- // src/getBookingRequestsByUserId.ts
563
- var import_zod11 = require("zod");
564
- var schema2 = import_zod11.z.object({
565
- userId: import_zod11.z.string().trim().min(1).uuid()
566
- });
567
- var getBookingRequestsByUserId = async (client, userId) => {
568
- const result = schema2.safeParse({ userId });
569
- if (!result.success) {
570
- throw new TypeError("Invalid userId", {
571
- cause: result.error.issues
572
- });
573
- }
574
- return client.get(
575
- `/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/users/${userId}`
576
- ).then(({ data }) => data).catch((error) => {
577
- if (error.formattedError?.status === 404) {
578
- return [];
579
- }
580
- throw error;
581
- });
582
- };
583
-
584
- // src/releaseBRPayment.ts
585
- var import_zod12 = __toESM(require("zod"));
586
- var releaseBRPaymentSchema = import_zod12.default.object({
587
- bookingRequestId: import_zod12.default.string().uuid(),
588
- pspReference: import_zod12.default.string().uuid()
589
- });
590
- var releaseBRPayment = async (client, bookingRequestId, pspReference) => {
591
- const resultPayload = releaseBRPaymentSchema.safeParse({ bookingRequestId, pspReference });
592
- if (!resultPayload.success) {
593
- throw new TypeError("Invalid args", {
594
- cause: resultPayload.error.issues
595
- });
596
- }
597
- return client.post(
598
- `boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/${bookingRequestId}/paymentintent/${pspReference}/cancel`,
599
- {}
600
- ).then(({ data }) => data).catch((error) => {
601
- throw new TypeError("Failed to release booking request payment", {
602
- cause: error
603
- });
604
- });
605
- };
606
-
607
- // src/cancelBookingRequest.ts
608
- var import_zod13 = __toESM(require("zod"));
609
- var schema3 = import_zod13.default.object({
610
- id: import_zod13.default.string().uuid()
611
- });
612
- var cancelBookingRequest = async (client, id) => {
613
- const result = schema3.safeParse({ id });
614
- if (!result.success) {
615
- throw new TypeError("Invalid args", {
616
- cause: result.error.issues
617
- });
618
- }
619
- return client.post(
620
- `/boapi/proxy/user/scheduledBooking/fleets/${client.clientOptions.fleetId}/bookingrequests/cancel/${id}`,
621
- {}
622
- ).then(({ data }) => data).catch((error) => {
623
- throw new TypeError("Failed to cancel booking request", {
624
- cause: error
625
- });
626
- });
627
- };
628
- // Annotate the CommonJS export names for ESM import in node:
629
- 0 && (module.exports = {
630
- allocateVehicle,
631
- cancelBookingRequest,
632
- deallocateVehicle,
633
- getAvailableVehicles,
634
- getBookingRequestById,
635
- getBookingRequestByTrip,
636
- getBookingRequests,
637
- getBookingRequestsByUserId,
638
- getSATBookingRequests,
639
- getScheduleBookingRequests,
640
- getStationById,
641
- getStations,
642
- getSubscriptionBookingRequestById,
643
- getSubscriptionBookingRequests,
644
- releaseBRPayment,
645
- triggerBRPayment,
646
- updateScheduleBooking
647
- });
File without changes