export type EvidenceId = string; export type GetApiV1EvidenceEvidenceIdVideoClipArgs = {evidence_id: EvidenceId, before_seconds?: number | undefined, after_seconds?: number | undefined}; export type GetApiV1EvidenceEvidenceIdVideoClipOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Render or read a bounded clip around local Evidence * * GET /v1/evidence/{evidence_id}/video-clip * * Also accepts auth: apiKeyAuth */ export const getApiV1EvidenceEvidenceIdVideoClip = async (args: GetApiV1EvidenceEvidenceIdVideoClipArgs, options?: GetApiV1EvidenceEvidenceIdVideoClipOptions) => { const {baseUrl = "https://api.cerul.ai", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "video/mp4") if (args.before_seconds != null) query.append("before_seconds", String(args.before_seconds)) if (args.after_seconds != null) query.append("after_seconds", String(args.after_seconds)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/evidence/${encodeURIComponent(String(args.evidence_id))}/video-clip${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() };