Class ChallengeConfigController
java.lang.Object
org.ntnu.idi.idatt2106.sparesti.sparestibackend.controller.ChallengeConfigController
@RestController
@CrossOrigin
@RequestMapping("/config/challenge")
public class ChallengeConfigController
extends Object
Controller used to manage endpoints related to a user's challenge configuration.
- Since:
- 23.4.24
- Version:
- 1.0
- Author:
- Yasin A.M.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<ChallengeConfigDTO> createChallengeConfig
(ChallengeConfigDTO challengeConfigDTO, org.springframework.security.core.userdetails.UserDetails userDetails) Creates a challenge configorg.springframework.http.ResponseEntity
<ChallengeConfigDTO> getChallengeConfig
(org.springframework.security.core.userdetails.UserDetails userDetails) Gets a user's challenge configorg.springframework.http.ResponseEntity
<ChallengeConfigDTO> updateChallengeConfig
(ChallengeConfigDTO challengeConfigDTO, org.springframework.security.core.userdetails.UserDetails userDetails) Updates a user's challenge config
-
Constructor Details
-
ChallengeConfigController
public ChallengeConfigController()
-
-
Method Details
-
createChallengeConfig
@PostMapping public org.springframework.http.ResponseEntity<ChallengeConfigDTO> createChallengeConfig(@RequestBody ChallengeConfigDTO challengeConfigDTO, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails) throws UserNotFoundException, BadInputException, ObjectNotValidException Creates a challenge config- Parameters:
challengeConfigDTO
- Wrapper for challenge configuserDetails
- Current user- Returns:
- Wrapper for the created challenge config info
- Throws:
UserNotFoundException
- If the user was not foundBadInputException
- For bad user inputObjectNotValidException
- If supplied config data is invalid
-
getChallengeConfig
@GetMapping public org.springframework.http.ResponseEntity<ChallengeConfigDTO> getChallengeConfig(@AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails) throws ChallengeConfigNotFoundException Gets a user's challenge config- Parameters:
userDetails
- Current user- Returns:
- The user's challenge config
- Throws:
ChallengeConfigNotFoundException
- If the user has not registered a challenge config
-
updateChallengeConfig
@PutMapping public org.springframework.http.ResponseEntity<ChallengeConfigDTO> updateChallengeConfig(@RequestBody ChallengeConfigDTO challengeConfigDTO, @AuthenticationPrincipal org.springframework.security.core.userdetails.UserDetails userDetails) throws ChallengeConfigNotFoundException, BadInputException, ObjectNotValidException Updates a user's challenge config- Parameters:
challengeConfigDTO
- Wrapper for the new challenge config datauserDetails
- Current user- Returns:
- Wrapper of for the updated challenge config's data
- Throws:
ChallengeConfigNotFoundException
- If the user's challenge config could not be foundBadInputException
- On bad user inputObjectNotValidException
- If the supplied config data is invalid
-