export type GetApiFilesIdArgs = {id: number, json?: boolean | undefined, update_url?: boolean | undefined}; export type GetApiFilesIdOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Response will redirect to authenticated file * * GET /files/{id} * * Also accepts auth: API-Key */ export const getApiFilesId = async (args: GetApiFilesIdArgs, options: GetApiFilesIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.json != null) query.append("json", String(args.json)) if (args.update_url != null) query.append("update_url", String(args.update_url)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/files/${encodeURIComponent(String(args.id))}${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 };