Class MailjetEventsRestController

java.lang.Object
es.kukenan.smartfi.microservice.communication.controller.MailjetEventsRestController

@RestController public class MailjetEventsRestController extends Object
This rest controller has been created to receive the messages generated by the MailJet "Event API: real-time notifications".
  • Field Details

    • API_PATH

      public static final String API_PATH
      REST API base path.
      See Also:
    • API_AUTHORITY

      public static final String API_AUTHORITY
      Authority (role) required in order to be able to invoke greeting API.
      See Also:
    • HEALTHCHECK_HEADER_RESULT

      private static final String HEALTHCHECK_HEADER_RESULT
      Health check result response header.
      See Also:
    • eventsService

      @Autowired private MailjetEventsService eventsService
      MailJet events service that hold event handling logic.
    • objectMapper

      @Autowired private es.kukenan.smartfi.common.utils.CustomObjectMapper objectMapper
      JSON to object mapper.
    • requestContextManager

      @Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManager
      Request context manager.
  • Constructor Details

    • MailjetEventsRestController

      public MailjetEventsRestController()
  • Method Details

    • receive

      @PostMapping(path="/papi/v1/mailjet/events", consumes="application/json") public org.springframework.http.ResponseEntity<Void> receive(@RequestBody com.fasterxml.jackson.databind.JsonNode body, @RequestParam(name="healthCheck",required=false) Boolean healthCheck)
      Entry-point for MailJet event api real time notifications.
      Parameters:
      body - the event notification.
      healthCheck - health check flag, if present the service will return 204 and do nothing.
      Returns:
      if the event is handled, it returns a response with http 200 status. Otherwise, MailJet will try to re-deliver the event in the future.
    • healthCheck

      private org.springframework.http.ResponseEntity<Void> healthCheck()
      Build the response for a Health Check request of this endpoint.
      Returns:
      the response.
    • safeValueAsString

      private String safeValueAsString(com.fasterxml.jackson.databind.JsonNode node)
      Safely map the value as a string.
      Parameters:
      node - a JsonNode.
      Returns:
      the JSON as string.