export type GetApiV1FilesFileIdContentArgs = {versionId?: string | undefined, fileId: string}; export type GetApiV1FilesFileIdContentOptions = {baseUrl?: string | undefined, personalApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a file * * GET /v1/files/{fileId}/content * * Also accepts auth: adamId */ export const getApiV1FilesFileIdContent = async (args: GetApiV1FilesFileIdContentArgs, options?: GetApiV1FilesFileIdContentOptions) => { const {baseUrl = "https://api.adam.new", fetch: fetchFn = fetch, personalApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.versionId != null) query.append("versionId", String(args.versionId)) if (personalApiKey !== undefined) headers.set('authorization', `Bearer ${personalApiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/files/${encodeURIComponent(String(args.fileId))}/content${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 };