export type GetApiApiInboxesChannelIdThreadsThreadIdMessagesMessageIdAttachmentsAttachmentIdArgs = {channelId: string, threadId: string, messageId: string, attachmentId: string, Range?: string | undefined}; export type GetApiApiInboxesChannelIdThreadsThreadIdMessagesMessageIdAttachmentsAttachmentIdOptions = {baseUrl?: string | undefined, ApiKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download an email attachment * * GET /api/inboxes/{channelId}/threads/{threadId}/messages/{messageId}/attachments/{attachmentId} * * Also accepts auth: DelegateToken, PartnerBearer */ export const getApiApiInboxesChannelIdThreadsThreadIdMessagesMessageIdAttachmentsAttachmentId = async (args: GetApiApiInboxesChannelIdThreadsThreadIdMessagesMessageIdAttachmentsAttachmentIdArgs, options?: GetApiApiInboxesChannelIdThreadsThreadIdMessagesMessageIdAttachmentsAttachmentIdOptions) => { const {baseUrl = "https://core-api.getaptly.com", fetch: fetchFn = fetch, ApiKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.Range != null) headers.set("Range", String(args.Range)) if (ApiKeyHeader !== undefined) headers.set("x-token", ApiKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/inboxes/${encodeURIComponent(String(args.channelId))}/threads/${encodeURIComponent(String(args.threadId))}/messages/${encodeURIComponent(String(args.messageId))}/attachments/${encodeURIComponent(String(args.attachmentId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };