export type GetApiV6FilesFileIdDownloadArgs = {fileId: string, limit?: string | undefined, offset?: string | undefined}; export type GetApiV6FilesFileIdDownloadOptions = {baseUrl?: string | undefined, HEADER?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a file asset * * GET /v6/files/{fileId}/download * * Also accepts auth: QUERY, COOKIE */ export const getApiV6FilesFileIdDownload = async (args: GetApiV6FilesFileIdDownloadArgs, options?: GetApiV6FilesFileIdDownloadOptions) => { const {baseUrl = "https://api.extole.io", fetch: fetchFn = fetch, HEADER} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (HEADER !== undefined) headers.set("Authorization", HEADER) const url = `${baseUrl.replace(/\/+$/, '')}/v6/files/${encodeURIComponent(String(args.fileId))}/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 };