@vulog/aima-business 1.2.39 → 1.2.41

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.cjs CHANGED
@@ -2,7 +2,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let zod = require("zod");
3
3
  let _vulog_aima_core = require("@vulog/aima-core");
4
4
  //#region src/addBusinessCredit.ts
5
- const bodySchema$5 = zod.z.object({ amount: zod.z.number().min(0) });
5
+ const bodySchema$5 = zod.z.object({
6
+ amount: zod.z.number().min(0),
7
+ expirationDate: zod.z.string().trim().min(1)
8
+ });
6
9
  const addBusinessCredit = async (client, businessId, body) => {
7
10
  const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
8
11
  if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
@@ -29,7 +32,7 @@ const addTripNote = async (client, tripId, body) => {
29
32
  };
30
33
  //#endregion
31
34
  //#region src/addUserToBusiness.ts
32
- const uuidSchema$9 = zod.z.string().trim().min(1).uuid();
35
+ const uuidSchema$10 = zod.z.string().trim().min(1).uuid();
33
36
  const bodySchema$4 = zod.z.object({
34
37
  email: zod.z.string().trim().email().optional(),
35
38
  emailConsent: zod.z.boolean().optional(),
@@ -37,8 +40,8 @@ const bodySchema$4 = zod.z.object({
37
40
  costCenterId: zod.z.string().trim().min(1).uuid().optional()
38
41
  }).optional();
39
42
  const addUserToBusiness = async (client, businessId, userId, data) => {
40
- const parsedBusinessId = uuidSchema$9.safeParse(businessId);
41
- const parsedUserId = uuidSchema$9.safeParse(userId);
43
+ const parsedBusinessId = uuidSchema$10.safeParse(businessId);
44
+ const parsedUserId = uuidSchema$10.safeParse(userId);
42
45
  if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
43
46
  const result = bodySchema$4.safeParse(data);
44
47
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
@@ -46,11 +49,11 @@ const addUserToBusiness = async (client, businessId, userId, data) => {
46
49
  };
47
50
  //#endregion
48
51
  //#region src/archiveBusinessProfile.ts
49
- const uuidSchema$8 = zod.z.string().trim().min(1).uuid();
52
+ const uuidSchema$9 = zod.z.string().trim().min(1).uuid();
50
53
  const archiveBusinessProfile = async (client, businessId, userId, profileId) => {
51
- const parsedBusinessId = uuidSchema$8.safeParse(businessId);
52
- const parsedUserId = uuidSchema$8.safeParse(userId);
53
- const parsedProfileId = uuidSchema$8.safeParse(profileId);
54
+ const parsedBusinessId = uuidSchema$9.safeParse(businessId);
55
+ const parsedUserId = uuidSchema$9.safeParse(userId);
56
+ const parsedProfileId = uuidSchema$9.safeParse(profileId);
54
57
  if (!parsedBusinessId.success || !parsedUserId.success || !parsedProfileId.success) throw new TypeError("Invalid args", { cause: [
55
58
  ...parsedBusinessId.error?.issues ?? [],
56
59
  ...parsedUserId.error?.issues ?? [],
@@ -60,17 +63,17 @@ const archiveBusinessProfile = async (client, businessId, userId, profileId) =>
60
63
  };
61
64
  //#endregion
62
65
  //#region src/bulkAddBusinessUsers.ts
63
- const bulkAddSchema = zod.z.object({
64
- businessId: zod.z.string().trim().min(1).uuid(),
65
- userIds: zod.z.array(zod.z.string().trim().min(1).uuid()).min(1)
66
- });
67
- const bulkAddBusinessUsers = async (client, businessId, body) => {
68
- const result = bulkAddSchema.safeParse({
69
- businessId,
70
- userIds: body.userIds
71
- });
72
- if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
73
- await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/user/bulk`, { userIds: result.data.userIds });
66
+ const uuidSchema$8 = zod.z.string().trim().min(1).uuid();
67
+ const bulkAddBusinessUsers = async (client, businessId, file, locale) => {
68
+ const parsedId = uuidSchema$8.safeParse(businessId);
69
+ if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
70
+ const formData = new FormData();
71
+ formData.append("file", file);
72
+ const searchParams = new URLSearchParams();
73
+ if (locale) searchParams.append("locale", locale);
74
+ const queryString = searchParams.toString();
75
+ const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId.data}/user/bulk${queryString ? `?${queryString}` : ""}`;
76
+ return client.post(url, formData, { headers: { "Content-Type": "multipart/form-data" } }).then(({ data }) => data);
74
77
  };
75
78
  //#endregion
76
79
  //#region src/businessDelegatedAdmin.ts
@@ -104,7 +107,13 @@ const removeBusinessOwner = async (client, businessId, userId) => {
104
107
  };
105
108
  //#endregion
106
109
  //#region src/chargeBusinessProduct.ts
107
- const bodySchema$3 = zod.z.object({ productId: zod.z.string().trim().min(1) });
110
+ const bodySchema$3 = zod.z.object({
111
+ productId: zod.z.string().trim().min(1),
112
+ amount: zod.z.number().min(0),
113
+ userId: zod.z.string().trim().min(1).uuid().optional(),
114
+ productNotes: zod.z.string().trim().optional(),
115
+ serviceId: zod.z.string().trim().min(1).uuid().optional()
116
+ });
108
117
  const chargeBusinessProduct = async (client, businessId, body) => {
109
118
  const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
110
119
  if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
@@ -114,7 +123,7 @@ const chargeBusinessProduct = async (client, businessId, body) => {
114
123
  };
115
124
  //#endregion
116
125
  //#region src/createBusiness.ts
117
- const createBusinessBodySchema = zod.z.object({ name: zod.z.string().trim().min(1).max(255) });
126
+ const createBusinessBodySchema = zod.z.object({ name: zod.z.string().trim().min(1).max(255) }).passthrough();
118
127
  const createBusiness = async (client, body) => {
119
128
  const result = createBusinessBodySchema.safeParse(body);
120
129
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
@@ -122,17 +131,21 @@ const createBusiness = async (client, body) => {
122
131
  };
123
132
  //#endregion
124
133
  //#region src/createBusinessCostCenter.ts
125
- const schema$8 = zod.z.object({
134
+ const schema$10 = zod.z.object({
126
135
  businessId: zod.z.string().trim().min(1).uuid(),
127
- name: zod.z.string().trim().min(1).max(255)
136
+ name: zod.z.string().trim().min(1).max(255),
137
+ value: zod.z.string().trim().min(1)
128
138
  });
129
139
  const createBusinessCostCenter = async (client, businessId, body) => {
130
- const result = schema$8.safeParse({
140
+ const result = schema$10.safeParse({
131
141
  businessId,
132
142
  ...body
133
143
  });
134
144
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
135
- return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/costcenter`, { name: result.data.name }).then(({ data }) => data);
145
+ return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/costcenter`, {
146
+ name: result.data.name,
147
+ value: result.data.value
148
+ }).then(({ data }) => data);
136
149
  };
137
150
  //#endregion
138
151
  //#region src/deactivateBusinessProfile.ts
@@ -145,12 +158,12 @@ const deactivateBusinessProfile = async (client, businessId, profileId) => {
145
158
  };
146
159
  //#endregion
147
160
  //#region src/deleteBusinessCostCenter.ts
148
- const schema$7 = zod.z.object({
161
+ const schema$9 = zod.z.object({
149
162
  businessId: zod.z.string().trim().min(1).uuid(),
150
163
  costCenterId: zod.z.string().trim().min(1).uuid()
151
164
  });
152
165
  const deleteBusinessCostCenter = async (client, businessId, costCenterId) => {
153
- const result = schema$7.safeParse({
166
+ const result = schema$9.safeParse({
154
167
  businessId,
155
168
  costCenterId
156
169
  });
@@ -185,12 +198,12 @@ const getBusinessContacts = async (client, businessId) => {
185
198
  };
186
199
  //#endregion
187
200
  //#region src/getBusinessCostCenterById.ts
188
- const schema$6 = zod.z.object({
201
+ const schema$8 = zod.z.object({
189
202
  businessId: zod.z.string().trim().min(1).uuid(),
190
203
  costCenterId: zod.z.string().trim().min(1).uuid()
191
204
  });
192
205
  const getBusinessCostCenterById = async (client, businessId, costCenterId) => {
193
- const result = schema$6.safeParse({
206
+ const result = schema$8.safeParse({
194
207
  businessId,
195
208
  costCenterId
196
209
  });
@@ -206,29 +219,58 @@ const getBusinessCostCenters = async (client, businessId) => {
206
219
  };
207
220
  //#endregion
208
221
  //#region src/getBusinesses.ts
222
+ const businessFiltersSchema = zod.z.object({
223
+ name: zod.z.string().trim().min(1).optional(),
224
+ status: zod.z.string().trim().min(1).optional(),
225
+ updateSince: zod.z.string().trim().min(1).optional()
226
+ });
209
227
  const getBusinesses = async (client, options) => {
210
- const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
228
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(businessFiltersSchema.default({})).safeParse(options ?? {});
211
229
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
212
230
  const finalOptions = resultOptions.data;
213
231
  const searchParams = new URLSearchParams();
214
232
  searchParams.append("page", finalOptions.page.toString());
215
233
  searchParams.append("size", finalOptions.pageSize.toString());
216
234
  if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
235
+ const filterKeyMap = {
236
+ name: "name",
237
+ status: "status",
238
+ updateSince: "update_since"
239
+ };
240
+ Object.entries(finalOptions.filters).forEach(([key, value]) => {
241
+ if (value === void 0) return;
242
+ searchParams.append(filterKeyMap[key] ?? key, value);
243
+ });
217
244
  const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business?${searchParams.toString()}`;
218
- return client.get(url).then(({ data, headers }) => ({
219
- data,
220
- page: headers.number,
221
- pageSize: headers.size,
222
- total: headers.totalelements,
223
- totalPages: headers.totalpages
245
+ return client.get(url).then(({ data }) => ({
246
+ data: data.content,
247
+ page: data.number,
248
+ pageSize: data.size,
249
+ total: data.totalElements,
250
+ totalPages: data.totalPages
224
251
  }));
225
252
  };
226
253
  //#endregion
227
254
  //#region src/getBusinessInviteLink.ts
228
- const getBusinessInviteLink = async (client, businessId) => {
229
- const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
255
+ const schema$7 = zod.z.object({
256
+ businessId: zod.z.string().trim().min(1).uuid(),
257
+ email: zod.z.string().trim().email(),
258
+ firstName: zod.z.string().trim().min(1).optional(),
259
+ lastName: zod.z.string().trim().min(1).optional(),
260
+ costCenterId: zod.z.string().trim().min(1).uuid().optional()
261
+ });
262
+ const getBusinessInviteLink = async (client, businessId, params) => {
263
+ const result = schema$7.safeParse({
264
+ businessId,
265
+ ...params
266
+ });
230
267
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
231
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/user/invite/link`).then(({ data }) => data);
268
+ const { businessId: parsedId, ...queryFields } = result.data;
269
+ const searchParams = new URLSearchParams();
270
+ Object.entries(queryFields).forEach(([key, value]) => {
271
+ if (value !== void 0) searchParams.append(key, value);
272
+ });
273
+ return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId}/user/invite/link?${searchParams.toString()}`).then(({ data }) => data);
232
274
  };
233
275
  //#endregion
234
276
  //#region src/getBusinessInvoiceProducts.ts
@@ -241,23 +283,35 @@ const getBusinessInvoiceProducts = async (client, entityId, invoiceId) => {
241
283
  };
242
284
  //#endregion
243
285
  //#region src/getBusinessInvoices.ts
286
+ const invoiceFiltersSchema = zod.z.object({
287
+ fromDate: zod.z.string().trim().min(1).optional(),
288
+ toDate: zod.z.string().trim().min(1).optional()
289
+ });
244
290
  const getBusinessInvoices = async (client, entityId, options) => {
245
291
  const resultId = zod.z.string().trim().min(1).uuid().safeParse(entityId);
246
292
  if (!resultId.success) throw new TypeError("Invalid args", { cause: resultId.error.issues });
247
- const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
293
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(invoiceFiltersSchema.default({})).safeParse(options ?? {});
248
294
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
249
295
  const finalOptions = resultOptions.data;
250
296
  const searchParams = new URLSearchParams();
251
297
  searchParams.append("page", finalOptions.page.toString());
252
298
  searchParams.append("size", finalOptions.pageSize.toString());
253
299
  if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
300
+ const filterKeyMap = {
301
+ fromDate: "from_date",
302
+ toDate: "to_date"
303
+ };
304
+ Object.entries(finalOptions.filters).forEach(([key, value]) => {
305
+ if (value === void 0) return;
306
+ searchParams.append(filterKeyMap[key] ?? key, value);
307
+ });
254
308
  const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/entities/${resultId.data}/businessInvoices?${searchParams.toString()}`;
255
- return client.get(url).then(({ data, headers }) => ({
256
- data,
257
- page: headers.number,
258
- pageSize: headers.size,
259
- total: headers.totalelements,
260
- totalPages: headers.totalpages
309
+ return client.get(url).then(({ data }) => ({
310
+ data: data.content,
311
+ page: data.number,
312
+ pageSize: data.size,
313
+ total: data.totalElements,
314
+ totalPages: data.totalPages
261
315
  }));
262
316
  };
263
317
  //#endregion
@@ -306,31 +360,53 @@ const getBusinessUserGlobalById = async (client, userId) => {
306
360
  };
307
361
  //#endregion
308
362
  //#region src/getBusinessUsers.ts
363
+ const businessUserFiltersSchema = zod.z.object({
364
+ role: zod.z.string().trim().min(1).optional(),
365
+ status: zod.z.string().trim().min(1).optional()
366
+ });
309
367
  const getBusinessUsers = async (client, businessId, options) => {
310
368
  const resultId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
311
369
  if (!resultId.success) throw new TypeError("Invalid args", { cause: resultId.error.issues });
312
- const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
370
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(businessUserFiltersSchema.default({})).safeParse(options ?? {});
313
371
  if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
314
372
  const finalOptions = resultOptions.data;
315
373
  const searchParams = new URLSearchParams();
316
374
  searchParams.append("page", finalOptions.page.toString());
317
375
  searchParams.append("size", finalOptions.pageSize.toString());
318
376
  if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
377
+ Object.entries(finalOptions.filters).forEach(([key, value]) => {
378
+ if (value === void 0) return;
379
+ searchParams.append(key, value);
380
+ });
319
381
  const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${resultId.data}/user?${searchParams.toString()}`;
320
- return client.get(url).then(({ data, headers }) => ({
321
- data,
322
- page: headers.number,
323
- pageSize: headers.size,
324
- total: headers.totalelements,
325
- totalPages: headers.totalpages
382
+ return client.get(url).then(({ data }) => ({
383
+ data: data.content,
384
+ page: data.number,
385
+ pageSize: data.size,
386
+ total: data.totalElements,
387
+ totalPages: data.totalPages
326
388
  }));
327
389
  };
328
390
  //#endregion
329
391
  //#region src/getBusinessWallet.ts
330
- const getBusinessWallet = async (client, businessId) => {
392
+ const getBusinessWallet = async (client, businessId, options) => {
331
393
  const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
332
394
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
333
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/wallet`).then(({ data }) => data);
395
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
396
+ if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
397
+ const finalOptions = resultOptions.data;
398
+ const searchParams = new URLSearchParams();
399
+ searchParams.append("page", finalOptions.page.toString());
400
+ searchParams.append("size", finalOptions.pageSize.toString());
401
+ if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
402
+ const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/wallet?${searchParams.toString()}`;
403
+ return client.get(url).then(({ data }) => ({
404
+ data: data.content,
405
+ page: data.number,
406
+ pageSize: data.size,
407
+ total: data.totalElements,
408
+ totalPages: data.totalPages
409
+ }));
334
410
  };
335
411
  //#endregion
336
412
  //#region src/getEntityBalance.ts
@@ -341,24 +417,90 @@ const getEntityBalance = async (client, entityId) => {
341
417
  };
342
418
  //#endregion
343
419
  //#region src/getEntityProducts.ts
344
- const getEntityProducts = async (client, entityId) => {
345
- const result = zod.z.string().trim().min(1).uuid().safeParse(entityId);
346
- if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
347
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${result.data}/product`).then(({ data }) => data);
420
+ const entityProductFiltersSchema = zod.z.object({
421
+ period: zod.z.string().trim().min(1),
422
+ user: zod.z.string().trim().min(1).optional(),
423
+ productDetailsType: zod.z.enum([
424
+ "UNIT",
425
+ "ACCUMULATIVE",
426
+ "DEFAULT"
427
+ ]).optional()
428
+ });
429
+ const getEntityProducts = async (client, entityId, options) => {
430
+ const parsedId = zod.z.string().trim().min(1).uuid().safeParse(entityId);
431
+ if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
432
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(entityProductFiltersSchema).safeParse(options);
433
+ if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
434
+ const finalOptions = resultOptions.data;
435
+ const searchParams = new URLSearchParams();
436
+ searchParams.append("page", finalOptions.page.toString());
437
+ searchParams.append("size", finalOptions.pageSize.toString());
438
+ searchParams.append("period", finalOptions.filters.period);
439
+ if (finalOptions.filters.user) searchParams.append("user", finalOptions.filters.user);
440
+ if (finalOptions.filters.productDetailsType) searchParams.append("productDetailsType", finalOptions.filters.productDetailsType);
441
+ return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/product?${searchParams.toString()}`).then(({ data }) => ({
442
+ data: data.content,
443
+ page: data.number,
444
+ pageSize: data.size,
445
+ total: data.totalElements,
446
+ totalPages: data.totalPages
447
+ }));
348
448
  };
349
449
  //#endregion
350
450
  //#region src/getEntityTrips.ts
351
- const getEntityTrips = async (client, entityId) => {
352
- const result = zod.z.string().trim().min(1).uuid().safeParse(entityId);
353
- if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
354
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${result.data}/trip`).then(({ data }) => data);
451
+ const entityTripFiltersSchema = zod.z.object({
452
+ period: zod.z.string().trim().min(1),
453
+ costCenterIds: zod.z.array(zod.z.string().trim().min(1)).optional(),
454
+ user: zod.z.string().trim().min(1).optional()
455
+ });
456
+ const getEntityTrips = async (client, entityId, options) => {
457
+ const parsedId = zod.z.string().trim().min(1).uuid().safeParse(entityId);
458
+ if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
459
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(entityTripFiltersSchema).safeParse(options);
460
+ if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
461
+ const finalOptions = resultOptions.data;
462
+ const searchParams = new URLSearchParams();
463
+ searchParams.append("page", finalOptions.page.toString());
464
+ searchParams.append("size", finalOptions.pageSize.toString());
465
+ searchParams.append("period", finalOptions.filters.period);
466
+ if (finalOptions.filters.user) searchParams.append("user", finalOptions.filters.user);
467
+ if (finalOptions.filters.costCenterIds) finalOptions.filters.costCenterIds.forEach((id) => {
468
+ searchParams.append("costCenterIds", id);
469
+ });
470
+ return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trip?${searchParams.toString()}`).then(({ data }) => ({
471
+ data: data.content,
472
+ page: data.number,
473
+ pageSize: data.size,
474
+ total: data.totalElements,
475
+ totalPages: data.totalPages
476
+ }));
355
477
  };
356
478
  //#endregion
357
479
  //#region src/getEntityTripsCost.ts
358
- const getEntityTripsCost = async (client, entityId) => {
359
- const result = zod.z.string().trim().min(1).uuid().safeParse(entityId);
360
- if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
361
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${result.data}/trips/cost`).then(({ data }) => data);
480
+ const tripsCostFiltersSchema = zod.z.object({
481
+ startDate: zod.z.string().trim().min(1),
482
+ endDate: zod.z.string().trim().min(1),
483
+ tripId: zod.z.string().trim().min(1).optional()
484
+ });
485
+ const getEntityTripsCost = async (client, entityId, options) => {
486
+ const parsedId = zod.z.string().trim().min(1).uuid().safeParse(entityId);
487
+ if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
488
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)(tripsCostFiltersSchema).safeParse(options);
489
+ if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
490
+ const finalOptions = resultOptions.data;
491
+ const searchParams = new URLSearchParams();
492
+ searchParams.append("page", finalOptions.page.toString());
493
+ searchParams.append("size", finalOptions.pageSize.toString());
494
+ searchParams.append("startDate", finalOptions.filters.startDate);
495
+ searchParams.append("endDate", finalOptions.filters.endDate);
496
+ if (finalOptions.filters.tripId) searchParams.append("tripId", finalOptions.filters.tripId);
497
+ return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trips/cost?${searchParams.toString()}`).then(({ data }) => ({
498
+ data: data.content,
499
+ page: data.number,
500
+ pageSize: data.size,
501
+ total: data.totalElements,
502
+ totalPages: data.totalPages
503
+ }));
362
504
  };
363
505
  //#endregion
364
506
  //#region src/getInvitationRequest.ts
@@ -384,10 +526,18 @@ const getInvoiceRefundableAmount = async (client, invoiceId) => {
384
526
  };
385
527
  //#endregion
386
528
  //#region src/getInvoiceRefundNote.ts
387
- const getInvoiceRefundNote = async (client, invoiceId) => {
529
+ const getInvoiceRefundNote = async (client, invoiceId, paymentRefundPspReference) => {
388
530
  const result = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
389
531
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
390
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${result.data}/refundNote`).then(({ data }) => data);
532
+ const searchParams = new URLSearchParams();
533
+ if (paymentRefundPspReference) {
534
+ const refResult = zod.z.string().trim().min(1).safeParse(paymentRefundPspReference);
535
+ if (!refResult.success) throw new TypeError("Invalid args", { cause: refResult.error.issues });
536
+ searchParams.append("paymentRefundPspReference", refResult.data);
537
+ }
538
+ const query = searchParams.toString();
539
+ const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${result.data}/refundNote${query ? `?${query}` : ""}`;
540
+ return client.get(url).then(({ data }) => data);
391
541
  };
392
542
  //#endregion
393
543
  //#region src/getOngoingTripNotes.ts
@@ -398,8 +548,25 @@ const getOngoingTripNotes = async (client, tripId) => {
398
548
  };
399
549
  //#endregion
400
550
  //#region src/getOngoingTrips.ts
401
- const getOngoingTrips = async (client) => {
402
- return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/ongoing`).then(({ data }) => data);
551
+ const getOngoingTrips = async (client, businessId, options) => {
552
+ const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
553
+ if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
554
+ const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
555
+ if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
556
+ const finalOptions = resultOptions.data;
557
+ const searchParams = new URLSearchParams();
558
+ searchParams.append("business", parsedId.data);
559
+ searchParams.append("page", finalOptions.page.toString());
560
+ searchParams.append("size", finalOptions.pageSize.toString());
561
+ if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
562
+ const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/ongoing?${searchParams.toString()}`;
563
+ return client.get(url).then(({ data }) => ({
564
+ data: data.content,
565
+ page: data.number,
566
+ pageSize: data.size,
567
+ total: data.totalElements,
568
+ totalPages: data.totalPages
569
+ }));
403
570
  };
404
571
  //#endregion
405
572
  //#region src/getStripePublishableKey.ts
@@ -415,19 +582,26 @@ const getStripeSetup = async (client, businessId) => {
415
582
  };
416
583
  //#endregion
417
584
  //#region src/inviteBusinessUser.ts
418
- const inviteSchema = zod.z.object({
585
+ const schema$6 = zod.z.object({
419
586
  businessId: zod.z.string().trim().min(1).uuid(),
420
587
  email: zod.z.string().trim().email(),
421
- costCenterId: zod.z.string().trim().min(1).uuid().optional()
588
+ firstName: zod.z.string().trim().min(1).optional(),
589
+ lastName: zod.z.string().trim().min(1).optional(),
590
+ costCenterId: zod.z.string().trim().min(1).uuid().optional(),
591
+ locale: zod.z.string().trim().min(1).optional()
422
592
  });
423
- const inviteBusinessUser = async (client, businessId, body) => {
424
- const result = inviteSchema.safeParse({
593
+ const inviteBusinessUser = async (client, businessId, params) => {
594
+ const result = schema$6.safeParse({
425
595
  businessId,
426
- ...body
596
+ ...params
427
597
  });
428
598
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
429
- const { businessId: parsedId, ...parsedBody } = result.data;
430
- await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId}/user/invite`, parsedBody);
599
+ const { businessId: parsedId, ...queryFields } = result.data;
600
+ const searchParams = new URLSearchParams();
601
+ Object.entries(queryFields).forEach(([key, value]) => {
602
+ if (value !== void 0) searchParams.append(key, value);
603
+ });
604
+ await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId}/user/invite?${searchParams.toString()}`);
431
605
  };
432
606
  //#endregion
433
607
  //#region src/listBusinessUsersGlobal.ts
@@ -493,17 +667,17 @@ const searchBusinessUsersByName = async (client, businessId, name) => {
493
667
  });
494
668
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
495
669
  const searchParams = new URLSearchParams();
496
- searchParams.append("name", result.data.name);
670
+ searchParams.append("fullname", result.data.name);
497
671
  const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/users/name?${searchParams.toString()}`;
498
672
  return client.get(url).then(({ data }) => data);
499
673
  };
500
674
  //#endregion
501
675
  //#region src/searchBusinessUsersGlobal.ts
502
- const searchBusinessUsersGlobal = async (client, query) => {
503
- const result = zod.z.string().trim().min(1).safeParse(query);
676
+ const searchBusinessUsersGlobal = async (client, name) => {
677
+ const result = zod.z.string().trim().min(1).safeParse(name);
504
678
  if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
505
679
  const searchParams = new URLSearchParams();
506
- searchParams.append("query", result.data);
680
+ searchParams.append("name", result.data);
507
681
  const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/users/search?${searchParams.toString()}`;
508
682
  return client.get(url).then(({ data }) => data);
509
683
  };
@@ -511,7 +685,8 @@ const searchBusinessUsersGlobal = async (client, query) => {
511
685
  //#region src/sendBusinessIban.ts
512
686
  const schema$2 = zod.z.object({
513
687
  businessId: zod.z.string().trim().min(1).uuid(),
514
- iban: zod.z.string().trim().min(1)
688
+ iban: zod.z.string().trim().min(1),
689
+ entityId: zod.z.string().trim().min(1).optional()
515
690
  });
516
691
  const sendBusinessIban = async (client, businessId, body) => {
517
692
  const result = schema$2.safeParse({
@@ -525,8 +700,9 @@ const sendBusinessIban = async (client, businessId, body) => {
525
700
  //#endregion
526
701
  //#region src/setInvoiceExternalPayment.ts
527
702
  const bodySchema$2 = zod.z.object({
528
- paymentReference: zod.z.string().trim().min(1).optional(),
529
- paymentDate: zod.z.string().trim().min(1).optional()
703
+ requesterId: zod.z.string().trim().min(1),
704
+ notes: zod.z.string().trim().optional(),
705
+ paymentMethod: zod.z.string().trim().optional()
530
706
  });
531
707
  const setInvoiceExternalPayment = async (client, invoiceId, body) => {
532
708
  const parsedId = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
@@ -537,7 +713,7 @@ const setInvoiceExternalPayment = async (client, invoiceId, body) => {
537
713
  };
538
714
  //#endregion
539
715
  //#region src/updateBusiness.ts
540
- const updateBusinessBodySchema = zod.z.object({ name: zod.z.string().trim().min(1).max(255).optional() });
716
+ const updateBusinessBodySchema = zod.z.object({ name: zod.z.string().trim().min(1).max(255).optional() }).passthrough();
541
717
  const updateBusiness = async (client, businessId, body) => {
542
718
  const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
543
719
  if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
@@ -548,7 +724,10 @@ const updateBusiness = async (client, businessId, body) => {
548
724
  //#endregion
549
725
  //#region src/updateBusinessCostCenter.ts
550
726
  const uuidSchema$1 = zod.z.string().trim().min(1).uuid();
551
- const bodySchema$1 = zod.z.object({ name: zod.z.string().trim().min(1).max(255).optional() });
727
+ const bodySchema$1 = zod.z.object({
728
+ name: zod.z.string().trim().min(1).max(255).optional(),
729
+ value: zod.z.string().trim().min(1).optional()
730
+ });
552
731
  const updateBusinessCostCenter = async (client, businessId, costCenterId, body) => {
553
732
  const parsedBusinessId = uuidSchema$1.safeParse(businessId);
554
733
  const parsedCostCenterId = uuidSchema$1.safeParse(costCenterId);