export type CreateApiSessionsSessionIdMessageArgs = {sessionId: string, text: string, header?: (string | null) | undefined, timeoutMs?: (number | null) | undefined}; export type CreateApiSessionsSessionIdMessageOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Issues a command to a client to display a message to the user. * * POST /Sessions/{sessionId}/Message */ export const createApiSessionsSessionIdMessage = async (args: CreateApiSessionsSessionIdMessageArgs, options?: CreateApiSessionsSessionIdMessageOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.text != null) query.append("text", String(args.text)) if (args.header != null) query.append("header", String(args.header)) if (args.timeoutMs != null) query.append("timeoutMs", String(args.timeoutMs)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Sessions/${encodeURIComponent(String(args.sessionId))}/Message${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 };