export type CreateApiContactsIdAttachmentsArgs = {id: number, filename: string}; export type CreateApiContactsIdAttachmentsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a contact attachment * * POST /contacts/{id}/attachments */ export const createApiContactsIdAttachments = async (args: CreateApiContactsIdAttachmentsArgs, options?: CreateApiContactsIdAttachmentsOptions) => { 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(/\/+$/, '')}/contacts/${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 };