NotificationsController

@RestController
@RequestMapping(value = ["/api/v1/notifications"])
class NotificationsController(notificationsListService: NotificationsListService)

Controller with endpoints to work with notifications

Constructors

Link copied to clipboard
constructor(notificationsListService: NotificationsListService)

Functions

Link copied to clipboard
@GetMapping(value = ["/new"])
fun anyNewNotification(@RequestHeader(value = "user-token") token: String): NewNotificationDto

GET endpoint for indicating whether there is any unread notification

Link copied to clipboard
@DeleteMapping(value = ["{notificationId}"])
fun deleteNotificationById(@RequestHeader(value = "user-token") token: String, @PathVariable notificationId: Long)

DELETE endpoint for deleting specified notification

Link copied to clipboard
@PostMapping(value = ["/delete"])
fun deleteNotifications(@RequestHeader(value = "user-token") token: String, @RequestBody notificationIds: NotificationIdsDto?)

POST endpoint for deleting notifications

Link copied to clipboard
@GetMapping
fun getNotifications(@RequestHeader(value = "user-token") token: String, page: Int, size: Int): Page<NotificationDto>

GET endpoint for listing all notifications

Link copied to clipboard
@ExceptionHandler(value = [IllegalArgumentException::class])
fun handleNotFound(e: IllegalArgumentException): ResponseEntity<String>
@ExceptionHandler(value = [NoSuchElementException::class])
fun handleNotFound(e: NoSuchElementException): ResponseEntity<String>

Exception handler

Link copied to clipboard
@PostMapping
fun readNotifications(@RequestHeader(value = "user-token") token: String, @RequestBody notificationIds: NotificationIdsDto?)

POST endpoint for marking notifications as read