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