export type CreateApiSessionsViewingArgs = {sessionId?: (string | null) | undefined, itemId: string}; export type CreateApiSessionsViewingOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Reports that a session is viewing an item. * * POST /Sessions/Viewing */ export const createApiSessionsViewing = async (args: CreateApiSessionsViewingArgs, options?: CreateApiSessionsViewingOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.sessionId != null) query.append("sessionId", String(args.sessionId)) if (args.itemId != null) query.append("itemId", String(args.itemId)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Sessions/Viewing${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 };