Interface UserApi


public interface UserApi
UserApi contains all the api operations handling User in the DzidziApp. This is the customer Api.
  • Method Details

    • findUserById

      User findUserById(UUID userId)
      Finds a user by id.
      Parameters:
      userId - the user id
      Returns:
      the user found
      Throws:
      com.dzidzi.exception.EntityNotFoundException - when the user is not found
    • createUserAccount

      User createUserAccount(AddUserRequest addUserRequest)
      Adds/creates a new user.
      Parameters:
      addUserRequest - the AddUserRequest to create/add a new user
      Returns:
      the newly created user
    • editUserParameters

      User editUserParameters(ChangeUserRequest changeUserRequest)
      Changes the fields/all fields of an existing user. The user id is obtained from the SecurityContextHolder, that is a user can edit their information only when logged in.
      Parameters:
      changeUserRequest - the ChangeUserRequest containing the fields to change
      Returns:
      the updated user
    • getUserByCredentialId

      User getUserByCredentialId()
    • removeAccount

      void removeAccount()
      Removes a user account from the system by the logged-in user.
    • activateAccount

      void activateAccount(String verificationCode)
      Activates user account.
      Parameters:
      verificationCode - the verification code of the user to be activated
    • deactivateAccount

      void deactivateAccount()
      Deactivates logged-in user account
    • reactivateAccount

      void reactivateAccount(String email)
      Reactivate account.
      Parameters:
      email - user email
    • activateAccountAfterDeactivation

      void activateAccountAfterDeactivation(String verificationCode, String password, String repeatedPassword)
      This reactivates user account after account has been deactivated. User has to set a new password to reactivate account.
      Parameters:
      verificationCode - the verification code
      password - the new password
      repeatedPassword - the repeated password
    • findUsers

      DzidziPaginationDTO<User> findUsers(FindUserRequest findUserRequest)
      Finds the paginated users based on the request.
      Parameters:
      findUserRequest - the request containing the params to filter users on
      Returns:
      the DzidziPaginationDTO
    • emailExists

      boolean emailExists(String email)
      Checks if the given email already exists for a user with user role.
      Parameters:
      email - the email
      Returns:
      true is email exist, false otherwise