export type CreateApiCompaniesCompanySlugPurchasesDraftsDraftIdAttachmentsArgs = {ehfDocumentId?: number | undefined, inboxDocumentId?: number | undefined, body: BodyInit}; export type CreateApiCompaniesCompanySlugPurchasesDraftsDraftIdAttachmentsOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates and adds a new attachment to a draft * * POST /companies/{companySlug}/purchases/drafts/{draftId}/attachments */ export const createApiCompaniesCompanySlugPurchasesDraftsDraftIdAttachments = async (args: CreateApiCompaniesCompanySlugPurchasesDraftsDraftIdAttachmentsArgs, options?: CreateApiCompaniesCompanySlugPurchasesDraftsDraftIdAttachmentsOptions) => { const {baseUrl = "https://api.fiken.no/api/v2", fetch: fetchFn = fetch, fikenApiOauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.ehfDocumentId != null) query.append("ehfDocumentId", String(args.ehfDocumentId)) if (args.inboxDocumentId != null) query.append("inboxDocumentId", String(args.inboxDocumentId)) if (fikenApiOauth !== undefined) headers.set('authorization', `Bearer ${fikenApiOauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companySlug))}/purchases/drafts/${encodeURIComponent(String(args.draftId))}/attachments${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };