export type GetApiAttachmentsIdDownloadArgs = {id: number}; export type GetApiAttachmentsIdDownloadOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Redirect to a time-limited signed URL for downloading an attachment. Returns HTTP 302 with a `Location` header pointing at a short-lived S3 URL. The URL expires after a short period and must not be cached. * * GET /attachments/{id}/download * * Also accepts auth: PersonalAccessToken */ export const getApiAttachmentsIdDownload = async (args: GetApiAttachmentsIdDownloadArgs, options?: GetApiAttachmentsIdDownloadOptions) => { const {baseUrl = "https://api.fergus.com", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/attachments/${encodeURIComponent(String(args.id))}/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 undefined };