export type PatchApiUserArgs = {body: {user: {name?: string | undefined, image?: (string | null) | undefined, last_read_at?: ({[key: string]: string} | null) | undefined, announcements_last_seen_at?: (string | null) | undefined, locale?: ('en' | 'fr' | 'es' | 'de' | 'null' | null) | undefined, current_password?: string | undefined, password?: string | undefined, password_confirmation?: string | undefined}}}; export type PatchApiUserOptions = {baseUrl?: string | undefined, KisiLogin?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update current user * * PATCH /user * * Also accepts auth: OAuth2 */ export const patchApiUser = async (args: PatchApiUserArgs, options?: PatchApiUserOptions) => { const {baseUrl = "https://api.kisi.io", fetch: fetchFn = fetch, KisiLogin} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (KisiLogin !== undefined) headers.set("Authorization", KisiLogin) const url = `${baseUrl.replace(/\/+$/, '')}/user${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 };