@vulog/aima-business 1.2.40 → 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 +48 -48
- package/dist/index.d.cts +14 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.mjs +48 -48
- package/package.json +3 -3
- package/src/getBusinessInvoices.test.ts +7 -14
- package/src/getBusinessInvoices.ts +7 -7
- package/src/getBusinessUsers.test.ts +6 -12
- package/src/getBusinessUsers.ts +7 -7
- package/src/getBusinessWallet.test.ts +4 -9
- package/src/getBusinessWallet.ts +7 -7
- package/src/getBusinesses.test.ts +15 -38
- package/src/getBusinesses.ts +7 -7
- package/src/getEntityProducts.ts +9 -7
- package/src/getEntityTrips.ts +9 -7
- package/src/getEntityTripsCost.ts +9 -7
- package/src/getOngoingTrips.test.ts +3 -21
- package/src/getOngoingTrips.ts +7 -7
- package/src/types.ts +14 -0
package/dist/index.cjs
CHANGED
|
@@ -242,12 +242,12 @@ const getBusinesses = async (client, options) => {
|
|
|
242
242
|
searchParams.append(filterKeyMap[key] ?? key, value);
|
|
243
243
|
});
|
|
244
244
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business?${searchParams.toString()}`;
|
|
245
|
-
return client.get(url).then(({ data
|
|
246
|
-
data,
|
|
247
|
-
page:
|
|
248
|
-
pageSize:
|
|
249
|
-
total:
|
|
250
|
-
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
|
|
251
251
|
}));
|
|
252
252
|
};
|
|
253
253
|
//#endregion
|
|
@@ -306,12 +306,12 @@ const getBusinessInvoices = async (client, entityId, options) => {
|
|
|
306
306
|
searchParams.append(filterKeyMap[key] ?? key, value);
|
|
307
307
|
});
|
|
308
308
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/entities/${resultId.data}/businessInvoices?${searchParams.toString()}`;
|
|
309
|
-
return client.get(url).then(({ data
|
|
310
|
-
data,
|
|
311
|
-
page:
|
|
312
|
-
pageSize:
|
|
313
|
-
total:
|
|
314
|
-
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
|
|
315
315
|
}));
|
|
316
316
|
};
|
|
317
317
|
//#endregion
|
|
@@ -379,12 +379,12 @@ const getBusinessUsers = async (client, businessId, options) => {
|
|
|
379
379
|
searchParams.append(key, value);
|
|
380
380
|
});
|
|
381
381
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${resultId.data}/user?${searchParams.toString()}`;
|
|
382
|
-
return client.get(url).then(({ data
|
|
383
|
-
data,
|
|
384
|
-
page:
|
|
385
|
-
pageSize:
|
|
386
|
-
total:
|
|
387
|
-
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
|
|
388
388
|
}));
|
|
389
389
|
};
|
|
390
390
|
//#endregion
|
|
@@ -400,12 +400,12 @@ const getBusinessWallet = async (client, businessId, options) => {
|
|
|
400
400
|
searchParams.append("size", finalOptions.pageSize.toString());
|
|
401
401
|
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
402
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,
|
|
405
|
-
page:
|
|
406
|
-
pageSize:
|
|
407
|
-
total:
|
|
408
|
-
totalPages:
|
|
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
409
|
}));
|
|
410
410
|
};
|
|
411
411
|
//#endregion
|
|
@@ -438,12 +438,12 @@ const getEntityProducts = async (client, entityId, options) => {
|
|
|
438
438
|
searchParams.append("period", finalOptions.filters.period);
|
|
439
439
|
if (finalOptions.filters.user) searchParams.append("user", finalOptions.filters.user);
|
|
440
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,
|
|
443
|
-
page:
|
|
444
|
-
pageSize:
|
|
445
|
-
total:
|
|
446
|
-
totalPages:
|
|
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
447
|
}));
|
|
448
448
|
};
|
|
449
449
|
//#endregion
|
|
@@ -467,12 +467,12 @@ const getEntityTrips = async (client, entityId, options) => {
|
|
|
467
467
|
if (finalOptions.filters.costCenterIds) finalOptions.filters.costCenterIds.forEach((id) => {
|
|
468
468
|
searchParams.append("costCenterIds", id);
|
|
469
469
|
});
|
|
470
|
-
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trip?${searchParams.toString()}`).then(({ data
|
|
471
|
-
data,
|
|
472
|
-
page:
|
|
473
|
-
pageSize:
|
|
474
|
-
total:
|
|
475
|
-
totalPages:
|
|
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
476
|
}));
|
|
477
477
|
};
|
|
478
478
|
//#endregion
|
|
@@ -494,12 +494,12 @@ const getEntityTripsCost = async (client, entityId, options) => {
|
|
|
494
494
|
searchParams.append("startDate", finalOptions.filters.startDate);
|
|
495
495
|
searchParams.append("endDate", finalOptions.filters.endDate);
|
|
496
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,
|
|
499
|
-
page:
|
|
500
|
-
pageSize:
|
|
501
|
-
total:
|
|
502
|
-
totalPages:
|
|
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
503
|
}));
|
|
504
504
|
};
|
|
505
505
|
//#endregion
|
|
@@ -560,12 +560,12 @@ const getOngoingTrips = async (client, businessId, options) => {
|
|
|
560
560
|
searchParams.append("size", finalOptions.pageSize.toString());
|
|
561
561
|
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
562
562
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/ongoing?${searchParams.toString()}`;
|
|
563
|
-
return client.get(url).then(({ data
|
|
564
|
-
data,
|
|
565
|
-
page:
|
|
566
|
-
pageSize:
|
|
567
|
-
total:
|
|
568
|
-
totalPages:
|
|
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
569
|
}));
|
|
570
570
|
};
|
|
571
571
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -10,6 +10,19 @@ type AddBusinessCreditBody = {
|
|
|
10
10
|
declare const addBusinessCredit: (client: Client, businessId: string, body: AddBusinessCreditBody) => Promise<void>;
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/types.d.ts
|
|
13
|
+
/** Spring Page response wrapper used by the business API */
|
|
14
|
+
type SpringPage<T> = {
|
|
15
|
+
content: T[];
|
|
16
|
+
totalElements: number;
|
|
17
|
+
totalPages: number;
|
|
18
|
+
size: number;
|
|
19
|
+
number: number;
|
|
20
|
+
first: boolean;
|
|
21
|
+
last: boolean;
|
|
22
|
+
numberOfElements: number;
|
|
23
|
+
empty: boolean;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
13
26
|
/** Represents a business entity (BusinessWSDTO) */
|
|
14
27
|
type Business = {
|
|
15
28
|
/** Unique identifier */id: string; /** Fleet identifier */
|
|
@@ -548,4 +561,4 @@ declare const updateBusinessUserProfile: (client: Client, businessId: string, us
|
|
|
548
561
|
//#region src/updateInvoiceStatus.d.ts
|
|
549
562
|
declare const updateInvoiceStatus: (client: Client, invoiceId: string, status: string) => Promise<void>;
|
|
550
563
|
//#endregion
|
|
551
|
-
export { AddBusinessCreditBody, AddTripNoteBody, AddUserToBusinessBody, Business, BusinessBillingGroup, BusinessContact, BusinessFilters, BusinessInviteLink, BusinessInvoice, BusinessInvoiceFilters, BusinessPaymentDetails, BusinessProduct, BusinessTrip, BusinessUser, BusinessUserFilters, BusinessUserProfile, BusinessWallet, ChargeBusinessProductBody, CostCenter, CreateBusinessBody, CreateCostCenterBody, EntityBalance, EntityProductFilters, EntityTripFilters, EntityTripsCost, GetBusinessInviteLinkParams, InvitationRequest, InviteBusinessUserParams, InvoiceRefundNote, InvoiceRefundableAmount, ListBusinessUsersGlobalBody, RefundInvoiceBody, SendBusinessIbanBody, SetInvoiceExternalPaymentBody, StripeConfig, StripeSetup, TripNote, TripsCostFilters, UpdateBusinessBody, UpdateBusinessUserProfileBody, UpdateCostCenterBody, addBusinessCredit, addStripePayment, addTripNote, addUserToBusiness, archiveBusinessProfile, bulkAddBusinessUsers, chargeBusinessProduct, createBusiness, createBusinessCostCenter, deactivateBusinessProfile, deleteBusinessCostCenter, deleteInvitationRequest, getBusinessBillingGroups, getBusinessById, getBusinessContacts, getBusinessCostCenterById, getBusinessCostCenters, getBusinessInviteLink, getBusinessInvoiceProducts, getBusinessInvoiceTrips, getBusinessInvoices, getBusinessPaymentDetails, getBusinessProducts, getBusinessTripById, getBusinessUserById, getBusinessUserGlobalById, getBusinessUsers, getBusinessWallet, getBusinesses, getEntityBalance, getEntityProducts, getEntityTrips, getEntityTripsCost, getInvitationRequest, getInvoicePdf, getInvoiceRefundNote, getInvoiceRefundableAmount, getOngoingTripNotes, getOngoingTrips, getStripePublishableKey, getStripeSetup, inviteBusinessUser, listBusinessUsersGlobal, redeemBusinessPromoCode, refundInvoice, refundInvoiceAmount, removeBusinessOwner, removeDelegatedAdmin, searchBusinessUsersByName, searchBusinessUsersGlobal, sendBusinessIban, setBusinessOwner, setDelegatedAdmin, setInvoiceExternalPayment, updateBusiness, updateBusinessCostCenter, updateBusinessProfileStatus, updateBusinessUserProfile, updateInvoiceStatus };
|
|
564
|
+
export { AddBusinessCreditBody, AddTripNoteBody, AddUserToBusinessBody, Business, BusinessBillingGroup, BusinessContact, BusinessFilters, BusinessInviteLink, BusinessInvoice, BusinessInvoiceFilters, BusinessPaymentDetails, BusinessProduct, BusinessTrip, BusinessUser, BusinessUserFilters, BusinessUserProfile, BusinessWallet, ChargeBusinessProductBody, CostCenter, CreateBusinessBody, CreateCostCenterBody, EntityBalance, EntityProductFilters, EntityTripFilters, EntityTripsCost, GetBusinessInviteLinkParams, InvitationRequest, InviteBusinessUserParams, InvoiceRefundNote, InvoiceRefundableAmount, ListBusinessUsersGlobalBody, RefundInvoiceBody, SendBusinessIbanBody, SetInvoiceExternalPaymentBody, SpringPage, StripeConfig, StripeSetup, TripNote, TripsCostFilters, UpdateBusinessBody, UpdateBusinessUserProfileBody, UpdateCostCenterBody, addBusinessCredit, addStripePayment, addTripNote, addUserToBusiness, archiveBusinessProfile, bulkAddBusinessUsers, chargeBusinessProduct, createBusiness, createBusinessCostCenter, deactivateBusinessProfile, deleteBusinessCostCenter, deleteInvitationRequest, getBusinessBillingGroups, getBusinessById, getBusinessContacts, getBusinessCostCenterById, getBusinessCostCenters, getBusinessInviteLink, getBusinessInvoiceProducts, getBusinessInvoiceTrips, getBusinessInvoices, getBusinessPaymentDetails, getBusinessProducts, getBusinessTripById, getBusinessUserById, getBusinessUserGlobalById, getBusinessUsers, getBusinessWallet, getBusinesses, getEntityBalance, getEntityProducts, getEntityTrips, getEntityTripsCost, getInvitationRequest, getInvoicePdf, getInvoiceRefundNote, getInvoiceRefundableAmount, getOngoingTripNotes, getOngoingTrips, getStripePublishableKey, getStripeSetup, inviteBusinessUser, listBusinessUsersGlobal, redeemBusinessPromoCode, refundInvoice, refundInvoiceAmount, removeBusinessOwner, removeDelegatedAdmin, searchBusinessUsersByName, searchBusinessUsersGlobal, sendBusinessIban, setBusinessOwner, setDelegatedAdmin, setInvoiceExternalPayment, updateBusiness, updateBusinessCostCenter, updateBusinessProfileStatus, updateBusinessUserProfile, updateInvoiceStatus };
|
package/dist/index.d.mts
CHANGED
|
@@ -10,6 +10,19 @@ type AddBusinessCreditBody = {
|
|
|
10
10
|
declare const addBusinessCredit: (client: Client, businessId: string, body: AddBusinessCreditBody) => Promise<void>;
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/types.d.ts
|
|
13
|
+
/** Spring Page response wrapper used by the business API */
|
|
14
|
+
type SpringPage<T> = {
|
|
15
|
+
content: T[];
|
|
16
|
+
totalElements: number;
|
|
17
|
+
totalPages: number;
|
|
18
|
+
size: number;
|
|
19
|
+
number: number;
|
|
20
|
+
first: boolean;
|
|
21
|
+
last: boolean;
|
|
22
|
+
numberOfElements: number;
|
|
23
|
+
empty: boolean;
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
};
|
|
13
26
|
/** Represents a business entity (BusinessWSDTO) */
|
|
14
27
|
type Business = {
|
|
15
28
|
/** Unique identifier */id: string; /** Fleet identifier */
|
|
@@ -548,4 +561,4 @@ declare const updateBusinessUserProfile: (client: Client, businessId: string, us
|
|
|
548
561
|
//#region src/updateInvoiceStatus.d.ts
|
|
549
562
|
declare const updateInvoiceStatus: (client: Client, invoiceId: string, status: string) => Promise<void>;
|
|
550
563
|
//#endregion
|
|
551
|
-
export { AddBusinessCreditBody, AddTripNoteBody, AddUserToBusinessBody, Business, BusinessBillingGroup, BusinessContact, BusinessFilters, BusinessInviteLink, BusinessInvoice, BusinessInvoiceFilters, BusinessPaymentDetails, BusinessProduct, BusinessTrip, BusinessUser, BusinessUserFilters, BusinessUserProfile, BusinessWallet, ChargeBusinessProductBody, CostCenter, CreateBusinessBody, CreateCostCenterBody, EntityBalance, EntityProductFilters, EntityTripFilters, EntityTripsCost, GetBusinessInviteLinkParams, InvitationRequest, InviteBusinessUserParams, InvoiceRefundNote, InvoiceRefundableAmount, ListBusinessUsersGlobalBody, RefundInvoiceBody, SendBusinessIbanBody, SetInvoiceExternalPaymentBody, StripeConfig, StripeSetup, TripNote, TripsCostFilters, UpdateBusinessBody, UpdateBusinessUserProfileBody, UpdateCostCenterBody, addBusinessCredit, addStripePayment, addTripNote, addUserToBusiness, archiveBusinessProfile, bulkAddBusinessUsers, chargeBusinessProduct, createBusiness, createBusinessCostCenter, deactivateBusinessProfile, deleteBusinessCostCenter, deleteInvitationRequest, getBusinessBillingGroups, getBusinessById, getBusinessContacts, getBusinessCostCenterById, getBusinessCostCenters, getBusinessInviteLink, getBusinessInvoiceProducts, getBusinessInvoiceTrips, getBusinessInvoices, getBusinessPaymentDetails, getBusinessProducts, getBusinessTripById, getBusinessUserById, getBusinessUserGlobalById, getBusinessUsers, getBusinessWallet, getBusinesses, getEntityBalance, getEntityProducts, getEntityTrips, getEntityTripsCost, getInvitationRequest, getInvoicePdf, getInvoiceRefundNote, getInvoiceRefundableAmount, getOngoingTripNotes, getOngoingTrips, getStripePublishableKey, getStripeSetup, inviteBusinessUser, listBusinessUsersGlobal, redeemBusinessPromoCode, refundInvoice, refundInvoiceAmount, removeBusinessOwner, removeDelegatedAdmin, searchBusinessUsersByName, searchBusinessUsersGlobal, sendBusinessIban, setBusinessOwner, setDelegatedAdmin, setInvoiceExternalPayment, updateBusiness, updateBusinessCostCenter, updateBusinessProfileStatus, updateBusinessUserProfile, updateInvoiceStatus };
|
|
564
|
+
export { AddBusinessCreditBody, AddTripNoteBody, AddUserToBusinessBody, Business, BusinessBillingGroup, BusinessContact, BusinessFilters, BusinessInviteLink, BusinessInvoice, BusinessInvoiceFilters, BusinessPaymentDetails, BusinessProduct, BusinessTrip, BusinessUser, BusinessUserFilters, BusinessUserProfile, BusinessWallet, ChargeBusinessProductBody, CostCenter, CreateBusinessBody, CreateCostCenterBody, EntityBalance, EntityProductFilters, EntityTripFilters, EntityTripsCost, GetBusinessInviteLinkParams, InvitationRequest, InviteBusinessUserParams, InvoiceRefundNote, InvoiceRefundableAmount, ListBusinessUsersGlobalBody, RefundInvoiceBody, SendBusinessIbanBody, SetInvoiceExternalPaymentBody, SpringPage, StripeConfig, StripeSetup, TripNote, TripsCostFilters, UpdateBusinessBody, UpdateBusinessUserProfileBody, UpdateCostCenterBody, addBusinessCredit, addStripePayment, addTripNote, addUserToBusiness, archiveBusinessProfile, bulkAddBusinessUsers, chargeBusinessProduct, createBusiness, createBusinessCostCenter, deactivateBusinessProfile, deleteBusinessCostCenter, deleteInvitationRequest, getBusinessBillingGroups, getBusinessById, getBusinessContacts, getBusinessCostCenterById, getBusinessCostCenters, getBusinessInviteLink, getBusinessInvoiceProducts, getBusinessInvoiceTrips, getBusinessInvoices, getBusinessPaymentDetails, getBusinessProducts, getBusinessTripById, getBusinessUserById, getBusinessUserGlobalById, getBusinessUsers, getBusinessWallet, getBusinesses, getEntityBalance, getEntityProducts, getEntityTrips, getEntityTripsCost, getInvitationRequest, getInvoicePdf, getInvoiceRefundNote, getInvoiceRefundableAmount, getOngoingTripNotes, getOngoingTrips, getStripePublishableKey, getStripeSetup, inviteBusinessUser, listBusinessUsersGlobal, redeemBusinessPromoCode, refundInvoice, refundInvoiceAmount, removeBusinessOwner, removeDelegatedAdmin, searchBusinessUsersByName, searchBusinessUsersGlobal, sendBusinessIban, setBusinessOwner, setDelegatedAdmin, setInvoiceExternalPayment, updateBusiness, updateBusinessCostCenter, updateBusinessProfileStatus, updateBusinessUserProfile, updateInvoiceStatus };
|
package/dist/index.mjs
CHANGED
|
@@ -241,12 +241,12 @@ const getBusinesses = async (client, options) => {
|
|
|
241
241
|
searchParams.append(filterKeyMap[key] ?? key, value);
|
|
242
242
|
});
|
|
243
243
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business?${searchParams.toString()}`;
|
|
244
|
-
return client.get(url).then(({ data
|
|
245
|
-
data,
|
|
246
|
-
page:
|
|
247
|
-
pageSize:
|
|
248
|
-
total:
|
|
249
|
-
totalPages:
|
|
244
|
+
return client.get(url).then(({ data }) => ({
|
|
245
|
+
data: data.content,
|
|
246
|
+
page: data.number,
|
|
247
|
+
pageSize: data.size,
|
|
248
|
+
total: data.totalElements,
|
|
249
|
+
totalPages: data.totalPages
|
|
250
250
|
}));
|
|
251
251
|
};
|
|
252
252
|
//#endregion
|
|
@@ -305,12 +305,12 @@ const getBusinessInvoices = async (client, entityId, options) => {
|
|
|
305
305
|
searchParams.append(filterKeyMap[key] ?? key, value);
|
|
306
306
|
});
|
|
307
307
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/entities/${resultId.data}/businessInvoices?${searchParams.toString()}`;
|
|
308
|
-
return client.get(url).then(({ data
|
|
309
|
-
data,
|
|
310
|
-
page:
|
|
311
|
-
pageSize:
|
|
312
|
-
total:
|
|
313
|
-
totalPages:
|
|
308
|
+
return client.get(url).then(({ data }) => ({
|
|
309
|
+
data: data.content,
|
|
310
|
+
page: data.number,
|
|
311
|
+
pageSize: data.size,
|
|
312
|
+
total: data.totalElements,
|
|
313
|
+
totalPages: data.totalPages
|
|
314
314
|
}));
|
|
315
315
|
};
|
|
316
316
|
//#endregion
|
|
@@ -378,12 +378,12 @@ const getBusinessUsers = async (client, businessId, options) => {
|
|
|
378
378
|
searchParams.append(key, value);
|
|
379
379
|
});
|
|
380
380
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${resultId.data}/user?${searchParams.toString()}`;
|
|
381
|
-
return client.get(url).then(({ data
|
|
382
|
-
data,
|
|
383
|
-
page:
|
|
384
|
-
pageSize:
|
|
385
|
-
total:
|
|
386
|
-
totalPages:
|
|
381
|
+
return client.get(url).then(({ data }) => ({
|
|
382
|
+
data: data.content,
|
|
383
|
+
page: data.number,
|
|
384
|
+
pageSize: data.size,
|
|
385
|
+
total: data.totalElements,
|
|
386
|
+
totalPages: data.totalPages
|
|
387
387
|
}));
|
|
388
388
|
};
|
|
389
389
|
//#endregion
|
|
@@ -399,12 +399,12 @@ const getBusinessWallet = async (client, businessId, options) => {
|
|
|
399
399
|
searchParams.append("size", finalOptions.pageSize.toString());
|
|
400
400
|
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
401
401
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/wallet?${searchParams.toString()}`;
|
|
402
|
-
return client.get(url).then(({ data
|
|
403
|
-
data,
|
|
404
|
-
page:
|
|
405
|
-
pageSize:
|
|
406
|
-
total:
|
|
407
|
-
totalPages:
|
|
402
|
+
return client.get(url).then(({ data }) => ({
|
|
403
|
+
data: data.content,
|
|
404
|
+
page: data.number,
|
|
405
|
+
pageSize: data.size,
|
|
406
|
+
total: data.totalElements,
|
|
407
|
+
totalPages: data.totalPages
|
|
408
408
|
}));
|
|
409
409
|
};
|
|
410
410
|
//#endregion
|
|
@@ -437,12 +437,12 @@ const getEntityProducts = async (client, entityId, options) => {
|
|
|
437
437
|
searchParams.append("period", finalOptions.filters.period);
|
|
438
438
|
if (finalOptions.filters.user) searchParams.append("user", finalOptions.filters.user);
|
|
439
439
|
if (finalOptions.filters.productDetailsType) searchParams.append("productDetailsType", finalOptions.filters.productDetailsType);
|
|
440
|
-
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/product?${searchParams.toString()}`).then(({ data
|
|
441
|
-
data,
|
|
442
|
-
page:
|
|
443
|
-
pageSize:
|
|
444
|
-
total:
|
|
445
|
-
totalPages:
|
|
440
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/product?${searchParams.toString()}`).then(({ data }) => ({
|
|
441
|
+
data: data.content,
|
|
442
|
+
page: data.number,
|
|
443
|
+
pageSize: data.size,
|
|
444
|
+
total: data.totalElements,
|
|
445
|
+
totalPages: data.totalPages
|
|
446
446
|
}));
|
|
447
447
|
};
|
|
448
448
|
//#endregion
|
|
@@ -466,12 +466,12 @@ const getEntityTrips = async (client, entityId, options) => {
|
|
|
466
466
|
if (finalOptions.filters.costCenterIds) finalOptions.filters.costCenterIds.forEach((id) => {
|
|
467
467
|
searchParams.append("costCenterIds", id);
|
|
468
468
|
});
|
|
469
|
-
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trip?${searchParams.toString()}`).then(({ data
|
|
470
|
-
data,
|
|
471
|
-
page:
|
|
472
|
-
pageSize:
|
|
473
|
-
total:
|
|
474
|
-
totalPages:
|
|
469
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trip?${searchParams.toString()}`).then(({ data }) => ({
|
|
470
|
+
data: data.content,
|
|
471
|
+
page: data.number,
|
|
472
|
+
pageSize: data.size,
|
|
473
|
+
total: data.totalElements,
|
|
474
|
+
totalPages: data.totalPages
|
|
475
475
|
}));
|
|
476
476
|
};
|
|
477
477
|
//#endregion
|
|
@@ -493,12 +493,12 @@ const getEntityTripsCost = async (client, entityId, options) => {
|
|
|
493
493
|
searchParams.append("startDate", finalOptions.filters.startDate);
|
|
494
494
|
searchParams.append("endDate", finalOptions.filters.endDate);
|
|
495
495
|
if (finalOptions.filters.tripId) searchParams.append("tripId", finalOptions.filters.tripId);
|
|
496
|
-
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trips/cost?${searchParams.toString()}`).then(({ data
|
|
497
|
-
data,
|
|
498
|
-
page:
|
|
499
|
-
pageSize:
|
|
500
|
-
total:
|
|
501
|
-
totalPages:
|
|
496
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trips/cost?${searchParams.toString()}`).then(({ data }) => ({
|
|
497
|
+
data: data.content,
|
|
498
|
+
page: data.number,
|
|
499
|
+
pageSize: data.size,
|
|
500
|
+
total: data.totalElements,
|
|
501
|
+
totalPages: data.totalPages
|
|
502
502
|
}));
|
|
503
503
|
};
|
|
504
504
|
//#endregion
|
|
@@ -559,12 +559,12 @@ const getOngoingTrips = async (client, businessId, options) => {
|
|
|
559
559
|
searchParams.append("size", finalOptions.pageSize.toString());
|
|
560
560
|
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
561
561
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/ongoing?${searchParams.toString()}`;
|
|
562
|
-
return client.get(url).then(({ data
|
|
563
|
-
data,
|
|
564
|
-
page:
|
|
565
|
-
pageSize:
|
|
566
|
-
total:
|
|
567
|
-
totalPages:
|
|
562
|
+
return client.get(url).then(({ data }) => ({
|
|
563
|
+
data: data.content,
|
|
564
|
+
page: data.number,
|
|
565
|
+
pageSize: data.size,
|
|
566
|
+
total: data.totalElements,
|
|
567
|
+
totalPages: data.totalPages
|
|
568
568
|
}));
|
|
569
569
|
};
|
|
570
570
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-business",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.41",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.cts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"author": "Vulog",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@vulog/aima-client": "1.2.
|
|
36
|
-
"@vulog/aima-core": "1.2.
|
|
35
|
+
"@vulog/aima-client": "1.2.41",
|
|
36
|
+
"@vulog/aima-core": "1.2.41"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"zod": "^4.3.6"
|
|
@@ -21,8 +21,7 @@ describe('getBusinessInvoices', () => {
|
|
|
21
21
|
{ id: 'inv-2', amount: 200, status: 'PENDING' },
|
|
22
22
|
];
|
|
23
23
|
getMock.mockResolvedValueOnce({
|
|
24
|
-
data: mockInvoices,
|
|
25
|
-
headers: { number: 0, size: 100, totalelements: 2, totalpages: 1 },
|
|
24
|
+
data: { content: mockInvoices, number: 0, size: 100, totalElements: 2, totalPages: 1 },
|
|
26
25
|
});
|
|
27
26
|
|
|
28
27
|
const result = await getBusinessInvoices(client, entityId);
|
|
@@ -41,8 +40,7 @@ describe('getBusinessInvoices', () => {
|
|
|
41
40
|
|
|
42
41
|
test('should pass custom pagination options', async () => {
|
|
43
42
|
getMock.mockResolvedValueOnce({
|
|
44
|
-
data: [],
|
|
45
|
-
headers: { number: 2, size: 25, totalelements: 0, totalpages: 0 },
|
|
43
|
+
data: { content: [], number: 2, size: 25, totalElements: 0, totalPages: 0 },
|
|
46
44
|
});
|
|
47
45
|
|
|
48
46
|
await getBusinessInvoices(client, entityId, { page: 2, pageSize: 25, sort: 'amount', sortDirection: 'DESC' });
|
|
@@ -55,8 +53,7 @@ describe('getBusinessInvoices', () => {
|
|
|
55
53
|
|
|
56
54
|
test('should append fromDate filter as from_date param', async () => {
|
|
57
55
|
getMock.mockResolvedValueOnce({
|
|
58
|
-
data: [],
|
|
59
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
56
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
60
57
|
});
|
|
61
58
|
|
|
62
59
|
await getBusinessInvoices(client, entityId, { filters: { fromDate: '2024-01-01' } });
|
|
@@ -68,8 +65,7 @@ describe('getBusinessInvoices', () => {
|
|
|
68
65
|
|
|
69
66
|
test('should append toDate filter as to_date param', async () => {
|
|
70
67
|
getMock.mockResolvedValueOnce({
|
|
71
|
-
data: [],
|
|
72
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
68
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
73
69
|
});
|
|
74
70
|
|
|
75
71
|
await getBusinessInvoices(client, entityId, { filters: { toDate: '2024-12-31' } });
|
|
@@ -81,8 +77,7 @@ describe('getBusinessInvoices', () => {
|
|
|
81
77
|
|
|
82
78
|
test('should append both date filters', async () => {
|
|
83
79
|
getMock.mockResolvedValueOnce({
|
|
84
|
-
data: [],
|
|
85
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
80
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
86
81
|
});
|
|
87
82
|
|
|
88
83
|
await getBusinessInvoices(client, entityId, {
|
|
@@ -97,8 +92,7 @@ describe('getBusinessInvoices', () => {
|
|
|
97
92
|
|
|
98
93
|
test('should not append undefined filters', async () => {
|
|
99
94
|
getMock.mockResolvedValueOnce({
|
|
100
|
-
data: [],
|
|
101
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
95
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
102
96
|
});
|
|
103
97
|
|
|
104
98
|
await getBusinessInvoices(client, entityId, { filters: { fromDate: '2024-01-01' } });
|
|
@@ -111,8 +105,7 @@ describe('getBusinessInvoices', () => {
|
|
|
111
105
|
|
|
112
106
|
test('should handle empty response', async () => {
|
|
113
107
|
getMock.mockResolvedValueOnce({
|
|
114
|
-
data: [],
|
|
115
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
108
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
116
109
|
});
|
|
117
110
|
|
|
118
111
|
const result = await getBusinessInvoices(client, entityId);
|
|
@@ -2,7 +2,7 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { BusinessInvoice } from './types';
|
|
5
|
+
import { BusinessInvoice, SpringPage } from './types';
|
|
6
6
|
|
|
7
7
|
const invoiceFiltersSchema = z.object({
|
|
8
8
|
fromDate: z.string().trim().min(1).optional(),
|
|
@@ -52,11 +52,11 @@ export const getBusinessInvoices = async (
|
|
|
52
52
|
|
|
53
53
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/entities/${resultId.data}/businessInvoices?${searchParams.toString()}`;
|
|
54
54
|
|
|
55
|
-
return client.get<BusinessInvoice
|
|
56
|
-
data,
|
|
57
|
-
page:
|
|
58
|
-
pageSize:
|
|
59
|
-
total:
|
|
60
|
-
totalPages:
|
|
55
|
+
return client.get<SpringPage<BusinessInvoice>>(url).then(({ data }) => ({
|
|
56
|
+
data: data.content,
|
|
57
|
+
page: data.number,
|
|
58
|
+
pageSize: data.size,
|
|
59
|
+
total: data.totalElements,
|
|
60
|
+
totalPages: data.totalPages,
|
|
61
61
|
}));
|
|
62
62
|
};
|
|
@@ -21,8 +21,7 @@ describe('getBusinessUsers', () => {
|
|
|
21
21
|
{ userId: 'u2', businessId, role: 'ADMIN' },
|
|
22
22
|
];
|
|
23
23
|
getMock.mockResolvedValueOnce({
|
|
24
|
-
data: mockUsers,
|
|
25
|
-
headers: { number: 0, size: 100, totalelements: 2, totalpages: 1 },
|
|
24
|
+
data: { content: mockUsers, number: 0, size: 100, totalElements: 2, totalPages: 1 },
|
|
26
25
|
});
|
|
27
26
|
|
|
28
27
|
const result = await getBusinessUsers(client, businessId);
|
|
@@ -41,8 +40,7 @@ describe('getBusinessUsers', () => {
|
|
|
41
40
|
|
|
42
41
|
test('should pass custom pagination options', async () => {
|
|
43
42
|
getMock.mockResolvedValueOnce({
|
|
44
|
-
data: [],
|
|
45
|
-
headers: { number: 2, size: 25, totalelements: 0, totalpages: 0 },
|
|
43
|
+
data: { content: [], number: 2, size: 25, totalElements: 0, totalPages: 0 },
|
|
46
44
|
});
|
|
47
45
|
|
|
48
46
|
await getBusinessUsers(client, businessId, { page: 2, pageSize: 25, sort: 'userId', sortDirection: 'DESC' });
|
|
@@ -55,8 +53,7 @@ describe('getBusinessUsers', () => {
|
|
|
55
53
|
|
|
56
54
|
test('should append role filter to search params', async () => {
|
|
57
55
|
getMock.mockResolvedValueOnce({
|
|
58
|
-
data: [],
|
|
59
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
56
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
60
57
|
});
|
|
61
58
|
|
|
62
59
|
await getBusinessUsers(client, businessId, { filters: { role: 'ADMIN' } });
|
|
@@ -68,8 +65,7 @@ describe('getBusinessUsers', () => {
|
|
|
68
65
|
|
|
69
66
|
test('should append status filter to search params', async () => {
|
|
70
67
|
getMock.mockResolvedValueOnce({
|
|
71
|
-
data: [],
|
|
72
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
68
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
73
69
|
});
|
|
74
70
|
|
|
75
71
|
await getBusinessUsers(client, businessId, { filters: { status: 'ACTIVE' } });
|
|
@@ -81,8 +77,7 @@ describe('getBusinessUsers', () => {
|
|
|
81
77
|
|
|
82
78
|
test('should append multiple filters to search params', async () => {
|
|
83
79
|
getMock.mockResolvedValueOnce({
|
|
84
|
-
data: [],
|
|
85
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
80
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
86
81
|
});
|
|
87
82
|
|
|
88
83
|
await getBusinessUsers(client, businessId, { filters: { role: 'ADMIN', status: 'ACTIVE' } });
|
|
@@ -95,8 +90,7 @@ describe('getBusinessUsers', () => {
|
|
|
95
90
|
|
|
96
91
|
test('should not append undefined filters', async () => {
|
|
97
92
|
getMock.mockResolvedValueOnce({
|
|
98
|
-
data: [],
|
|
99
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
93
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
100
94
|
});
|
|
101
95
|
|
|
102
96
|
await getBusinessUsers(client, businessId, { filters: { role: 'ADMIN' } });
|
package/src/getBusinessUsers.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { BusinessUser } from './types';
|
|
5
|
+
import { BusinessUser, SpringPage } from './types';
|
|
6
6
|
|
|
7
7
|
const businessUserFiltersSchema = z.object({
|
|
8
8
|
role: z.string().trim().min(1).optional(),
|
|
@@ -47,11 +47,11 @@ export const getBusinessUsers = async (
|
|
|
47
47
|
|
|
48
48
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${resultId.data}/user?${searchParams.toString()}`;
|
|
49
49
|
|
|
50
|
-
return client.get<BusinessUser
|
|
51
|
-
data,
|
|
52
|
-
page:
|
|
53
|
-
pageSize:
|
|
54
|
-
total:
|
|
55
|
-
totalPages:
|
|
50
|
+
return client.get<SpringPage<BusinessUser>>(url).then(({ data }) => ({
|
|
51
|
+
data: data.content,
|
|
52
|
+
page: data.number,
|
|
53
|
+
pageSize: data.size,
|
|
54
|
+
total: data.totalElements,
|
|
55
|
+
totalPages: data.totalPages,
|
|
56
56
|
}));
|
|
57
57
|
};
|
|
@@ -22,14 +22,10 @@ describe('getBusinessWallet', () => {
|
|
|
22
22
|
{ balance: 1000, currency: 'EUR' },
|
|
23
23
|
{ balance: 500, currency: 'USD' },
|
|
24
24
|
];
|
|
25
|
-
const mockHeaders = {
|
|
26
|
-
number: 0,
|
|
27
|
-
size: 100,
|
|
28
|
-
totalelements: 2,
|
|
29
|
-
totalpages: 1,
|
|
30
|
-
};
|
|
31
25
|
|
|
32
|
-
getMock.mockResolvedValueOnce({
|
|
26
|
+
getMock.mockResolvedValueOnce({
|
|
27
|
+
data: { content: mockData, number: 0, size: 100, totalElements: 2, totalPages: 1 },
|
|
28
|
+
});
|
|
33
29
|
|
|
34
30
|
const result = await getBusinessWallet(client, BUSINESS_ID);
|
|
35
31
|
|
|
@@ -50,8 +46,7 @@ describe('getBusinessWallet', () => {
|
|
|
50
46
|
|
|
51
47
|
test('should pass custom pagination options', async () => {
|
|
52
48
|
getMock.mockResolvedValueOnce({
|
|
53
|
-
data: [],
|
|
54
|
-
headers: { number: 1, size: 50, totalelements: 0, totalpages: 0 },
|
|
49
|
+
data: { content: [], number: 1, size: 50, totalElements: 0, totalPages: 0 },
|
|
55
50
|
});
|
|
56
51
|
|
|
57
52
|
await getBusinessWallet(client, BUSINESS_ID, { page: 1, pageSize: 50, sort: 'balance', sortDirection: 'DESC' });
|
package/src/getBusinessWallet.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { BusinessWallet } from './types';
|
|
5
|
+
import { BusinessWallet, SpringPage } from './types';
|
|
6
6
|
|
|
7
7
|
export const getBusinessWallet = async (
|
|
8
8
|
client: Client,
|
|
@@ -33,11 +33,11 @@ export const getBusinessWallet = async (
|
|
|
33
33
|
|
|
34
34
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/wallet?${searchParams.toString()}`;
|
|
35
35
|
|
|
36
|
-
return client.get<BusinessWallet
|
|
37
|
-
data,
|
|
38
|
-
page:
|
|
39
|
-
pageSize:
|
|
40
|
-
total:
|
|
41
|
-
totalPages:
|
|
36
|
+
return client.get<SpringPage<BusinessWallet>>(url).then(({ data }) => ({
|
|
37
|
+
data: data.content,
|
|
38
|
+
page: data.number,
|
|
39
|
+
pageSize: data.size,
|
|
40
|
+
total: data.totalElements,
|
|
41
|
+
totalPages: data.totalPages,
|
|
42
42
|
}));
|
|
43
43
|
};
|
|
@@ -22,16 +22,10 @@ describe('getBusinesses', () => {
|
|
|
22
22
|
{ id: 'id-2', name: 'Business Two', status: 'INACTIVE' },
|
|
23
23
|
];
|
|
24
24
|
|
|
25
|
-
const mockHeaders = {
|
|
26
|
-
number: 0,
|
|
27
|
-
size: 100,
|
|
28
|
-
totalelements: 2,
|
|
29
|
-
totalpages: 1,
|
|
30
|
-
};
|
|
31
25
|
|
|
32
26
|
getMock.mockResolvedValueOnce({
|
|
33
|
-
data: mockData,
|
|
34
|
-
|
|
27
|
+
data: { content: mockData, number: 0, size: 100, totalElements: 2, totalPages: 1 },
|
|
28
|
+
|
|
35
29
|
});
|
|
36
30
|
|
|
37
31
|
const result = await getBusinesses(client);
|
|
@@ -59,16 +53,10 @@ describe('getBusinesses', () => {
|
|
|
59
53
|
{ id: 'id-1', name: 'Business One', status: 'ACTIVE' },
|
|
60
54
|
];
|
|
61
55
|
|
|
62
|
-
const mockHeaders = {
|
|
63
|
-
number: 1,
|
|
64
|
-
size: 50,
|
|
65
|
-
totalelements: 10,
|
|
66
|
-
totalpages: 2,
|
|
67
|
-
};
|
|
68
56
|
|
|
69
57
|
getMock.mockResolvedValueOnce({
|
|
70
|
-
data: mockData,
|
|
71
|
-
|
|
58
|
+
data: { content: mockData, number: 0, size: 100, totalElements: 2, totalPages: 1 },
|
|
59
|
+
|
|
72
60
|
});
|
|
73
61
|
|
|
74
62
|
const options = {
|
|
@@ -82,10 +70,10 @@ describe('getBusinesses', () => {
|
|
|
82
70
|
|
|
83
71
|
expect(result).toEqual({
|
|
84
72
|
data: mockData,
|
|
85
|
-
page:
|
|
86
|
-
pageSize:
|
|
87
|
-
total:
|
|
88
|
-
totalPages:
|
|
73
|
+
page: 0,
|
|
74
|
+
pageSize: 100,
|
|
75
|
+
total: 2,
|
|
76
|
+
totalPages: 1,
|
|
89
77
|
});
|
|
90
78
|
|
|
91
79
|
const calledUrl = getMock.mock.calls[0][0];
|
|
@@ -96,16 +84,10 @@ describe('getBusinesses', () => {
|
|
|
96
84
|
});
|
|
97
85
|
|
|
98
86
|
test('should handle empty response', async () => {
|
|
99
|
-
const mockHeaders = {
|
|
100
|
-
number: 0,
|
|
101
|
-
size: 100,
|
|
102
|
-
totalelements: 0,
|
|
103
|
-
totalpages: 0,
|
|
104
|
-
};
|
|
105
87
|
|
|
106
88
|
getMock.mockResolvedValueOnce({
|
|
107
|
-
data: [],
|
|
108
|
-
|
|
89
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
90
|
+
|
|
109
91
|
});
|
|
110
92
|
|
|
111
93
|
const result = await getBusinesses(client);
|
|
@@ -121,8 +103,7 @@ describe('getBusinesses', () => {
|
|
|
121
103
|
|
|
122
104
|
test('should append name filter to search params', async () => {
|
|
123
105
|
getMock.mockResolvedValueOnce({
|
|
124
|
-
data: [],
|
|
125
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
106
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
126
107
|
});
|
|
127
108
|
|
|
128
109
|
await getBusinesses(client, { filters: { name: 'Acme' } });
|
|
@@ -134,8 +115,7 @@ describe('getBusinesses', () => {
|
|
|
134
115
|
|
|
135
116
|
test('should append status filter to search params', async () => {
|
|
136
117
|
getMock.mockResolvedValueOnce({
|
|
137
|
-
data: [],
|
|
138
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
118
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
139
119
|
});
|
|
140
120
|
|
|
141
121
|
await getBusinesses(client, { filters: { status: 'ACTIVE' } });
|
|
@@ -147,8 +127,7 @@ describe('getBusinesses', () => {
|
|
|
147
127
|
|
|
148
128
|
test('should append update_since filter to search params', async () => {
|
|
149
129
|
getMock.mockResolvedValueOnce({
|
|
150
|
-
data: [],
|
|
151
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
130
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
152
131
|
});
|
|
153
132
|
|
|
154
133
|
await getBusinesses(client, { filters: { updateSince: '2024-01-01' } });
|
|
@@ -160,8 +139,7 @@ describe('getBusinesses', () => {
|
|
|
160
139
|
|
|
161
140
|
test('should append multiple filters to search params', async () => {
|
|
162
141
|
getMock.mockResolvedValueOnce({
|
|
163
|
-
data: [],
|
|
164
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
142
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
165
143
|
});
|
|
166
144
|
|
|
167
145
|
await getBusinesses(client, {
|
|
@@ -177,8 +155,7 @@ describe('getBusinesses', () => {
|
|
|
177
155
|
|
|
178
156
|
test('should not append undefined filters', async () => {
|
|
179
157
|
getMock.mockResolvedValueOnce({
|
|
180
|
-
data: [],
|
|
181
|
-
headers: { number: 0, size: 100, totalelements: 0, totalpages: 0 },
|
|
158
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
182
159
|
});
|
|
183
160
|
|
|
184
161
|
await getBusinesses(client, { filters: { name: 'Acme' } });
|
package/src/getBusinesses.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { Business } from './types';
|
|
5
|
+
import { Business, SpringPage } from './types';
|
|
6
6
|
|
|
7
7
|
const businessFiltersSchema = z.object({
|
|
8
8
|
name: z.string().trim().min(1).optional(),
|
|
@@ -48,11 +48,11 @@ export const getBusinesses = async (
|
|
|
48
48
|
|
|
49
49
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business?${searchParams.toString()}`;
|
|
50
50
|
|
|
51
|
-
return client.get<Business
|
|
52
|
-
data,
|
|
53
|
-
page:
|
|
54
|
-
pageSize:
|
|
55
|
-
total:
|
|
56
|
-
totalPages:
|
|
51
|
+
return client.get<SpringPage<Business>>(url).then(({ data }) => ({
|
|
52
|
+
data: data.content,
|
|
53
|
+
page: data.number,
|
|
54
|
+
pageSize: data.size,
|
|
55
|
+
total: data.totalElements,
|
|
56
|
+
totalPages: data.totalPages,
|
|
57
57
|
}));
|
|
58
58
|
};
|
package/src/getEntityProducts.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
+
import { SpringPage } from './types';
|
|
6
|
+
|
|
5
7
|
const entityProductFiltersSchema = z.object({
|
|
6
8
|
period: z.string().trim().min(1),
|
|
7
9
|
user: z.string().trim().min(1).optional(),
|
|
@@ -40,13 +42,13 @@ export const getEntityProducts = async (
|
|
|
40
42
|
|
|
41
43
|
return client
|
|
42
44
|
.get<
|
|
43
|
-
any
|
|
45
|
+
SpringPage<any>
|
|
44
46
|
>(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/product?${searchParams.toString()}`)
|
|
45
|
-
.then(({ data
|
|
46
|
-
data,
|
|
47
|
-
page:
|
|
48
|
-
pageSize:
|
|
49
|
-
total:
|
|
50
|
-
totalPages:
|
|
47
|
+
.then(({ data }) => ({
|
|
48
|
+
data: data.content,
|
|
49
|
+
page: data.number,
|
|
50
|
+
pageSize: data.size,
|
|
51
|
+
total: data.totalElements,
|
|
52
|
+
totalPages: data.totalPages,
|
|
51
53
|
}));
|
|
52
54
|
};
|
package/src/getEntityTrips.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
+
import { SpringPage } from './types';
|
|
6
|
+
|
|
5
7
|
const entityTripFiltersSchema = z.object({
|
|
6
8
|
period: z.string().trim().min(1),
|
|
7
9
|
costCenterIds: z.array(z.string().trim().min(1)).optional(),
|
|
@@ -42,13 +44,13 @@ export const getEntityTrips = async (
|
|
|
42
44
|
|
|
43
45
|
return client
|
|
44
46
|
.get<
|
|
45
|
-
any
|
|
47
|
+
SpringPage<any>
|
|
46
48
|
>(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trip?${searchParams.toString()}`)
|
|
47
|
-
.then(({ data
|
|
48
|
-
data,
|
|
49
|
-
page:
|
|
50
|
-
pageSize:
|
|
51
|
-
total:
|
|
52
|
-
totalPages:
|
|
49
|
+
.then(({ data }) => ({
|
|
50
|
+
data: data.content,
|
|
51
|
+
page: data.number,
|
|
52
|
+
pageSize: data.size,
|
|
53
|
+
total: data.totalElements,
|
|
54
|
+
totalPages: data.totalPages,
|
|
53
55
|
}));
|
|
54
56
|
};
|
|
@@ -2,6 +2,8 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
+
import { SpringPage } from './types';
|
|
6
|
+
|
|
5
7
|
const tripsCostFiltersSchema = z.object({
|
|
6
8
|
startDate: z.string().trim().min(1),
|
|
7
9
|
endDate: z.string().trim().min(1),
|
|
@@ -38,13 +40,13 @@ export const getEntityTripsCost = async (
|
|
|
38
40
|
|
|
39
41
|
return client
|
|
40
42
|
.get<
|
|
41
|
-
any
|
|
43
|
+
SpringPage<any>
|
|
42
44
|
>(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${parsedId.data}/trips/cost?${searchParams.toString()}`)
|
|
43
|
-
.then(({ data
|
|
44
|
-
data,
|
|
45
|
-
page:
|
|
46
|
-
pageSize:
|
|
47
|
-
total:
|
|
48
|
-
totalPages:
|
|
45
|
+
.then(({ data }) => ({
|
|
46
|
+
data: data.content,
|
|
47
|
+
page: data.number,
|
|
48
|
+
pageSize: data.size,
|
|
49
|
+
total: data.totalElements,
|
|
50
|
+
totalPages: data.totalPages,
|
|
49
51
|
}));
|
|
50
52
|
};
|
|
@@ -23,13 +23,7 @@ describe('getOngoingTrips', () => {
|
|
|
23
23
|
{ tripId: '129bc3c7-82c3-5d87-a1ce-7f9e4a379729' },
|
|
24
24
|
];
|
|
25
25
|
getMock.mockResolvedValueOnce({
|
|
26
|
-
data: mockTrips,
|
|
27
|
-
headers: {
|
|
28
|
-
number: 0,
|
|
29
|
-
size: 100,
|
|
30
|
-
totalelements: 2,
|
|
31
|
-
totalpages: 1,
|
|
32
|
-
},
|
|
26
|
+
data: { content: mockTrips, number: 0, size: 100, totalElements: 2, totalPages: 1 },
|
|
33
27
|
});
|
|
34
28
|
|
|
35
29
|
const result = await getOngoingTrips(client, businessId);
|
|
@@ -48,13 +42,7 @@ describe('getOngoingTrips', () => {
|
|
|
48
42
|
|
|
49
43
|
test('should return an empty paginated response when no ongoing trips', async () => {
|
|
50
44
|
getMock.mockResolvedValueOnce({
|
|
51
|
-
data: [],
|
|
52
|
-
headers: {
|
|
53
|
-
number: 0,
|
|
54
|
-
size: 100,
|
|
55
|
-
totalelements: 0,
|
|
56
|
-
totalpages: 0,
|
|
57
|
-
},
|
|
45
|
+
data: { content: [], number: 0, size: 100, totalElements: 0, totalPages: 0 },
|
|
58
46
|
});
|
|
59
47
|
|
|
60
48
|
const result = await getOngoingTrips(client, businessId);
|
|
@@ -70,13 +58,7 @@ describe('getOngoingTrips', () => {
|
|
|
70
58
|
|
|
71
59
|
test('should pass custom pagination options', async () => {
|
|
72
60
|
getMock.mockResolvedValueOnce({
|
|
73
|
-
data: [],
|
|
74
|
-
headers: {
|
|
75
|
-
number: 2,
|
|
76
|
-
size: 10,
|
|
77
|
-
totalelements: 25,
|
|
78
|
-
totalpages: 3,
|
|
79
|
-
},
|
|
61
|
+
data: { content: [], number: 2, size: 10, totalElements: 25, totalPages: 3 },
|
|
80
62
|
});
|
|
81
63
|
|
|
82
64
|
const result = await getOngoingTrips(client, businessId, { page: 2, pageSize: 10 });
|
package/src/getOngoingTrips.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Client } from '@vulog/aima-client';
|
|
|
2
2
|
import { createPaginableOptionsSchema, PaginableOptions, PaginableResponse } from '@vulog/aima-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import { BusinessTrip } from './types';
|
|
5
|
+
import { BusinessTrip, SpringPage } from './types';
|
|
6
6
|
|
|
7
7
|
// Note: the type is named OngoingTripDTO in the API but we reuse BusinessTrip
|
|
8
8
|
export const getOngoingTrips = async (
|
|
@@ -32,11 +32,11 @@ export const getOngoingTrips = async (
|
|
|
32
32
|
|
|
33
33
|
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/ongoing?${searchParams.toString()}`;
|
|
34
34
|
|
|
35
|
-
return client.get<BusinessTrip
|
|
36
|
-
data,
|
|
37
|
-
page:
|
|
38
|
-
pageSize:
|
|
39
|
-
total:
|
|
40
|
-
totalPages:
|
|
35
|
+
return client.get<SpringPage<BusinessTrip>>(url).then(({ data }) => ({
|
|
36
|
+
data: data.content,
|
|
37
|
+
page: data.number,
|
|
38
|
+
pageSize: data.size,
|
|
39
|
+
total: data.totalElements,
|
|
40
|
+
totalPages: data.totalPages,
|
|
41
41
|
}));
|
|
42
42
|
};
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
/** Spring Page response wrapper used by the business API */
|
|
2
|
+
export type SpringPage<T> = {
|
|
3
|
+
content: T[];
|
|
4
|
+
totalElements: number;
|
|
5
|
+
totalPages: number;
|
|
6
|
+
size: number;
|
|
7
|
+
number: number;
|
|
8
|
+
first: boolean;
|
|
9
|
+
last: boolean;
|
|
10
|
+
numberOfElements: number;
|
|
11
|
+
empty: boolean;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
|
|
1
15
|
/** Represents a business entity (BusinessWSDTO) */
|
|
2
16
|
export type Business = {
|
|
3
17
|
/** Unique identifier */
|