export type CreateApiCoaApiEntityEntityIdAttachmentArgs = {entity_id: number}; export type CreateApiCoaApiEntityEntityIdAttachmentOptions = {baseUrl?: string | undefined, knoxApiToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload Entity Invoice Email Attachment * * POST /coa/api/entity/{entity_id}/attachment */ export const createApiCoaApiEntityEntityIdAttachment = async (args: CreateApiCoaApiEntityEntityIdAttachmentArgs, options?: CreateApiCoaApiEntityEntityIdAttachmentOptions) => { const {baseUrl = "https://api.meetcampfire.com", fetch: fetchFn = fetch, knoxApiToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (knoxApiToken !== undefined) headers.set("Authorization", knoxApiToken) const url = `${baseUrl.replace(/\/+$/, '')}/coa/api/entity/${encodeURIComponent(String(args.entity_id))}/attachment${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 };