Class Notification
java.lang.Object
com.broadleafcommerce.notification.domain.Notification
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware
public class Notification
extends Object
implements com.broadleafcommerce.data.tracking.core.ContextStateAware
A Notification represents a message to send to a
Recipient
.
Notifications have a notificationType which is a business defined value which can be used to
resolve the message.
Notifications have a deliveryType which can determine the provider that will send the message
(for example, EMAIL and SMS).- Author:
- Broadleaf Commerce
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Convenience method to easily add a "cc" recipient using just an email.void
Convenience method to easily add a "to" recipient using an email and name.void
Convenience method to easily add a "cc" recipient using just an email.void
Convenience method to easily add a "to" recipient using an email and name.void
addToEmail
(String emailAddress) Convenience method to easily add a "to" recipient using just an email.void
addToEmail
(String emailAddress, String name) Convenience method to easily add a "to" recipient using an email and name.void
addToMobile
(String mobileNumber) Convenience method to easily add a "to" recipient mobile.void
addToMobile
(String mobileNumber, String name) Convenience method to easily add a "to" recipient using an email and name.protected boolean
boolean
com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
A subset ofTracking
information to expose the context state for this object.The date that this notification was first created.getData()
A String (typically JSON structure) representing the data for the notification template.Delivery Type (EMAIL, SMS) represents how the message will be delivered.getId()
Unique identifier for the notification.The messageBody for the Notification.Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.Tracks the lifecycle of a notification.A generic set of properties that can be added to the notification.List of objects to receive this notification.int
The number of times this message has been retried.TheSender
for this notification.The date that this notification was first created.List of mediaUrls to send to supporting SMS provider.For Notifications with an EMAIL deliveryType, the subject of the EMAIL.Can be used to specify which templateName the provider should use to construct the messageBody.int
hashCode()
void
setContextState
(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.void
setCreateDate
(Instant createDate) The date that this notification was first created.void
A String (typically JSON structure) representing the data for the notification template.void
setDeliveryType
(String deliveryType) Delivery Type (EMAIL, SMS) represents how the message will be delivered.void
Unique identifier for the notification.void
setMessageBody
(String messageBody) The messageBody for the Notification.void
setMessageType
(String messageType) Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.void
setNotificationStatus
(String notificationStatus) Tracks the lifecycle of a notification.void
setProperties
(Map<String, Object> properties) A generic set of properties that can be added to the notification.void
setRecipients
(List<Recipient> recipients) List of objects to receive this notification.void
setRetryCount
(int retryCount) The number of times this message has been retried.void
TheSender
for this notification.void
setSentDate
(Instant sentDate) The date that this notification was first created.void
setSmsMediaUrls
(List<String> smsMediaUrls) List of mediaUrls to send to supporting SMS provider.void
setSubject
(String subject) For Notifications with an EMAIL deliveryType, the subject of the EMAIL.void
setTemplateName
(String templateName) Can be used to specify which templateName the provider should use to construct the messageBody.toString()
-
Constructor Details
-
Notification
public Notification()
-
-
Method Details
-
addToEmail
Convenience method to easily add a "to" recipient using just an email.- Parameters:
emailAddress
-
-
addToEmail
Convenience method to easily add a "to" recipient using an email and name.- Parameters:
emailAddress
-
-
addToMobile
Convenience method to easily add a "to" recipient mobile.- Parameters:
mobileNumber
-
-
addToMobile
Convenience method to easily add a "to" recipient using an email and name.- Parameters:
mobileNumber
-name
-
-
addCc
Convenience method to easily add a "cc" recipient using just an email.- Parameters:
emailAddress
-
-
addCc
Convenience method to easily add a "to" recipient using an email and name.- Parameters:
emailAddress
-
-
addBcc
Convenience method to easily add a "cc" recipient using just an email.- Parameters:
emailAddress
-
-
addBcc
Convenience method to easily add a "to" recipient using an email and name.- Parameters:
emailAddress
-
-
getId
Unique identifier for the notification. Typically a ULID.- Returns:
- the id of this Notification
-
getNotificationStatus
Tracks the lifecycle of a notification.Default States
- NEW : Default state indicating that the message is being prepared
- READY_TO_SEND : Indicates the message is ready to be delivered
- SENDING : The MessageSender has been called to send the message
- SENT : The MessageSender has successfully delivered the message
- RETRY : The MessageSender has indicated that the message could be retried
- ERROR : The message received an error when building or sending.
- Returns:
- the notification status
-
getMessageType
Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.
The messageType is typically use along with the deliveryType to determine the appropriate provider to build and deliver the message.
- Returns:
- the message type of this Notification
-
getDeliveryType
Delivery Type (EMAIL, SMS) represents how the message will be delivered. The deliveryType typically use along with the notificationType to determine the appropriate provider to build and deliver the message. Defaults to "EMAIL"- Returns:
- the delivery type of this Notification
-
getSender
TheSender
for this notification. It is common for the Notification not to know the sender and instead for theNotificationHandler
orMessageSender
to have a default sender configured. -
getRecipients
List of objects to receive this notification. Typically, a notification has a single Recipient. This list provides support for multiple "TO", "CC", and "BCC" on the same notification. -
getSubject
For Notifications with an EMAIL deliveryType, the subject of the EMAIL. Other deliveryTypes may use this field but it is not typical.- Returns:
- the subject of the Notification
-
getTemplateName
Can be used to specify which templateName the provider should use to construct the messageBody. Typically not used as a MessageBuilder will rely on the notificationType (e.g. RESET_PASSWORD or ORDER_CONFIRMATION) and the deliveryType (e.g. SMS, EMAIL) to determine the correct template.- Returns:
- the name of a template used for this notification
-
getData
A String (typically JSON structure) representing the data for the notification template. Most templates will be coded to expect a specific data content and structure.- Returns:
- a JSON structure representing the data for the notification template.
-
getProperties
A generic set of properties that can be added to the notification. These can be used by templates or to target an appropriate NotificationHandler. -
getMessageBody
The messageBody for the Notification. Required for messages that are not built using a templateName and templateData. This field is typically not populated when using a 3rd party processor to process the template.- Returns:
- the message
-
getRetryCount
public int getRetryCount()The number of times this message has been retried.- Returns:
- The number of retry attempts to send this notification.
-
getCreateDate
The date that this notification was first created.- Returns:
- The date that this notification was first created.
-
getSentDate
The date that this notification was first created.- Returns:
- The date that this notification was sent to a provider.
-
getContextState
public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()A subset ofTracking
information to expose the context state for this object.- Specified by:
getContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Returns:
- a subset of
Tracking
information to expose the context state for this object
-
getSmsMediaUrls
List of mediaUrls to send to supporting SMS provider.- Returns:
- the list of media urls.
- See Also:
-
setId
Unique identifier for the notification. Typically a ULID.- Parameters:
id
-
-
setNotificationStatus
Tracks the lifecycle of a notification.Default States
- NEW : Default state indicating that the message is being prepared
- READY_TO_SEND : Indicates the message is ready to be delivered
- SENDING : The MessageSender has been called to send the message
- SENT : The MessageSender has successfully delivered the message
- RETRY : The MessageSender has indicated that the message could be retried
- ERROR : The message received an error when building or sending.
- Parameters:
notificationStatus
-
-
setMessageType
Message Type (RESET_PASSWORD, ORDER_CONFIRMATION) represents the type of notification being sent.
The messageType is typically use along with the deliveryType to determine the appropriate provider to build and deliver the message.
- Parameters:
messageType
-
-
setDeliveryType
Delivery Type (EMAIL, SMS) represents how the message will be delivered. The deliveryType typically use along with the notificationType to determine the appropriate provider to build and deliver the message. Defaults to "EMAIL"- Parameters:
deliveryType
-
-
setSender
TheSender
for this notification. It is common for the Notification not to know the sender and instead for theNotificationHandler
orMessageSender
to have a default sender configured. -
setRecipients
List of objects to receive this notification. Typically, a notification has a single Recipient. This list provides support for multiple "TO", "CC", and "BCC" on the same notification. -
setSubject
For Notifications with an EMAIL deliveryType, the subject of the EMAIL. Other deliveryTypes may use this field but it is not typical.- Parameters:
subject
-
-
setTemplateName
Can be used to specify which templateName the provider should use to construct the messageBody. Typically not used as a MessageBuilder will rely on the notificationType (e.g. RESET_PASSWORD or ORDER_CONFIRMATION) and the deliveryType (e.g. SMS, EMAIL) to determine the correct template.- Parameters:
templateName
-
-
setData
A String (typically JSON structure) representing the data for the notification template. Most templates will be coded to expect a specific data content and structure.- Parameters:
templateData
-
-
setProperties
A generic set of properties that can be added to the notification. These can be used by templates or to target an appropriate NotificationHandler. -
setMessageBody
The messageBody for the Notification. Required for messages that are not built using a templateName and templateData. This field is typically not populated when using a 3rd party processor to process the template.- Parameters:
messageBody
-
-
setRetryCount
public void setRetryCount(int retryCount) The number of times this message has been retried.- Parameters:
retryCount
-
-
setCreateDate
The date that this notification was first created.- Parameters:
createDate
- The date that this notification was first created.
-
setSentDate
The date that this notification was first created.- Parameters:
sentDate
- The date that this notification was sent to a provider.
-
setContextState
public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState) A subset ofTracking
information to expose the context state for this object.- Specified by:
setContextState
in interfacecom.broadleafcommerce.data.tracking.core.ContextStateAware
- Parameters:
contextState
- a subset ofTracking
information to expose the context state for this object
-
setSmsMediaUrls
List of mediaUrls to send to supporting SMS provider.- Parameters:
list
- of media urls to add to an SMS message- See Also:
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode()
-