export type PatchApiUsersUpdateDetailsUserIdArgs = {user_id: number, body: {phone?: string | undefined, email?: string | undefined, current_password?: string | undefined, new_password?: string | undefined, confirm_new_password?: string | undefined, redirect_uri?: string | undefined}}; export type PatchApiUsersUpdateDetailsUserIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update user details. Need permission: account_change_password * * PATCH /users/update_details/{user_id} */ export const patchApiUsersUpdateDetailsUserId = async (args: PatchApiUsersUpdateDetailsUserIdArgs, options?: PatchApiUsersUpdateDetailsUserIdOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") const url = `${baseUrl.replace(/\/+$/, '')}/users/update_details/${encodeURIComponent(String(args.user_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };