Class PlatformUserService

java.lang.Object
com.unosquare.carmigo.service.PlatformUserService

@Service public class PlatformUserService extends Object
Handles requests regarding the PlatformUser entity.
  • Constructor Details

    • PlatformUserService

      public PlatformUserService()
  • Method Details

    • createPlatformUser

      @CachePut(value="platformUser", key="#result.id") public PlatformUserResponse createPlatformUser(PlatformUserRequest platformUserRequest)
      Creates a platform user. This new user's access status is set to STAGED.
      Parameters:
      platformUserRequest - the requirements as PlatformUserRequest.
      Returns:
      a PlatformUserResponse.
    • confirmEmail

      public void confirmEmail(String email)
      Allows a user to confirm their email. Upon confirmation, their access status is set to ACTIVE which gives them more access.
      Parameters:
      email - the user's email.
    • cacheableGetPlatformUserById

      @Cacheable(value="platformUser", key="#platformUserId") public PlatformUserResponse cacheableGetPlatformUserById(int platformUserId)
      Fetches a platform user and caches them.
      Parameters:
      platformUserId - the platform user id to search for.
      Returns:
      a PlatformUserResponse.
    • refreshableGetPlatformUserById

      @CachePut(value="platformUser", key="#platformUserId") public PlatformUserResponse refreshableGetPlatformUserById(int platformUserId)
      Fetches a platform user and refreshes the cache.
      Parameters:
      platformUserId - the platform user id to search for.
      Returns:
      a PlatformUserResponse.
    • patchPlatformUserById

      @CachePut(value="platformUser", key="#platformUserId") public PlatformUserResponse patchPlatformUserById(int platformUserId, com.github.fge.jsonpatch.JsonPatch patch)
      Corrects platform user information.
      Pass an array of a JsonPatch body with the operation, the path and the value.
      Accepted operation values are “add”, "remove", "replace", "move", "copy" and "test".
      Here is an example which updates a user's phone number and their access status:
         [
           {
             "op": "replace",
             "path": "/phoneNumber",
             "value": "02875935862"
           },
           {
             "op": "replace",
             "path": "/userAccessStatus/id",
             "value": "5"
           }
         ]
       
      Parameters:
      platformUserId - the platform user id to be updated.
      patch - a JsonPatch.
      Returns:
      a PlatformUserResponse.
    • deletePlatformUserById

      @CacheEvict(value="platformUser", key="#platformUserId") public void deletePlatformUserById(int platformUserId)
      Deletes a platform user.
      Warning: it will also delete (if any) the driver and/or the passenger associated. Example: Tom is a platform user who is also a driver as well as a passenger. When deleting Tom's platform user profile, his driver's and passenger's profiles will also be deleted.
      Parameters:
      platformUserId - the platform user id to be deleted.