export type PatchApiBudgetsBudgetIdArgs = {budgetId: string, accountId: string, body: {feature?: ({payments?: boolean | undefined}) | undefined}}; export type PatchApiBudgetsBudgetIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a budget's details * * PATCH /budgets/{budgetId} */ export const patchApiBudgetsBudgetId = async (args: PatchApiBudgetsBudgetIdArgs, options?: PatchApiBudgetsBudgetIdOptions) => { const {baseUrl = "https://api.equalsmoney.com/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.accountId != null) query.append("accountId", String(args.accountId)) const url = `${baseUrl.replace(/\/+$/, '')}/budgets/${encodeURIComponent(String(args.budgetId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };