export type UpdatePasswordInfo = {currentPassword?: (string | null) | undefined, newPassword?: (string | null) | undefined}; export type UpdateApiUsersUserIdChangePasswordArgs = {userId: string, body: UpdatePasswordInfo}; export type UpdateApiUsersUserIdChangePasswordOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates the password of a user * * PUT /users/{userId}/changePassword */ export const updateApiUsersUserIdChangePassword = async (args: UpdateApiUsersUserIdChangePasswordArgs, options?: UpdateApiUsersUserIdChangePasswordOptions) => { const {baseUrl = "https://connect.signl4.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/users/${encodeURIComponent(String(args.userId))}/changePassword${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };