export type GetApiNhtsaComponentApiV1DownloadDataFileArgs = {testNo: string, vehNo?: string | undefined, compNo?: string | undefined, configNo?: string | undefined, fileName?: string | undefined, fileType: string, docNo?: string | undefined}; export type GetApiNhtsaComponentApiV1DownloadDataFileOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /nhtsa/component/api/v1/downloadDataFile */ export const getApiNhtsaComponentApiV1DownloadDataFile = async (args: GetApiNhtsaComponentApiV1DownloadDataFileArgs, options: GetApiNhtsaComponentApiV1DownloadDataFileOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.testNo != null) query.append("testNo", String(args.testNo)) if (args.vehNo != null) query.append("vehNo", String(args.vehNo)) if (args.compNo != null) query.append("compNo", String(args.compNo)) if (args.configNo != null) query.append("configNo", String(args.configNo)) if (args.fileName != null) query.append("fileName", String(args.fileName)) if (args.fileType != null) query.append("fileType", String(args.fileType)) if (args.docNo != null) query.append("docNo", String(args.docNo)) const url = `${baseUrl.replace(/\/+$/, '')}/nhtsa/component/api/v1/downloadDataFile${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.blob() };