export type GetApiThreatProfilesProfileIdDownloadFormatArgs = {'x-apikey': string, format: 'json' | 'csv' | 'stix', profile_id: string, limit?: string | undefined}; export type GetApiThreatProfilesProfileIdDownloadFormatOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export IoCs * * GET /threat_profiles/{profile_id}/download/{format} */ export const getApiThreatProfilesProfileIdDownloadFormat = async (args: GetApiThreatProfilesProfileIdDownloadFormatArgs, options?: GetApiThreatProfilesProfileIdDownloadFormatOptions) => { const {baseUrl = "https://www.virustotal.com/api/v3", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['x-apikey'] != null) headers.set("x-apikey", String(args['x-apikey'])) if (args.limit != null) query.append("limit", String(args.limit)) const url = `${baseUrl.replace(/\/+$/, '')}/threat_profiles/${encodeURIComponent(String(args.profile_id))}/download/${encodeURIComponent(String(args.format))}${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 };