Class SlackNotificationHandler
java.lang.Object
es.kukenan.smartfi.microservice.communication.service.provider.impl.slack.SlackNotificationHandler
- All Implemented Interfaces:
NotificationProviderHandler
@Component
public class SlackNotificationHandler
extends Object
implements NotificationProviderHandler
Service class that holds all the mail notification sending bussiness logic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringSlack delivery channel.private SlackClientMailJet Rest client. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaccepts(NotificationChannel channel, NotificationProvider provider) Return true if this handler is able to send the given notification request.private StringbuildTemplate(String template) private NotificationResponsehandleResult(String to, NotificationRequest request, Exception ex) Process response messages.send(NotificationRequest request, Template template, NotificationSenderService.MessageContext messageContext) Send a notification.
-
Field Details
-
channel
Slack delivery channel. Accepts direct-pm in order to send the message directly to a user or a fixed channel identifier, for example 013XNDSF7G. -
slackClient
MailJet Rest client.
-
-
Constructor Details
-
SlackNotificationHandler
public SlackNotificationHandler()
-
-
Method Details
-
accepts
Description copied from interface:NotificationProviderHandlerReturn true if this handler is able to send the given notification request.- Specified by:
acceptsin interfaceNotificationProviderHandler- Parameters:
channel- notification channel.provider- the provider to use.- Returns:
- true if this handler is able to send the given notification request.
-
send
public NotificationResponse send(NotificationRequest request, Template template, NotificationSenderService.MessageContext messageContext) Description copied from interface:NotificationProviderHandlerSend a notification.- Specified by:
sendin interfaceNotificationProviderHandler- Parameters:
request- notification request.template- the template to use to send the notification request.messageContext- the message context of the notification.- Returns:
- the notification entity to store.
-
handleResult
Process response messages.- Parameters:
to- message destination address.request-NotificationRequest-ex- Exception if any was thrown, that is, the slack message was not sent.- Returns:
- the
NotificationResponseobject.
-
buildTemplate
-