export type GetApiDefectEvidenceEvidenceIdDownloadOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the annotated evidence crop for a defect_evidence row * * GET /defect-evidence/{evidenceId}/download * * Also accepts auth: ApiKeyAuth */ export const getApiDefectEvidenceEvidenceIdDownload = async (options: GetApiDefectEvidenceEvidenceIdDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/jpeg") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/defect-evidence/${encodeURIComponent(String(args.evidenceId))}/download${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() };