java.lang.Object
cmpt213.assignment4.packagedeliveries.webappserver.controllers.Controller

@RestController public class Controller extends Object
Rest Controller class. Defines methods that handle requests by client.
  • Constructor Details

    • Controller

      public Controller()
  • Method Details

    • getPingMessage

      @GetMapping("/ping") public String getPingMessage()
      Method handles client starting connection to server.
      Returns:
      Returns a message that tells the client the server is up.
    • getAllPackages

      @GetMapping("/listAll") public String getAllPackages()
      Method handles client request for a list of all packages.
      Returns:
      Returns a String in JSON format of the list to all packages.
    • getOverduePackages

      @GetMapping("/listOverduePackage") public String getOverduePackages()
      Method handles client request for a list of overdue packages.
      Returns:
      Returns a String in JSON format of the list to overdue packages.
    • getUpcomingPackages

      @GetMapping("/listUpcomingPackage") public String getUpcomingPackages()
      Method handles client request for a list of upcoming packages.
      Returns:
      Returns a String in JSON format of the list to upcoming packages.
    • addPackage

      @PostMapping("/addPackage") @ResponseBody @ResponseStatus(CREATED) public String addPackage(@RequestBody String newPackage)
      Method handles client request to add a package.
      Parameters:
      newPackage - String in JSON format of the Package to be added.
      Returns:
      Returns a String in JSON format of updated list to all packages.
    • removePackage

      @PostMapping("/removePackage") @ResponseBody @ResponseStatus(CREATED) public String removePackage(@RequestBody String stringContents)
      Method handles client request to remove a package.
      Parameters:
      stringContents - Index of package to be removed.
      Returns:
      Returns a String in JSON format of updated list to all packages.
    • markPackageAsDelivered

      @PostMapping("/markPackageAsDelivered") @ResponseBody @ResponseStatus(CREATED) public String markPackageAsDelivered(@RequestBody String pkgChangeContent)
      Method handles client request to change package delivery status.
      Parameters:
      pkgChangeContent - A string Array of two values, an index and a boolean.
      Returns:
      Returns a String in JSON format of updated list to all packages.
    • exitClient

      @GetMapping("/exit") public String exitClient()
      Method that handles client request to save data.
      Returns:
      A String message that tells client the data has been saved.