export type NotificationLevel = 'Normal' | 'Warning' | 'Error'; export type CreateApiNotificationsAdminArgs = {url?: (string | null) | undefined, level?: NotificationLevel | undefined, name?: (string | null) | undefined, description?: (string | null) | undefined}; export type CreateApiNotificationsAdminOptions = {baseUrl?: string | undefined, CustomAuthentication?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sends a notification to all admins. * * POST /Notifications/Admin */ export const createApiNotificationsAdmin = async (args: CreateApiNotificationsAdminArgs, options?: CreateApiNotificationsAdminOptions) => { const {baseUrl = "http://localhost", fetch: fetchFn = fetch, CustomAuthentication} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.url != null) query.append("url", String(args.url)) if (args.level != null) query.append("level", String(args.level)) if (args.name != null) query.append("name", String(args.name)) if (args.description != null) query.append("description", String(args.description)) if (CustomAuthentication !== undefined) headers.set("X-Emby-Authorization", CustomAuthentication) const url = `${baseUrl.replace(/\/+$/, '')}/Notifications/Admin${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 };