export type CreateApiCompaniesIdAttachmentsArgs = {id: number, filename: string}; export type CreateApiCompaniesIdAttachmentsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a company attachment * * POST /companies/{id}/attachments */ export const createApiCompaniesIdAttachments = async (args: CreateApiCompaniesIdAttachmentsArgs, options?: CreateApiCompaniesIdAttachmentsOptions) => { const {baseUrl = "https://api.catsone.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.filename != null) query.append("filename", String(args.filename)) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.id))}/attachments${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 };