export type CreateApiAttachmentsAttachmentIdImageArgs = {attachmentId: number, body: BodyInit}; export type CreateApiAttachmentsAttachmentIdImageOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Replace the Image * * POST /attachments/{attachmentId}/image */ export const createApiAttachmentsAttachmentIdImage = async (args: CreateApiAttachmentsAttachmentIdImageArgs, options: CreateApiAttachmentsAttachmentIdImageOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/attachments/${encodeURIComponent(String(args.attachmentId))}/image${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 };