//native
type Brex = {
token: string;
};
/**
*
Set limit for the user
*
This endpoint sets the monthly limit for a user.
The limit amount must be non-negative.
To unset the monthly limit of the user, just set `monthly_limit` to null.
*/
export async function main(
auth: Brex,
id: string,
body: { monthly_limit?: { amount?: number; currency?: string } & {} },
Idempotency_Key?: string,
) {
const url = new URL(`https://platform.brexapis.com/v2/users/${id}/limit`);
const response = await fetch(url, {
method: "POST",
headers: {
...(Idempotency_Key ? { "Idempotency-Key": Idempotency_Key } : {}),
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 217 days ago