export type CreateApiProfileRawDownloadsDownloadIdFileArgs = {download_id: number, token?: (string | null) | undefined}; export type CreateApiProfileRawDownloadsDownloadIdFileOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a raw file through the platform * * POST /profile/raw/downloads/{download_id}/file */ export const createApiProfileRawDownloadsDownloadIdFile = async (args: CreateApiProfileRawDownloadsDownloadIdFileArgs, options?: CreateApiProfileRawDownloadsDownloadIdFileOptions) => { const {baseUrl = "https://api.leakradar.io", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.token != null) query.append("token", String(args.token)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/profile/raw/downloads/${encodeURIComponent(String(args.download_id))}/file${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };