export type GetApiAttachmentsAttachmentTokenDownloadArgs = {attachment_token: string, inline?: boolean | undefined}; export type GetApiAttachmentsAttachmentTokenDownloadOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Attachment * * GET /attachments/{attachment_token}/download */ export const getApiAttachmentsAttachmentTokenDownload = async (args: GetApiAttachmentsAttachmentTokenDownloadArgs, options?: GetApiAttachmentsAttachmentTokenDownloadOptions) => { const {baseUrl = "https://api.everhour.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (args.inline != null) query.append("inline", String(args.inline)) if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/attachments/${encodeURIComponent(String(args.attachment_token))}/download${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() };