Class JourneyController

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

@RestController @RequestMapping("/v1/journeys") public class JourneyController extends Object
Handles Journey APIs.
  • Constructor Details

    • JourneyController

      public JourneyController()
  • Method Details

    • getJourneyById

      @GetMapping(value="/{journeyId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<JourneyResponse> getJourneyById(@PathVariable int journeyId)
      Enables logged-in admin users to search for a specific journey.
      Parameters:
      journeyId - the journey's id.
      Returns:
      Response body as JourneyResponse.
    • searchJourneys

      @GetMapping(value="/search", produces="application/json") public org.springframework.http.ResponseEntity<List<JourneyResponse>> searchJourneys(@Valid @Valid SearchJourneysRequest searchJourneysRequest)
      Enables users to search for journeys. No need of authentication.
      Parameters:
      searchJourneysRequest - Request body as SearchJourneysRequest.
      Returns:
      Response body as List of JourneyResponse.
    • getJourneysByCurrentDriver

      @GetMapping(value="/drivers/my-journeys", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'SUSPENDED\') or hasAuthority(\'ADMIN\') or hasAuthority(\'DEV\')") public org.springframework.http.ResponseEntity<List<JourneyResponse>> getJourneysByCurrentDriver()
      Enables logged-in user, as a driver, to search for their journeys.
      Returns:
      Response body as List of JourneyResponse.
    • getJourneysByDriverId

      @GetMapping(value="/drivers/{driverId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<List<JourneyResponse>> getJourneysByDriverId(@PathVariable int driverId)
      Enables logged-in admin users to search for journeys of a driver.
      Parameters:
      driverId - the driver's id.
      Returns:
      Response body as List of JourneyResponse.
    • getJourneysByCurrentPassenger

      @GetMapping(value="/passengers/my-journeys", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'SUSPENDED\') or hasAuthority(\'ADMIN\') or hasAuthority(\'DEV\')") public org.springframework.http.ResponseEntity<List<JourneyResponse>> getJourneysByCurrentPassenger()
      Enables logged-in user, as a passenger, to search their journeys.
      Returns:
      Response body as List of JourneyResponse.
    • getJourneysByPassengerId

      @GetMapping(value="/passengers/{passengerId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<List<JourneyResponse>> getJourneysByPassengerId(@PathVariable int passengerId)
      Enables logged-in admin users to search for journeys of a passenger.
      Parameters:
      passengerId - the passenger's id.
      Returns:
      Response body as List of JourneyResponse.
    • createJourney

      @PostMapping(produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<JourneyResponse> createJourney(@Valid @RequestBody @Valid JourneyRequest journeyRequest)
      Enables logged-in user, as a driver, to create a journey.
      Parameters:
      journeyRequest - Request body as JourneyRequest.
      Returns:
      Response body as JourneyResponse.
    • createJourneyByDriverId

      @PostMapping(value="/drivers/{driverId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<JourneyResponse> createJourneyByDriverId(@PathVariable int driverId, @Valid @RequestBody @Valid JourneyRequest journeyRequest)
      Enables logged-in admin users to create a journey for a driver.
      Parameters:
      driverId - the driver id to create a journey for.
      journeyRequest - Request body as JourneyRequest.
      Returns:
      Response body as JourneyResponse.
    • addCurrentPassengerToJourney

      @PostMapping(value="/{journeyId}/add-passenger", produces="application/json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> addCurrentPassengerToJourney(@PathVariable int journeyId)
      Enables logged-in user, as a passenger, to be a passenger of this journey.
      Parameters:
      journeyId - the journey id to add this passenger.
      Returns:
      an empty body.
    • addPassengerToThisJourney

      @PostMapping(value="/{journeyId}/add-passenger/{passengerId}", produces="application/json") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> addPassengerToThisJourney(@PathVariable int journeyId, @PathVariable int passengerId)
      Enables logged-in admin users to add this passenger to this journey.
      Parameters:
      journeyId - the journey id to add this passenger.
      passengerId - the passenger id to be added to this journey.
      Returns:
      an empty body.
    • patchJourney

      @PatchMapping(value="/{journeyId}", consumes="application/json-patch+json") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<JourneyResponse> patchJourney(@PathVariable int journeyId, @Valid @RequestBody @Valid com.github.fge.jsonpatch.JsonPatch patch)
      Enables logged-in admin users or the driver who owns this journey to make correction.
      Parameters:
      journeyId - the journey id to be corrected.
      patch - Request body as JsonPatch.
      Returns:
      Response body as JourneyResponse.
    • deleteJourney

      @DeleteMapping("/{journeyId}") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> deleteJourney(@PathVariable int journeyId)
      Enables logged-in admin users or the driver who owns this journey to delete.
      Parameters:
      journeyId - the journey id to be deleted.
      Returns:
      an empty body.
    • removeCurrentPassengerFromJourney

      @DeleteMapping("{journeyId}/remove-passenger") @PreAuthorize("hasAuthority(\'ACTIVE\') or hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> removeCurrentPassengerFromJourney(@PathVariable int journeyId)
      Enables a user, as a passenger, to no longer be part of this journey.
      Parameters:
      journeyId - the journey id to remove a passenger.
      Returns:
      an empty body.
    • removePassengerFromThisJourney

      @DeleteMapping("{journeyId}/remove-passenger/{passengerId}") @PreAuthorize("hasAuthority(\'ADMIN\')") public org.springframework.http.ResponseEntity<?> removePassengerFromThisJourney(@PathVariable int journeyId, @PathVariable int passengerId)
      Enables logged-in admin users to remove a passenger from a journey.
      Parameters:
      journeyId - the journey id to remove a passenger.
      passengerId - the passenger id to be removed from a journey.
      Returns:
      an empty body.
    • calculateDistance

      @GetMapping(value="/calculateDistance", produces="application/json") public org.springframework.http.ResponseEntity<DistanceResponse> calculateDistance(@Valid @Valid DistanceRequest distanceRequest)
      Enables users to search for the distance of two points. No need of authentication.
      Parameters:
      distanceRequest - the search criteria as DistanceRequest.
      Returns:
      Response body as DistanceResponse.