export type GetApiV3NotificationsArgs = {pageNo: number, limit: number, userIdentifier: string, filter: string, category: string}; export type GetApiV3NotificationsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * GET /v3/notifications */ export const getApiV3Notifications = async (args: GetApiV3NotificationsArgs, options: GetApiV3NotificationsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.pageNo != null) query.append("pageNo", String(args.pageNo)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.userIdentifier != null) query.append("userIdentifier", String(args.userIdentifier)) if (args.filter != null) query.append("filter", String(args.filter)) if (args.category != null) query.append("category", String(args.category)) const url = `${baseUrl.replace(/\/+$/, '')}/v3/notifications${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };