Package vaultWeb.controllers
Class PrivateChatPollController
java.lang.Object
vaultWeb.controllers.PrivateChatPollController
@RestController
@RequestMapping("/api/private-chats/{privateChatId}/polls")
public class PrivateChatPollController
extends Object
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<PollResponseDto> createPoll(Long privateChatId, @Valid PollRequestDto pollDto) Creates a new poll in the specified private chat.org.springframework.http.ResponseEntity<Void> deletePoll(Long privateChatId, Long pollId) Deletes a poll from a private chat.org.springframework.http.ResponseEntity<List<PollResponseDto>> Retrieves all polls of a given private chat.org.springframework.http.ResponseEntity<PollResponseDto> updatePoll(Long privateChatId, Long pollId, @Valid PollRequestDto pollDto) Updates an existing poll.org.springframework.http.ResponseEntity<Void> Casts a vote for a specific poll option.
-
Constructor Details
-
PrivateChatPollController
public PrivateChatPollController()
-
-
Method Details
-
createPoll
@PostMapping("") public org.springframework.http.ResponseEntity<PollResponseDto> createPoll(@PathVariable Long privateChatId, @RequestBody @Valid @Valid PollRequestDto pollDto) Creates a new poll in the specified private chat.- Parameters:
privateChatId- the ID of the private chat where the poll will be createdpollDto- the poll data sent in the request body- Returns:
- the created poll as a PollResponseDto
-
vote
@PostMapping("/{pollId}/options/{optionId}/vote") public org.springframework.http.ResponseEntity<Void> vote(@PathVariable Long privateChatId, @PathVariable Long pollId, @PathVariable Long optionId) Casts a vote for a specific poll option.- Parameters:
pollId- the ID of the polloptionId- the ID of the option being voted for- Returns:
- HTTP 204 No Content
-
updatePoll
@PutMapping("/{pollId}") public org.springframework.http.ResponseEntity<PollResponseDto> updatePoll(@PathVariable Long privateChatId, @PathVariable Long pollId, @RequestBody @Valid @Valid PollRequestDto pollDto) Updates an existing poll.- Parameters:
pollId- the ID of the poll to updatepollDto- the new poll data- Returns:
- updated PollResponseDto
-
deletePoll
@DeleteMapping("/{pollId}") public org.springframework.http.ResponseEntity<Void> deletePoll(@PathVariable Long privateChatId, @PathVariable Long pollId) Deletes a poll from a private chat.- Parameters:
pollId- the ID of the poll to delete- Returns:
- HTTP 204 No Content
-
getPolls
@GetMapping("") public org.springframework.http.ResponseEntity<List<PollResponseDto>> getPolls(@PathVariable Long privateChatId) Retrieves all polls of a given private chat.- Parameters:
privateChatId- the ID of the private chat- Returns:
- list of PollResponseDto objects
-