We have several functions in our implemented API:
def findUser(id: Long): Option[User]
case object UsernameAlreadyOccupied
def updateUsername(user: User, username: String): Either[UsernameAlreadyOccupied.type, User]
case object ConnectionError
def saveUser(user: User): Either[ConnectionError.type, Unit]
We need a function that will take an id with a new username and get the data, update the user, and save it in the data warehouse using the functions above. Implement this function but keep in mind that we need our own error tree for it, which has already been implemented.