//native
type Brex = {
token: string;
};
/**
*
Update Budget
*
Updates a Budget
*/
export async function main(
auth: Brex,
id: string,
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/${id}`);
const response = await fetch(url, {
method: "PUT",
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 217 days ago