/* * Copyright 2025 Google. This software is provided as-is, without warranty or representation for any use or purpose. * Your use of it is subject to your agreement with Google. */ package com.example.controller; import com.example.dto.dialogflow.notification.ExternalNotRequestDTO; import com.example.service.notification.NotificationManagerService; import jakarta.validation.Valid; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @RestController @RequestMapping("/api/v1/dialogflow") public class NotificationController { private static final Logger logger = LoggerFactory.getLogger(ConversationController.class); private final NotificationManagerService notificationManagerService; public NotificationController(NotificationManagerService notificationManagerService) { this.notificationManagerService = notificationManagerService; } @PostMapping("/notification") public Mono processNotification(@Valid @RequestBody ExternalNotRequestDTO request) { return notificationManagerService.processNotification(request) .doOnSuccess(response -> logger.info("Successfully processed direct Dialogflow request")) .doOnError(error -> logger.error("Error processing direct Dialogflow request: {}", error.getMessage(), error)) .then(); } }