Class ShoppingListController

java.lang.Object
ntnu.idatt2016.v233.SmartMat.controller.group.ShoppingListController

@RestController @RequestMapping("/api/shoppinglist") public class ShoppingListController extends Object
Controller for the shopping list
Version:
1.0
Author:
Stian Lyng
  • Constructor Details

    • ShoppingListController

      public ShoppingListController()
  • Method Details

    • getShoppingListById

      @GetMapping("/{id}") public org.springframework.http.ResponseEntity<ShoppingList> getShoppingListById(@PathVariable("id") long id, org.springframework.security.core.Authentication auth)
      Gets a shopping list by its ID
      Parameters:
      id - the shopping list ID
      authentication - The authentication object of the user.
      Returns:
      the shopping list, or an error if the ID is invalid, or the user dose not have the rights to edit the shopping list
    • getAllShoppingListsByGroupId

      @GetMapping("/group/{groupId}") public org.springframework.http.ResponseEntity<ShoppingList> getAllShoppingListsByGroupId(@PathVariable("groupId") long id, org.springframework.security.core.Authentication auth)
      Gets a shopping list by its group ID
      Parameters:
      id - the request containing the group ID
      authentication - The authentication object of the user.
      Returns:
      the shopping list, or an error if the ID is invalid
    • addItemToShoppingList

      @PostMapping("/addProduct/{shoppingListId}/{ean}") public org.springframework.http.ResponseEntity<?> addItemToShoppingList(@PathVariable("shoppingListId") long shoppingListId, @PathVariable("ean") String ean, org.springframework.security.core.Authentication auth)
      Adds a product to a shopping list
      Parameters:
      shoppingListId - the shopping list ID
      ean - the product EAN
      auth - the authentication object
      Returns:
      the shopping list with the added product, or an error if the shopping list ID or EAN is invalid
    • removeProductFromShoppingList

      @DeleteMapping("/removeProduct/{shoppingListId}/{ean}") public org.springframework.http.ResponseEntity<ShoppingList> removeProductFromShoppingList(@PathVariable("shoppingListId") String shoppingListId, @PathVariable("ean") String ean, org.springframework.security.core.Authentication auth)
      Removes a product from a shopping list
      Parameters:
      shoppingListId - the shopping list ID
      ean - the product EAN
      auth - The authentication object of the user.
      Returns:
      the shopping list with the removed product, or an error if the shopping list ID or EAN is invalid