//native
type Brex = {
token: string;
};
/**
*
Create Budget
*
Creates a Budget
*/
export async function main(
auth: Brex,
Idempotency_Key: string,
body: {
name: string;
description: string;
parent_budget_id: string;
owner_user_ids?: string[];
period_recurrence_type:
| ("MONTHLY" & {})
| ("QUARTERLY" & {})
| ("YEARLY" & {})
| ("ONE_TIME" & {});
amount: { amount: number; currency?: string };
limit_type?: ("HARD" & {}) | ("SOFT" & {});
start_date?: string;
end_date?: string;
},
) {
const url = new URL(`https://platform.brexapis.com/v2/budgets`);
const response = await fetch(url, {
method: "POST",
headers: {
"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 170 days ago