export type PatchApiInvoicesIdArgs = {id: number, body: {issue_date?: string | undefined, due_date?: string | undefined, client_id?: number | undefined, payer_id?: number | undefined, payment_type?: ('cash' | 'cashless' | 'credit_card') | undefined, manager_id?: number | undefined, comment?: string | undefined}}; export type PatchApiInvoicesIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Invoice * * PATCH /invoices/{id} */ export const patchApiInvoicesId = async (args: PatchApiInvoicesIdArgs, options?: PatchApiInvoicesIdOptions) => { const {baseUrl = "https://api.roapp.io/v2", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/invoices/${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 undefined };