export type GetApiUsersNotificationsUserIdArgs = {userId: string, countOnly?: boolean | undefined, date?: string | undefined, limit: unknown, page: unknown}; export type GetApiUsersNotificationsUserIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Recieve the users notifications. * * GET /users/notifications/:userId */ export const getApiUsersNotificationsUserId = async (args: GetApiUsersNotificationsUserIdArgs, options?: GetApiUsersNotificationsUserIdOptions) => { const {baseUrl = "https://catalog.archives.gov/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.countOnly != null) query.append("countOnly", String(args.countOnly)) if (args.date != null) query.append("date", String(args.date)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) const url = `${baseUrl.replace(/\/+$/, '')}/users/notifications/:userId${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 };