export type CreateApiCompaniesCompanySlugPurchasesDraftsDraftIdCreatePurchaseOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a purchase from an already created draft. * * POST /companies/{companySlug}/purchases/drafts/{draftId}/createPurchase */ export const createApiCompaniesCompanySlugPurchasesDraftsDraftIdCreatePurchase = async (options?: CreateApiCompaniesCompanySlugPurchasesDraftsDraftIdCreatePurchaseOptions) => { const {baseUrl = "https://api.fiken.no/api/v2", fetch: fetchFn = fetch, fikenApiOauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (fikenApiOauth !== undefined) headers.set('authorization', `Bearer ${fikenApiOauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companySlug))}/purchases/drafts/${encodeURIComponent(String(args.draftId))}/createPurchase${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };