export type UserPreferencesPatch = unknown; export type PatchApiUsersUserIDConfigArgs = {userID: string, body: UserPreferencesPatch}; export type PatchApiUsersUserIDConfigOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates user config * * PATCH /users/{userID}/config */ export const patchApiUsersUserIDConfig = async (args: PatchApiUsersUserIDConfigArgs, options?: PatchApiUsersUserIDConfigOptions) => { const {baseUrl = "http://localhost/api/v2", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set("Authorization", BearerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.userID))}/config${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };