export type GetApiUsersIdArgs = {id: number, module_permissions?: string | undefined}; export type GetApiUsersIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve an entry * * GET /users/{id} */ export const getApiUsersId = async (args: GetApiUsersIdArgs, options?: GetApiUsersIdOptions) => { const {baseUrl = "https://www.rcac.purdue.edu/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.module_permissions != null) query.append("module_permissions", String(args.module_permissions)) const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.id))}${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 };