export type Expense = {amount?: number | undefined, category?: string | undefined, categoryID?: (string | null) | undefined, date?: string | undefined, description?: string | undefined, documents?: (Array<{digest: string, name: string, path: string, size: number, type?: 'CloudFile' | undefined, uploadDate?: (string | null) | undefined, url?: (string | null) | undefined}>) | undefined, id?: string | undefined, isPaid?: boolean | undefined, originalAmount?: (number | null) | undefined, originalCurrency?: (string | null) | undefined, paymentMethod?: string | undefined, paymentMethodID?: (string | null) | undefined, vatRate?: number | undefined, withholdingTax?: boolean | undefined}; export type PatchApiExpensesIdArgs = {body: Expense}; export type PatchApiExpensesIdOptions = {baseUrl: string, ApiKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update expense * * PATCH /expenses/{id} * * Also accepts auth: FirebaseIdToken */ export const patchApiExpensesId = async (args: PatchApiExpensesIdArgs, options: PatchApiExpensesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyHeader !== undefined) headers.set("X-API-Key", ApiKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/expenses/${encodeURIComponent(String(args.id))}${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 (await res.json()) as unknown };