export type GetApiApiV1RtIdLatestArgs = {id: string, countdown_clock?: boolean | undefined}; export type GetApiApiV1RtIdLatestOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve latest data for a real-time stream * * GET /api/v1/rt/{id}/latest */ export const getApiApiV1RtIdLatest = async (args: GetApiApiV1RtIdLatestArgs, options: GetApiApiV1RtIdLatestOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.countdown_clock != null) query.append("countdown_clock", String(args.countdown_clock)) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/rt/${encodeURIComponent(String(args.id))}/latest${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 undefined };