export type UpdateInvoiceRequest = {newDueDate?: string | undefined, sentManually?: boolean | undefined}; export type PatchApiCompaniesCompanySlugInvoicesInvoiceIdArgs = {body: UpdateInvoiceRequest}; export type PatchApiCompaniesCompanySlugInvoicesInvoiceIdOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates invoice with provided id. It is possible to update the due date of an invoice * * PATCH /companies/{companySlug}/invoices/{invoiceId} */ export const patchApiCompaniesCompanySlugInvoicesInvoiceId = async (args: PatchApiCompaniesCompanySlugInvoicesInvoiceIdArgs, options?: PatchApiCompaniesCompanySlugInvoicesInvoiceIdOptions) => { const {baseUrl = "https://api.fiken.no/api/v2", fetch: fetchFn = fetch, fikenApiOauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (fikenApiOauth !== undefined) headers.set('authorization', `Bearer ${fikenApiOauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companySlug))}/invoices/${encodeURIComponent(String(args.invoiceId))}${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 };