Class DriverController

java.lang.Object
com.unosquare.carmigo.controller.DriverController

@RestController @RequestMapping("/v1/drivers") public class DriverController extends Object
Handles Driver APIs.
  • Constructor Details

    • DriverController

      public DriverController()
  • Method Details

    • createDriver

      @PostMapping(value="/create", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<DriverResponse> createDriver(@Valid @RequestBody @Valid DriverRequest driverRequest)
      Enables logged-in users to create a driver's profile.
      Parameters:
      driverRequest - Request body as DriverRequest.
      Returns:
      Response body as DriverResponse.
    • createDriverById

      @PostMapping(value="/{driverId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<DriverResponse> createDriverById(@PathVariable int driverId, @Valid @RequestBody @Valid DriverRequest driverRequest)
      Enables logged-in admin users to create a driver's profile for another user.
      Parameters:
      driverId - the user to become a driver.
      driverRequest - Request body as DriverRequest.
      Returns:
      Response body as DriverResponse.
    • getCurrentDriverProfile

      @GetMapping(value="/profile", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'SUSPENDED\') or hasAuthority(\'ADMIN\') or hasAuthority(\'DEV\')") public org.springframework.http.ResponseEntity<DriverResponse> getCurrentDriverProfile()
      Enables logged-in users to see their driver's profiles.
      Returns:
      Response body as DriverResponse.
    • getDriverById

      @GetMapping(value="/{driverId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<DriverResponse> getDriverById(@PathVariable int driverId)
      Enables logged-in admin users to see other driver's profiles.
      Parameters:
      driverId - the driver's id.
      Returns:
      Response body as DriverResponse.
    • deleteCurrentDriver

      @DeleteMapping @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> deleteCurrentDriver()
      Enables logged-in user's to delete their driver's profile.
      Returns:
      an empty body.
    • deleteDriverById

      @DeleteMapping("/{driverId}") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> deleteDriverById(@PathVariable int driverId)
      Enables logged-in admin users to delete a driver's profile.
      Parameters:
      driverId - the driver's id to be deleted.
      Returns:
      an empty body.