export type CameraId = string; export type SnapshotChannel = 'main' | 'package'; export type ForceHighQuality = 'true' | 'false'; export type GetApiV1CamerasIdSnapshotArgs = {id: CameraId, channel?: SnapshotChannel | undefined, highQuality?: ForceHighQuality | undefined}; export type GetApiV1CamerasIdSnapshotOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get camera snapshot * * GET /v1/cameras/{id}/snapshot */ export const getApiV1CamerasIdSnapshot = async (args: GetApiV1CamerasIdSnapshotArgs, options?: GetApiV1CamerasIdSnapshotOptions) => { const {baseUrl = "https://api.ui.com/v1/connector/consoles/942A6FF664C0000000000964970E0000000009E710560000000068A9873F:9999999999/proxy/protect/integration", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/jpeg") if (args.channel != null) query.append("channel", String(args.channel)) if (args.highQuality != null) query.append("highQuality", String(args.highQuality)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/cameras/${encodeURIComponent(String(args.id))}/snapshot${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() };