export type Counter = {value?: number | undefined}; export type CreateApiCompaniesCompanySlugCreditNotesCounterArgs = {body: Counter}; export type CreateApiCompaniesCompanySlugCreditNotesCounterOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates the first credit note number which is then increased by one with every new credit note. By sending an empty request body the default is base number 10000 (the first credit note number will thus be 10001), but can be specified to another starting value. * * POST /companies/{companySlug}/creditNotes/counter */ export const createApiCompaniesCompanySlugCreditNotesCounter = async (args: CreateApiCompaniesCompanySlugCreditNotesCounterArgs, options?: CreateApiCompaniesCompanySlugCreditNotesCounterOptions) => { 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/counter${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 };