import { UserService } from '../../../../core/backend-api/index.js';
import { tryExecute } from '../../../../core/resources/index.js';
/**
 * A server data source for changing the password of a user
 * @class UmbChangeUserPasswordServerDataSource
 */
export class UmbChangeUserPasswordServerDataSource {
    #host;
    /**
     * Creates an instance of UmbChangeUserPasswordServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbChangeUserPasswordServerDataSource
     */
    constructor(host) {
        this.#host = host;
    }
    /**
     * Change the password of a user
     * @param {string} id
     * @param {string} newPassword
     * @returns {*}
     * @memberof UmbChangeUserPasswordServerDataSource
     */
    async changePassword(id, newPassword) {
        if (!id)
            throw new Error('User Id is missing');
        return tryExecute(this.#host, UserService.postUserByIdChangePassword({
            path: { id },
            body: {
                newPassword,
            },
        }));
    }
}
