export type FullCreditNoteRequest = {issueDate: string, invoiceId: number, creditNoteText?: string | undefined}; export type CreateApiCompaniesCompanySlugCreditNotesFullArgs = {body: FullCreditNoteRequest}; export type CreateApiCompaniesCompanySlugCreditNotesFullOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new credit note that covers the full amount of the associated invoice. * * POST /companies/{companySlug}/creditNotes/full */ export const createApiCompaniesCompanySlugCreditNotesFull = async (args: CreateApiCompaniesCompanySlugCreditNotesFullArgs, options?: CreateApiCompaniesCompanySlugCreditNotesFullOptions) => { 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))}/creditNotes/full${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };