export type CreateApiV1ChatTranscriptArgs = {roomId: number}; export type CreateApiV1ChatTranscriptOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Returns the chat transcript for a given room id * * POST /v1/chat/transcript * * Also accepts auth: API Key */ export const createApiV1ChatTranscript = async (args: CreateApiV1ChatTranscriptArgs, options: CreateApiV1ChatTranscriptOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.roomId != null) query.append("roomId", String(args.roomId)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/chat/transcript${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };