export type GetApiSiteListsSiteListIdDownloadCsvArgs = {site_list_id: number, target_type?: string | undefined}; export type GetApiSiteListsSiteListIdDownloadCsvOptions = {baseUrl?: string | undefined, Auth0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download Information for a Site List * * GET /site_lists/{site_list_id}/download.csv */ export const getApiSiteListsSiteListIdDownloadCsv = async (args: GetApiSiteListsSiteListIdDownloadCsvArgs, options?: GetApiSiteListsSiteListIdDownloadCsvOptions) => { const {baseUrl = "https://api.mediamath.com/api/v3.0", fetch: fetchFn = fetch, Auth0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.target_type != null) query.append("target_type", String(args.target_type)) if (Auth0 !== undefined) headers.set('authorization', `Bearer ${Auth0}`) const url = `${baseUrl.replace(/\/+$/, '')}/site_lists/${encodeURIComponent(String(args.site_list_id))}/download.csv${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 res.text() };