export type ChangePasswordRequest = unknown; export type CreateApiUsersUserIDChangepasswordArgs = {userID: string, body: ChangePasswordRequest}; export type CreateApiUsersUserIDChangepasswordOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Change a user's password * * POST /users/{userID}/changepassword */ export const createApiUsersUserIDChangepassword = async (args: CreateApiUsersUserIDChangepasswordArgs, options?: CreateApiUsersUserIDChangepasswordOptions) => { 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))}/changepassword${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };