export type CreateApiNotificationsReadArgs = {category?: string | undefined, topic?: string | undefined}; export type CreateApiNotificationsReadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mark all notifications read * * POST /notifications/read */ export const createApiNotificationsRead = async (args: CreateApiNotificationsReadArgs, options?: CreateApiNotificationsReadOptions) => { const {baseUrl = "https://api.magicbell.com/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.category != null) query.append("category", String(args.category)) if (args.topic != null) query.append("topic", String(args.topic)) const url = `${baseUrl.replace(/\/+$/, '')}/notifications/read${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 };