@vulog/aima-business 1.2.39
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 +668 -0
- package/dist/index.d.cts +346 -0
- package/dist/index.d.mts +346 -0
- package/dist/index.mjs +609 -0
- package/package.json +42 -0
- package/src/addBusinessCredit.ts +31 -0
- package/src/addStripePayment.ts +18 -0
- package/src/addTripNote.test.ts +67 -0
- package/src/addTripNote.ts +30 -0
- package/src/addUserToBusiness.test.ts +74 -0
- package/src/addUserToBusiness.ts +49 -0
- package/src/archiveBusinessProfile.ts +28 -0
- package/src/bulkAddBusinessUsers.ts +27 -0
- package/src/businessDelegatedAdmin.test.ts +68 -0
- package/src/businessDelegatedAdmin.ts +32 -0
- package/src/businessOwner.test.ts +68 -0
- package/src/businessOwner.ts +32 -0
- package/src/chargeBusinessProduct.ts +31 -0
- package/src/createBusiness.test.ts +54 -0
- package/src/createBusiness.ts +23 -0
- package/src/createBusinessCostCenter.test.ts +61 -0
- package/src/createBusinessCostCenter.ts +34 -0
- package/src/deactivateBusinessProfile.ts +22 -0
- package/src/deleteBusinessCostCenter.test.ts +45 -0
- package/src/deleteBusinessCostCenter.ts +23 -0
- package/src/deleteInvitationRequest.test.ts +45 -0
- package/src/deleteInvitationRequest.ts +13 -0
- package/src/getBillingGroups.ts +9 -0
- package/src/getBusinessById.test.ts +47 -0
- package/src/getBusinessById.ts +15 -0
- package/src/getBusinessContacts.ts +17 -0
- package/src/getBusinessCostCenterById.ts +27 -0
- package/src/getBusinessCostCenters.ts +18 -0
- package/src/getBusinessInviteLink.ts +17 -0
- package/src/getBusinessInvoiceProducts.ts +24 -0
- package/src/getBusinessInvoiceTrips.ts +20 -0
- package/src/getBusinessInvoices.test.ts +92 -0
- package/src/getBusinessInvoices.ts +43 -0
- package/src/getBusinessPaymentDetails.ts +20 -0
- package/src/getBusinessProducts.ts +9 -0
- package/src/getBusinessTripById.ts +15 -0
- package/src/getBusinessUserById.ts +26 -0
- package/src/getBusinessUserGlobalById.ts +15 -0
- package/src/getBusinessUsers.test.ts +70 -0
- package/src/getBusinessUsers.ts +43 -0
- package/src/getBusinessWallet.test.ts +46 -0
- package/src/getBusinessWallet.ts +17 -0
- package/src/getBusinesses.test.ts +133 -0
- package/src/getBusinesses.ts +36 -0
- package/src/getEntityBalance.ts +17 -0
- package/src/getEntityProducts.ts +15 -0
- package/src/getEntityTrips.ts +13 -0
- package/src/getEntityTripsCost.ts +17 -0
- package/src/getInvitationRequest.test.ts +46 -0
- package/src/getInvitationRequest.ts +17 -0
- package/src/getInvoicePdf.test.ts +62 -0
- package/src/getInvoicePdf.ts +16 -0
- package/src/getInvoiceRefundNote.ts +17 -0
- package/src/getInvoiceRefundableAmount.ts +20 -0
- package/src/getOngoingTripNotes.ts +17 -0
- package/src/getOngoingTrips.test.ts +43 -0
- package/src/getOngoingTrips.ts +9 -0
- package/src/getStripePublishableKey.ts +9 -0
- package/src/getStripeSetup.ts +17 -0
- package/src/index.ts +58 -0
- package/src/inviteBusinessUser.ts +31 -0
- package/src/listBusinessUsersGlobal.test.ts +65 -0
- package/src/listBusinessUsersGlobal.ts +26 -0
- package/src/redeemBusinessPromoCode.ts +18 -0
- package/src/refundInvoice.test.ts +72 -0
- package/src/refundInvoice.ts +33 -0
- package/src/refundInvoiceAmount.ts +20 -0
- package/src/searchBusinessUsersByName.ts +27 -0
- package/src/searchBusinessUsersGlobal.ts +18 -0
- package/src/sendBusinessIban.ts +29 -0
- package/src/setInvoiceExternalPayment.ts +33 -0
- package/src/types.ts +163 -0
- package/src/updateBusiness.test.ts +65 -0
- package/src/updateBusiness.ts +35 -0
- package/src/updateBusinessCostCenter.ts +41 -0
- package/src/updateBusinessProfileStatus.ts +22 -0
- package/src/updateBusinessUserProfile.ts +51 -0
- package/src/updateInvoiceStatus.test.ts +54 -0
- package/src/updateInvoiceStatus.ts +19 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.ts +8 -0
- package/vitest.config.ts +1 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let zod = require("zod");
|
|
3
|
+
let _vulog_aima_core = require("@vulog/aima-core");
|
|
4
|
+
//#region src/addBusinessCredit.ts
|
|
5
|
+
const bodySchema$5 = zod.z.object({ amount: zod.z.number().min(0) });
|
|
6
|
+
const addBusinessCredit = async (client, businessId, body) => {
|
|
7
|
+
const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
8
|
+
if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
|
|
9
|
+
const result = bodySchema$5.safeParse(body);
|
|
10
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
11
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId.data}/credit`, result.data);
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/addStripePayment.ts
|
|
15
|
+
/** @deprecated */
|
|
16
|
+
const addStripePayment = async (client, businessId) => {
|
|
17
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
18
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
19
|
+
return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/stripe/businesses/${result.data}/add`).then(({ data }) => data);
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/addTripNote.ts
|
|
23
|
+
const addTripNoteBodySchema = zod.z.object({ content: zod.z.string().trim().min(1) });
|
|
24
|
+
const addTripNote = async (client, tripId, body) => {
|
|
25
|
+
const tripIdResult = zod.z.string().trim().min(1).uuid().safeParse(tripId);
|
|
26
|
+
const bodyResult = addTripNoteBodySchema.safeParse(body);
|
|
27
|
+
if (!tripIdResult.success || !bodyResult.success) throw new TypeError("Invalid args", { cause: [...tripIdResult.error?.issues ?? [], ...bodyResult.error?.issues ?? []] });
|
|
28
|
+
return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/${tripIdResult.data}/notes`, bodyResult.data).then(({ data }) => data);
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/addUserToBusiness.ts
|
|
32
|
+
const uuidSchema$9 = zod.z.string().trim().min(1).uuid();
|
|
33
|
+
const bodySchema$4 = zod.z.object({
|
|
34
|
+
email: zod.z.string().trim().email().optional(),
|
|
35
|
+
emailConsent: zod.z.boolean().optional(),
|
|
36
|
+
requestId: zod.z.string().trim().min(1).uuid().optional(),
|
|
37
|
+
costCenterId: zod.z.string().trim().min(1).uuid().optional()
|
|
38
|
+
}).optional();
|
|
39
|
+
const addUserToBusiness = async (client, businessId, userId, data) => {
|
|
40
|
+
const parsedBusinessId = uuidSchema$9.safeParse(businessId);
|
|
41
|
+
const parsedUserId = uuidSchema$9.safeParse(userId);
|
|
42
|
+
if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
|
|
43
|
+
const result = bodySchema$4.safeParse(data);
|
|
44
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
45
|
+
return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}`, result.data ?? {}).then(({ data: d }) => d);
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/archiveBusinessProfile.ts
|
|
49
|
+
const uuidSchema$8 = zod.z.string().trim().min(1).uuid();
|
|
50
|
+
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
|
+
if (!parsedBusinessId.success || !parsedUserId.success || !parsedProfileId.success) throw new TypeError("Invalid args", { cause: [
|
|
55
|
+
...parsedBusinessId.error?.issues ?? [],
|
|
56
|
+
...parsedUserId.error?.issues ?? [],
|
|
57
|
+
...parsedProfileId.error?.issues ?? []
|
|
58
|
+
] });
|
|
59
|
+
await client.delete(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}/profile/${parsedProfileId.data}`);
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//#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 });
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/businessDelegatedAdmin.ts
|
|
77
|
+
const uuidSchema$7 = zod.z.string().trim().min(1).uuid();
|
|
78
|
+
const setDelegatedAdmin = async (client, businessId, userId) => {
|
|
79
|
+
const parsedBusinessId = uuidSchema$7.safeParse(businessId);
|
|
80
|
+
const parsedUserId = uuidSchema$7.safeParse(userId);
|
|
81
|
+
if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
|
|
82
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}/delegatedAdmin`);
|
|
83
|
+
};
|
|
84
|
+
const removeDelegatedAdmin = async (client, businessId, userId) => {
|
|
85
|
+
const parsedBusinessId = uuidSchema$7.safeParse(businessId);
|
|
86
|
+
const parsedUserId = uuidSchema$7.safeParse(userId);
|
|
87
|
+
if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
|
|
88
|
+
await client.delete(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}/delegatedAdmin`);
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/businessOwner.ts
|
|
92
|
+
const uuidSchema$6 = zod.z.string().trim().min(1).uuid();
|
|
93
|
+
const setBusinessOwner = async (client, businessId, userId) => {
|
|
94
|
+
const parsedBusinessId = uuidSchema$6.safeParse(businessId);
|
|
95
|
+
const parsedUserId = uuidSchema$6.safeParse(userId);
|
|
96
|
+
if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
|
|
97
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}/owner`);
|
|
98
|
+
};
|
|
99
|
+
const removeBusinessOwner = async (client, businessId, userId) => {
|
|
100
|
+
const parsedBusinessId = uuidSchema$6.safeParse(businessId);
|
|
101
|
+
const parsedUserId = uuidSchema$6.safeParse(userId);
|
|
102
|
+
if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
|
|
103
|
+
await client.delete(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}/owner`);
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/chargeBusinessProduct.ts
|
|
107
|
+
const bodySchema$3 = zod.z.object({ productId: zod.z.string().trim().min(1) });
|
|
108
|
+
const chargeBusinessProduct = async (client, businessId, body) => {
|
|
109
|
+
const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
110
|
+
if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
|
|
111
|
+
const result = bodySchema$3.safeParse(body);
|
|
112
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
113
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId.data}/product`, result.data);
|
|
114
|
+
};
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/createBusiness.ts
|
|
117
|
+
const createBusinessBodySchema = zod.z.object({ name: zod.z.string().trim().min(1).max(255) });
|
|
118
|
+
const createBusiness = async (client, body) => {
|
|
119
|
+
const result = createBusinessBodySchema.safeParse(body);
|
|
120
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
121
|
+
return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business`, result.data).then(({ data }) => data);
|
|
122
|
+
};
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/createBusinessCostCenter.ts
|
|
125
|
+
const schema$8 = zod.z.object({
|
|
126
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
127
|
+
name: zod.z.string().trim().min(1).max(255)
|
|
128
|
+
});
|
|
129
|
+
const createBusinessCostCenter = async (client, businessId, body) => {
|
|
130
|
+
const result = schema$8.safeParse({
|
|
131
|
+
businessId,
|
|
132
|
+
...body
|
|
133
|
+
});
|
|
134
|
+
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);
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/deactivateBusinessProfile.ts
|
|
139
|
+
const uuidSchema$5 = zod.z.string().trim().min(1).uuid();
|
|
140
|
+
const deactivateBusinessProfile = async (client, businessId, profileId) => {
|
|
141
|
+
const parsedBusinessId = uuidSchema$5.safeParse(businessId);
|
|
142
|
+
const parsedProfileId = uuidSchema$5.safeParse(profileId);
|
|
143
|
+
if (!parsedBusinessId.success || !parsedProfileId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedProfileId.error?.issues ?? []] });
|
|
144
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/profiles/${parsedProfileId.data}/deactivate`);
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/deleteBusinessCostCenter.ts
|
|
148
|
+
const schema$7 = zod.z.object({
|
|
149
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
150
|
+
costCenterId: zod.z.string().trim().min(1).uuid()
|
|
151
|
+
});
|
|
152
|
+
const deleteBusinessCostCenter = async (client, businessId, costCenterId) => {
|
|
153
|
+
const result = schema$7.safeParse({
|
|
154
|
+
businessId,
|
|
155
|
+
costCenterId
|
|
156
|
+
});
|
|
157
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
158
|
+
await client.delete(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/costcenter/${result.data.costCenterId}`);
|
|
159
|
+
};
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/deleteInvitationRequest.ts
|
|
162
|
+
const deleteInvitationRequest = async (client, invitationId) => {
|
|
163
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(invitationId);
|
|
164
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
165
|
+
await client.delete(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invitationRequest/${result.data}`);
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/getBillingGroups.ts
|
|
169
|
+
const getBusinessBillingGroups = async (client) => {
|
|
170
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/groups`).then(({ data }) => data);
|
|
171
|
+
};
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region src/getBusinessById.ts
|
|
174
|
+
const getBusinessById = async (client, businessId) => {
|
|
175
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
176
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
177
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}`).then(({ data }) => data);
|
|
178
|
+
};
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/getBusinessContacts.ts
|
|
181
|
+
const getBusinessContacts = async (client, businessId) => {
|
|
182
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
183
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
184
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/contacts`).then(({ data }) => data);
|
|
185
|
+
};
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/getBusinessCostCenterById.ts
|
|
188
|
+
const schema$6 = zod.z.object({
|
|
189
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
190
|
+
costCenterId: zod.z.string().trim().min(1).uuid()
|
|
191
|
+
});
|
|
192
|
+
const getBusinessCostCenterById = async (client, businessId, costCenterId) => {
|
|
193
|
+
const result = schema$6.safeParse({
|
|
194
|
+
businessId,
|
|
195
|
+
costCenterId
|
|
196
|
+
});
|
|
197
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
198
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/costcenter/${result.data.costCenterId}`).then(({ data }) => data);
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/getBusinessCostCenters.ts
|
|
202
|
+
const getBusinessCostCenters = async (client, businessId) => {
|
|
203
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
204
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
205
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/costcenter`).then(({ data }) => data);
|
|
206
|
+
};
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/getBusinesses.ts
|
|
209
|
+
const getBusinesses = async (client, options) => {
|
|
210
|
+
const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
|
|
211
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
212
|
+
const finalOptions = resultOptions.data;
|
|
213
|
+
const searchParams = new URLSearchParams();
|
|
214
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
215
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
216
|
+
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
217
|
+
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
|
|
224
|
+
}));
|
|
225
|
+
};
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region src/getBusinessInviteLink.ts
|
|
228
|
+
const getBusinessInviteLink = async (client, businessId) => {
|
|
229
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
230
|
+
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);
|
|
232
|
+
};
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/getBusinessInvoiceProducts.ts
|
|
235
|
+
const uuidSchema$4 = zod.z.string().trim().min(1).uuid();
|
|
236
|
+
const getBusinessInvoiceProducts = async (client, entityId, invoiceId) => {
|
|
237
|
+
const parsedEntityId = uuidSchema$4.safeParse(entityId);
|
|
238
|
+
const parsedInvoiceId = uuidSchema$4.safeParse(invoiceId);
|
|
239
|
+
if (!parsedEntityId.success || !parsedInvoiceId.success) throw new TypeError("Invalid args", { cause: [...parsedEntityId.error?.issues ?? [], ...parsedInvoiceId.error?.issues ?? []] });
|
|
240
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/entities/${parsedEntityId.data}/businessInvoices/${parsedInvoiceId.data}/products`).then(({ data }) => data);
|
|
241
|
+
};
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/getBusinessInvoices.ts
|
|
244
|
+
const getBusinessInvoices = async (client, entityId, options) => {
|
|
245
|
+
const resultId = zod.z.string().trim().min(1).uuid().safeParse(entityId);
|
|
246
|
+
if (!resultId.success) throw new TypeError("Invalid args", { cause: resultId.error.issues });
|
|
247
|
+
const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
|
|
248
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
249
|
+
const finalOptions = resultOptions.data;
|
|
250
|
+
const searchParams = new URLSearchParams();
|
|
251
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
252
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
253
|
+
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
254
|
+
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
|
|
261
|
+
}));
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/getBusinessInvoiceTrips.ts
|
|
265
|
+
const uuidSchema$3 = zod.z.string().trim().min(1).uuid();
|
|
266
|
+
const getBusinessInvoiceTrips = async (client, entityId, invoiceId) => {
|
|
267
|
+
const parsedEntityId = uuidSchema$3.safeParse(entityId);
|
|
268
|
+
const parsedInvoiceId = uuidSchema$3.safeParse(invoiceId);
|
|
269
|
+
if (!parsedEntityId.success || !parsedInvoiceId.success) throw new TypeError("Invalid args", { cause: [...parsedEntityId.error?.issues ?? [], ...parsedInvoiceId.error?.issues ?? []] });
|
|
270
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/entities/${parsedEntityId.data}/businessInvoices/${parsedInvoiceId.data}/trips`).then(({ data }) => data);
|
|
271
|
+
};
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region src/getBusinessPaymentDetails.ts
|
|
274
|
+
const getBusinessPaymentDetails = async (client, businessId) => {
|
|
275
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
276
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
277
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data}/paymentDetails`).then(({ data }) => data);
|
|
278
|
+
};
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/getBusinessProducts.ts
|
|
281
|
+
const getBusinessProducts = async (client) => {
|
|
282
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/product`).then(({ data }) => data);
|
|
283
|
+
};
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/getBusinessTripById.ts
|
|
286
|
+
const getBusinessTripById = async (client, tripId) => {
|
|
287
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(tripId);
|
|
288
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
289
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/trip/${result.data}`).then(({ data }) => data);
|
|
290
|
+
};
|
|
291
|
+
//#endregion
|
|
292
|
+
//#region src/getBusinessUserById.ts
|
|
293
|
+
const uuidSchema$2 = zod.z.string().trim().min(1).uuid();
|
|
294
|
+
const getBusinessUserById = async (client, businessId, userId) => {
|
|
295
|
+
const parsedBusinessId = uuidSchema$2.safeParse(businessId);
|
|
296
|
+
const parsedUserId = uuidSchema$2.safeParse(userId);
|
|
297
|
+
if (!parsedBusinessId.success || !parsedUserId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedUserId.error?.issues ?? []] });
|
|
298
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}`).then(({ data }) => data);
|
|
299
|
+
};
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/getBusinessUserGlobalById.ts
|
|
302
|
+
const getBusinessUserGlobalById = async (client, userId) => {
|
|
303
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(userId);
|
|
304
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
305
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/users/${result.data}`).then(({ data }) => data);
|
|
306
|
+
};
|
|
307
|
+
//#endregion
|
|
308
|
+
//#region src/getBusinessUsers.ts
|
|
309
|
+
const getBusinessUsers = async (client, businessId, options) => {
|
|
310
|
+
const resultId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
311
|
+
if (!resultId.success) throw new TypeError("Invalid args", { cause: resultId.error.issues });
|
|
312
|
+
const resultOptions = (0, _vulog_aima_core.createPaginableOptionsSchema)().safeParse(options ?? {});
|
|
313
|
+
if (!resultOptions.success) throw new TypeError("Invalid options", { cause: resultOptions.error.issues });
|
|
314
|
+
const finalOptions = resultOptions.data;
|
|
315
|
+
const searchParams = new URLSearchParams();
|
|
316
|
+
searchParams.append("page", finalOptions.page.toString());
|
|
317
|
+
searchParams.append("size", finalOptions.pageSize.toString());
|
|
318
|
+
if (finalOptions.sort) searchParams.append("sort", `${finalOptions.sort.toString()},${finalOptions.sortDirection.toString()}`);
|
|
319
|
+
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
|
|
326
|
+
}));
|
|
327
|
+
};
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/getBusinessWallet.ts
|
|
330
|
+
const getBusinessWallet = async (client, businessId) => {
|
|
331
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
332
|
+
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);
|
|
334
|
+
};
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/getEntityBalance.ts
|
|
337
|
+
const getEntityBalance = async (client, entityId) => {
|
|
338
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(entityId);
|
|
339
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
340
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/billing/entity/${result.data}/balance`).then(({ data }) => data);
|
|
341
|
+
};
|
|
342
|
+
//#endregion
|
|
343
|
+
//#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);
|
|
348
|
+
};
|
|
349
|
+
//#endregion
|
|
350
|
+
//#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);
|
|
355
|
+
};
|
|
356
|
+
//#endregion
|
|
357
|
+
//#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);
|
|
362
|
+
};
|
|
363
|
+
//#endregion
|
|
364
|
+
//#region src/getInvitationRequest.ts
|
|
365
|
+
const getInvitationRequest = async (client, invitationId) => {
|
|
366
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(invitationId);
|
|
367
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
368
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invitationRequest/${result.data}`).then(({ data }) => data);
|
|
369
|
+
};
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/getInvoicePdf.ts
|
|
372
|
+
const getInvoicePdf = async (client, invoiceId) => {
|
|
373
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
|
|
374
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
375
|
+
const { data } = await client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${result.data}/pdf`, { responseType: "arraybuffer" });
|
|
376
|
+
return data && data.byteLength > 0 ? data : null;
|
|
377
|
+
};
|
|
378
|
+
//#endregion
|
|
379
|
+
//#region src/getInvoiceRefundableAmount.ts
|
|
380
|
+
const getInvoiceRefundableAmount = async (client, invoiceId) => {
|
|
381
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
|
|
382
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
383
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${result.data}/refundableAmount`).then(({ data }) => data);
|
|
384
|
+
};
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/getInvoiceRefundNote.ts
|
|
387
|
+
const getInvoiceRefundNote = async (client, invoiceId) => {
|
|
388
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
|
|
389
|
+
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);
|
|
391
|
+
};
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/getOngoingTripNotes.ts
|
|
394
|
+
const getOngoingTripNotes = async (client, tripId) => {
|
|
395
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(tripId);
|
|
396
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
397
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/ongoingTrip/${result.data}/notes`).then(({ data }) => data);
|
|
398
|
+
};
|
|
399
|
+
//#endregion
|
|
400
|
+
//#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);
|
|
403
|
+
};
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/getStripePublishableKey.ts
|
|
406
|
+
const getStripePublishableKey = async (client) => {
|
|
407
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/stripe/config/key`).then(({ data }) => data);
|
|
408
|
+
};
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/getStripeSetup.ts
|
|
411
|
+
const getStripeSetup = async (client, businessId) => {
|
|
412
|
+
const result = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
413
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
414
|
+
return client.get(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/stripe/businesses/${result.data}/add`).then(({ data }) => data);
|
|
415
|
+
};
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/inviteBusinessUser.ts
|
|
418
|
+
const inviteSchema = zod.z.object({
|
|
419
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
420
|
+
email: zod.z.string().trim().email(),
|
|
421
|
+
costCenterId: zod.z.string().trim().min(1).uuid().optional()
|
|
422
|
+
});
|
|
423
|
+
const inviteBusinessUser = async (client, businessId, body) => {
|
|
424
|
+
const result = inviteSchema.safeParse({
|
|
425
|
+
businessId,
|
|
426
|
+
...body
|
|
427
|
+
});
|
|
428
|
+
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);
|
|
431
|
+
};
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/listBusinessUsersGlobal.ts
|
|
434
|
+
const schema$5 = zod.z.object({ userIds: zod.z.array(zod.z.string().trim().min(1).uuid()).min(1) });
|
|
435
|
+
const listBusinessUsersGlobal = async (client, body) => {
|
|
436
|
+
const result = schema$5.safeParse(body);
|
|
437
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
438
|
+
return client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/users/list`, result.data).then(({ data }) => data);
|
|
439
|
+
};
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/redeemBusinessPromoCode.ts
|
|
442
|
+
const schema$4 = zod.z.object({
|
|
443
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
444
|
+
reference: zod.z.string().trim().min(1)
|
|
445
|
+
});
|
|
446
|
+
const redeemBusinessPromoCode = async (client, businessId, reference) => {
|
|
447
|
+
const result = schema$4.safeParse({
|
|
448
|
+
businessId,
|
|
449
|
+
reference
|
|
450
|
+
});
|
|
451
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
452
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/promoCodes/redeem/${result.data.reference}`);
|
|
453
|
+
};
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/refundInvoice.ts
|
|
456
|
+
const refundInvoiceBodySchema = zod.z.object({
|
|
457
|
+
amount: zod.z.number().min(0).optional(),
|
|
458
|
+
note: zod.z.string().trim().nullable().optional()
|
|
459
|
+
});
|
|
460
|
+
const refundInvoice = async (client, invoiceId, body) => {
|
|
461
|
+
const parsedId = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
|
|
462
|
+
if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
|
|
463
|
+
const result = refundInvoiceBodySchema.safeParse(body ?? {});
|
|
464
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
465
|
+
const filteredData = Object.fromEntries(Object.entries(result.data).filter(([_, value]) => value !== void 0 && value !== null));
|
|
466
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${parsedId.data}/refund`, filteredData);
|
|
467
|
+
};
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/refundInvoiceAmount.ts
|
|
470
|
+
const schema$3 = zod.z.object({
|
|
471
|
+
invoiceId: zod.z.string().trim().min(1).uuid(),
|
|
472
|
+
amount: zod.z.number().min(0)
|
|
473
|
+
});
|
|
474
|
+
/** @deprecated Use refundInvoice instead */
|
|
475
|
+
const refundInvoiceAmount = async (client, invoiceId, amount) => {
|
|
476
|
+
const result = schema$3.safeParse({
|
|
477
|
+
invoiceId,
|
|
478
|
+
amount
|
|
479
|
+
});
|
|
480
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
481
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${result.data.invoiceId}/refund/${result.data.amount}`, {});
|
|
482
|
+
};
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/searchBusinessUsersByName.ts
|
|
485
|
+
const searchSchema = zod.z.object({
|
|
486
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
487
|
+
name: zod.z.string().trim().min(1)
|
|
488
|
+
});
|
|
489
|
+
const searchBusinessUsersByName = async (client, businessId, name) => {
|
|
490
|
+
const result = searchSchema.safeParse({
|
|
491
|
+
businessId,
|
|
492
|
+
name
|
|
493
|
+
});
|
|
494
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
495
|
+
const searchParams = new URLSearchParams();
|
|
496
|
+
searchParams.append("name", result.data.name);
|
|
497
|
+
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/users/name?${searchParams.toString()}`;
|
|
498
|
+
return client.get(url).then(({ data }) => data);
|
|
499
|
+
};
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/searchBusinessUsersGlobal.ts
|
|
502
|
+
const searchBusinessUsersGlobal = async (client, query) => {
|
|
503
|
+
const result = zod.z.string().trim().min(1).safeParse(query);
|
|
504
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
505
|
+
const searchParams = new URLSearchParams();
|
|
506
|
+
searchParams.append("query", result.data);
|
|
507
|
+
const url = `/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/users/search?${searchParams.toString()}`;
|
|
508
|
+
return client.get(url).then(({ data }) => data);
|
|
509
|
+
};
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/sendBusinessIban.ts
|
|
512
|
+
const schema$2 = zod.z.object({
|
|
513
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
514
|
+
iban: zod.z.string().trim().min(1)
|
|
515
|
+
});
|
|
516
|
+
const sendBusinessIban = async (client, businessId, body) => {
|
|
517
|
+
const result = schema$2.safeParse({
|
|
518
|
+
businessId,
|
|
519
|
+
...body
|
|
520
|
+
});
|
|
521
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
522
|
+
const { businessId: parsedId, ...parsedBody } = result.data;
|
|
523
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId}/paymentDetails/wireTransfer`, parsedBody);
|
|
524
|
+
};
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/setInvoiceExternalPayment.ts
|
|
527
|
+
const bodySchema$2 = zod.z.object({
|
|
528
|
+
paymentReference: zod.z.string().trim().min(1).optional(),
|
|
529
|
+
paymentDate: zod.z.string().trim().min(1).optional()
|
|
530
|
+
});
|
|
531
|
+
const setInvoiceExternalPayment = async (client, invoiceId, body) => {
|
|
532
|
+
const parsedId = zod.z.string().trim().min(1).uuid().safeParse(invoiceId);
|
|
533
|
+
if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
|
|
534
|
+
const result = bodySchema$2.safeParse(body);
|
|
535
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
536
|
+
await client.put(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${parsedId.data}/externalPayment`, result.data);
|
|
537
|
+
};
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/updateBusiness.ts
|
|
540
|
+
const updateBusinessBodySchema = zod.z.object({ name: zod.z.string().trim().min(1).max(255).optional() });
|
|
541
|
+
const updateBusiness = async (client, businessId, body) => {
|
|
542
|
+
const parsedId = zod.z.string().trim().min(1).uuid().safeParse(businessId);
|
|
543
|
+
if (!parsedId.success) throw new TypeError("Invalid args", { cause: parsedId.error.issues });
|
|
544
|
+
const result = updateBusinessBodySchema.safeParse(body);
|
|
545
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
546
|
+
return client.put(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedId.data}`, result.data).then(({ data }) => data);
|
|
547
|
+
};
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/updateBusinessCostCenter.ts
|
|
550
|
+
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() });
|
|
552
|
+
const updateBusinessCostCenter = async (client, businessId, costCenterId, body) => {
|
|
553
|
+
const parsedBusinessId = uuidSchema$1.safeParse(businessId);
|
|
554
|
+
const parsedCostCenterId = uuidSchema$1.safeParse(costCenterId);
|
|
555
|
+
if (!parsedBusinessId.success || !parsedCostCenterId.success) throw new TypeError("Invalid args", { cause: [...parsedBusinessId.error?.issues ?? [], ...parsedCostCenterId.error?.issues ?? []] });
|
|
556
|
+
const result = bodySchema$1.safeParse(body);
|
|
557
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
558
|
+
return client.put(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/costcenter/${parsedCostCenterId.data}`, result.data).then(({ data }) => data);
|
|
559
|
+
};
|
|
560
|
+
//#endregion
|
|
561
|
+
//#region src/updateBusinessProfileStatus.ts
|
|
562
|
+
const schema$1 = zod.z.object({
|
|
563
|
+
businessId: zod.z.string().trim().min(1).uuid(),
|
|
564
|
+
status: zod.z.string().trim().min(1)
|
|
565
|
+
});
|
|
566
|
+
const updateBusinessProfileStatus = async (client, businessId, status) => {
|
|
567
|
+
const result = schema$1.safeParse({
|
|
568
|
+
businessId,
|
|
569
|
+
status
|
|
570
|
+
});
|
|
571
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
572
|
+
await client.put(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${result.data.businessId}/profile/user/profile/status/${result.data.status}`);
|
|
573
|
+
};
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/updateBusinessUserProfile.ts
|
|
576
|
+
const uuidSchema = zod.z.string().trim().min(1).uuid();
|
|
577
|
+
const bodySchema = zod.z.object({
|
|
578
|
+
email: zod.z.string().trim().email().optional(),
|
|
579
|
+
emailConsent: zod.z.boolean().optional(),
|
|
580
|
+
costCenterId: zod.z.string().trim().min(1).uuid().optional()
|
|
581
|
+
});
|
|
582
|
+
const updateBusinessUserProfile = async (client, businessId, userId, profileId, body) => {
|
|
583
|
+
const parsedBusinessId = uuidSchema.safeParse(businessId);
|
|
584
|
+
const parsedUserId = uuidSchema.safeParse(userId);
|
|
585
|
+
const parsedProfileId = uuidSchema.safeParse(profileId);
|
|
586
|
+
if (!parsedBusinessId.success || !parsedUserId.success || !parsedProfileId.success) throw new TypeError("Invalid args", { cause: [
|
|
587
|
+
...parsedBusinessId.error?.issues ?? [],
|
|
588
|
+
...parsedUserId.error?.issues ?? [],
|
|
589
|
+
...parsedProfileId.error?.issues ?? []
|
|
590
|
+
] });
|
|
591
|
+
const result = bodySchema.safeParse(body);
|
|
592
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
593
|
+
return client.put(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/business/${parsedBusinessId.data}/user/${parsedUserId.data}/profile/${parsedProfileId.data}`, result.data).then(({ data }) => data);
|
|
594
|
+
};
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region src/updateInvoiceStatus.ts
|
|
597
|
+
const schema = zod.z.object({
|
|
598
|
+
invoiceId: zod.z.string().trim().min(1).uuid(),
|
|
599
|
+
status: zod.z.string().trim().min(1)
|
|
600
|
+
});
|
|
601
|
+
const updateInvoiceStatus = async (client, invoiceId, status) => {
|
|
602
|
+
const result = schema.safeParse({
|
|
603
|
+
invoiceId,
|
|
604
|
+
status
|
|
605
|
+
});
|
|
606
|
+
if (!result.success) throw new TypeError("Invalid args", { cause: result.error.issues });
|
|
607
|
+
await client.post(`/boapi/proxy/business/fleets/${client.clientOptions.fleetId}/invoices/${result.data.invoiceId}/status/${result.data.status}`, {});
|
|
608
|
+
};
|
|
609
|
+
//#endregion
|
|
610
|
+
exports.addBusinessCredit = addBusinessCredit;
|
|
611
|
+
exports.addStripePayment = addStripePayment;
|
|
612
|
+
exports.addTripNote = addTripNote;
|
|
613
|
+
exports.addUserToBusiness = addUserToBusiness;
|
|
614
|
+
exports.archiveBusinessProfile = archiveBusinessProfile;
|
|
615
|
+
exports.bulkAddBusinessUsers = bulkAddBusinessUsers;
|
|
616
|
+
exports.chargeBusinessProduct = chargeBusinessProduct;
|
|
617
|
+
exports.createBusiness = createBusiness;
|
|
618
|
+
exports.createBusinessCostCenter = createBusinessCostCenter;
|
|
619
|
+
exports.deactivateBusinessProfile = deactivateBusinessProfile;
|
|
620
|
+
exports.deleteBusinessCostCenter = deleteBusinessCostCenter;
|
|
621
|
+
exports.deleteInvitationRequest = deleteInvitationRequest;
|
|
622
|
+
exports.getBusinessBillingGroups = getBusinessBillingGroups;
|
|
623
|
+
exports.getBusinessById = getBusinessById;
|
|
624
|
+
exports.getBusinessContacts = getBusinessContacts;
|
|
625
|
+
exports.getBusinessCostCenterById = getBusinessCostCenterById;
|
|
626
|
+
exports.getBusinessCostCenters = getBusinessCostCenters;
|
|
627
|
+
exports.getBusinessInviteLink = getBusinessInviteLink;
|
|
628
|
+
exports.getBusinessInvoiceProducts = getBusinessInvoiceProducts;
|
|
629
|
+
exports.getBusinessInvoiceTrips = getBusinessInvoiceTrips;
|
|
630
|
+
exports.getBusinessInvoices = getBusinessInvoices;
|
|
631
|
+
exports.getBusinessPaymentDetails = getBusinessPaymentDetails;
|
|
632
|
+
exports.getBusinessProducts = getBusinessProducts;
|
|
633
|
+
exports.getBusinessTripById = getBusinessTripById;
|
|
634
|
+
exports.getBusinessUserById = getBusinessUserById;
|
|
635
|
+
exports.getBusinessUserGlobalById = getBusinessUserGlobalById;
|
|
636
|
+
exports.getBusinessUsers = getBusinessUsers;
|
|
637
|
+
exports.getBusinessWallet = getBusinessWallet;
|
|
638
|
+
exports.getBusinesses = getBusinesses;
|
|
639
|
+
exports.getEntityBalance = getEntityBalance;
|
|
640
|
+
exports.getEntityProducts = getEntityProducts;
|
|
641
|
+
exports.getEntityTrips = getEntityTrips;
|
|
642
|
+
exports.getEntityTripsCost = getEntityTripsCost;
|
|
643
|
+
exports.getInvitationRequest = getInvitationRequest;
|
|
644
|
+
exports.getInvoicePdf = getInvoicePdf;
|
|
645
|
+
exports.getInvoiceRefundNote = getInvoiceRefundNote;
|
|
646
|
+
exports.getInvoiceRefundableAmount = getInvoiceRefundableAmount;
|
|
647
|
+
exports.getOngoingTripNotes = getOngoingTripNotes;
|
|
648
|
+
exports.getOngoingTrips = getOngoingTrips;
|
|
649
|
+
exports.getStripePublishableKey = getStripePublishableKey;
|
|
650
|
+
exports.getStripeSetup = getStripeSetup;
|
|
651
|
+
exports.inviteBusinessUser = inviteBusinessUser;
|
|
652
|
+
exports.listBusinessUsersGlobal = listBusinessUsersGlobal;
|
|
653
|
+
exports.redeemBusinessPromoCode = redeemBusinessPromoCode;
|
|
654
|
+
exports.refundInvoice = refundInvoice;
|
|
655
|
+
exports.refundInvoiceAmount = refundInvoiceAmount;
|
|
656
|
+
exports.removeBusinessOwner = removeBusinessOwner;
|
|
657
|
+
exports.removeDelegatedAdmin = removeDelegatedAdmin;
|
|
658
|
+
exports.searchBusinessUsersByName = searchBusinessUsersByName;
|
|
659
|
+
exports.searchBusinessUsersGlobal = searchBusinessUsersGlobal;
|
|
660
|
+
exports.sendBusinessIban = sendBusinessIban;
|
|
661
|
+
exports.setBusinessOwner = setBusinessOwner;
|
|
662
|
+
exports.setDelegatedAdmin = setDelegatedAdmin;
|
|
663
|
+
exports.setInvoiceExternalPayment = setInvoiceExternalPayment;
|
|
664
|
+
exports.updateBusiness = updateBusiness;
|
|
665
|
+
exports.updateBusinessCostCenter = updateBusinessCostCenter;
|
|
666
|
+
exports.updateBusinessProfileStatus = updateBusinessProfileStatus;
|
|
667
|
+
exports.updateBusinessUserProfile = updateBusinessUserProfile;
|
|
668
|
+
exports.updateInvoiceStatus = updateInvoiceStatus;
|