Package uk.gov.service.notify
Interface NotificationClientApi
-
- All Known Implementing Classes:
NotificationClient
public interface NotificationClientApi
-
-
Method Summary
Modifier and Type Method Description TemplatePreviewgenerateTemplatePreview(java.lang.String templateId, java.util.Map<java.lang.String,java.lang.Object> personalisation)The generateTemplatePreview returns a template with the placeholders replaced with the given personalisation.TemplateListgetAllTemplates(java.lang.String templateType)Returns all the templates for your service.NotificationgetNotificationById(java.lang.String notificationId)The getNotificationById method will return aNotificationfor a given notification id.NotificationListgetNotifications(java.lang.String status, java.lang.String notification_type, java.lang.String reference, java.lang.String olderThanId)The getNotifications method will create a GET HTTPS request to retrieve all the notifications.byte[]getPdfForLetter(java.lang.String notificationId)The getPdfForLetter method will return abyte[]containing the PDF contents of a given letter notification.ReceivedTextMessageListgetReceivedTextMessages(java.lang.String olderThanId)The getReceivedTextMessages returns a list ofReceivedTextMessage, the list is sorted by createdAt descending.TemplategetTemplateById(java.lang.String templateId)The getTemplateById returns aTemplategiven the template id.TemplategetTemplateVersion(java.lang.String templateId, int version)The getTemplateVersion returns aTemplategiven the template id and version.SendEmailResponsesendEmail(java.lang.String templateId, java.lang.String emailAddress, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference)The sendEmail method will create an HTTPS POST request.SendEmailResponsesendEmail(java.lang.String templateId, java.lang.String emailAddress, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference, java.lang.String emailReplyToId)The sendEmail method will create an HTTPS POST request.SendLetterResponsesendLetter(java.lang.String templateId, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference)The sendLetter method will create an HTTPS POST request.LetterResponsesendPrecompiledLetter(java.lang.String reference, java.io.File precompiledPDF)The sendPrecompiledLetter method will create an HTTPS POST request.LetterResponsesendPrecompiledLetter(java.lang.String reference, java.io.File precompiledPDF, java.lang.String postage)The sendPrecompiledLetter method will create an HTTPS POST request.LetterResponsesendPrecompiledLetterWithInputStream(java.lang.String reference, java.io.InputStream stream)The sendPrecompiledLetterWithInputStream method will create an HTTPS POST request.LetterResponsesendPrecompiledLetterWithInputStream(java.lang.String reference, java.io.InputStream stream, java.lang.String postage)The sendPrecompiledLetterWithInputStream method will create an HTTPS POST request.SendSmsResponsesendSms(java.lang.String templateId, java.lang.String phoneNumber, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference)The sendSms method will create an HTTPS POST request.SendSmsResponsesendSms(java.lang.String templateId, java.lang.String phoneNumber, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference, java.lang.String smsSenderId)The sendSms method will create an HTTPS POST request.
-
-
-
Method Detail
-
sendEmail
SendEmailResponse sendEmail(java.lang.String templateId, java.lang.String emailAddress, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference) throws NotificationClientException
The sendEmail method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
templateId- The template id is visible on the template page in the application.emailAddress- The email addresspersonalisation- Map representing the placeholders for the template if any. For example, key=name value=Bob Can be an empty map or null when the template does not require placeholders.reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Can be an empty string or null, when you do not require a reference for the notifications.- Returns:
SendEmailResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-an-email-error-codes
-
sendEmail
SendEmailResponse sendEmail(java.lang.String templateId, java.lang.String emailAddress, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference, java.lang.String emailReplyToId) throws NotificationClientException
The sendEmail method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
templateId- The template id is visible on the template page in the application.emailAddress- The email addresspersonalisation- Map representing the placeholders for the template if any. For example, key=name value=Bob Can be an empty map or null when the template does not require placeholders.reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Can be an empty string or null, when you do not require a reference for the notifications.emailReplyToId- An optional identifier for a reply to email address for the notification, rather than use the service default. Service emailReplyToIds can be accessed via the service settings / manage email reply to addresses page. Omit this argument to use the default service email reply to address.- Returns:
SendEmailResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-an-email-error-codes
-
sendSms
SendSmsResponse sendSms(java.lang.String templateId, java.lang.String phoneNumber, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference) throws NotificationClientException
The sendSms method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
templateId- The template id is visible from the template page in the application.phoneNumber- The mobile phone numberpersonalisation- Map representing the placeholders for the template if any. For example, key=name value=Bob Can be an empty map or null when the template does not require placeholders.reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Can be an empty string or null, when you do not require a reference for the notifications.- Returns:
SendSmsResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#error-codes
-
sendSms
SendSmsResponse sendSms(java.lang.String templateId, java.lang.String phoneNumber, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference, java.lang.String smsSenderId) throws NotificationClientException
The sendSms method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
templateId- The template id is visible from the template page in the application.phoneNumber- The mobile phone numberpersonalisation- Map representing the placeholders for the template if any. For example, key=name value=Bob Can be an empty map or null when the template does not require placeholders.reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Can be an empty string or null, when you do not require a reference for the notifications.smsSenderId- An optional identifier for the text message sender of the notification, rather than use the service default. Service smsSenderIds can be accessed via the service settings / manage text message senders page. Omit this argument to use the default service text message sender.- Returns:
SendSmsResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#error-codes
-
sendLetter
SendLetterResponse sendLetter(java.lang.String templateId, java.util.Map<java.lang.String,?> personalisation, java.lang.String reference) throws NotificationClientException
The sendLetter method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
templateId- Find templateId by clicking API info for the template you want to sendpersonalisation- Map representing the placeholders for the template if any. For example, key=name value=Bob. Must include the keys "address_line_1", "address_line_2" and "postcode".reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Can be an empty string or null, when you do not require a reference for the notifications.- Returns:
SendLetterResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-a-letter-error-codes
-
sendPrecompiledLetter
LetterResponse sendPrecompiledLetter(java.lang.String reference, java.io.File precompiledPDF) throws NotificationClientException
The sendPrecompiledLetter method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Cannot be an empty string or null for precompiled PDF files.precompiledPDF- A file containing a PDF conforming to the Notify standards for printing. The file must be a PDF and cannot be null.- Returns:
LetterResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-a-precompiled-letter-error-codes
-
sendPrecompiledLetter
LetterResponse sendPrecompiledLetter(java.lang.String reference, java.io.File precompiledPDF, java.lang.String postage) throws NotificationClientException
The sendPrecompiledLetter method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Cannot be an empty string or null for precompiled PDF files.precompiledPDF- A file containing a PDF conforming to the Notify standards for printing. The file must be a PDF and cannot be null.postage- You can choose first or second class postage for your precompiled letter. Set the value to first for first class, or second for second class. If you do not pass in this argument, the postage will default to second class.- Returns:
LetterResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-a-precompiled-letter-error-codes
-
sendPrecompiledLetterWithInputStream
LetterResponse sendPrecompiledLetterWithInputStream(java.lang.String reference, java.io.InputStream stream) throws NotificationClientException
The sendPrecompiledLetterWithInputStream method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Cannot be an empty string or null for precompiled PDF files.stream- AnInputStreamconforming to the Notify standards for printing. The InputStream cannot be null.- Returns:
LetterResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-a-precompiled-letter-error-codes
-
sendPrecompiledLetterWithInputStream
LetterResponse sendPrecompiledLetterWithInputStream(java.lang.String reference, java.io.InputStream stream, java.lang.String postage) throws NotificationClientException
The sendPrecompiledLetterWithInputStream method will create an HTTPS POST request. A JWT token will be created and added as an Authorization header to the request.- Parameters:
reference- A reference specified by the service for the notification. Get all notifications can be filtered by this reference. This reference can be unique or used used to refer to a batch of notifications. Cannot be an empty string or null for precompiled PDF files.stream- AnInputStreamconforming to the Notify standards for printing. The InputStream cannot be null.postage- You can choose first or second class postage for your precompiled letter. Set the value to first for first class, or second for second class. If you do not pass in this argument, the postage will default to second class.- Returns:
LetterResponse- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#send-a-precompiled-letter-error-codes
-
getNotificationById
Notification getNotificationById(java.lang.String notificationId) throws NotificationClientException
The getNotificationById method will return aNotificationfor a given notification id. The id can be retrieved from theNotificationResponseof asendEmail,sendLetterorsendSmsrequest.- Parameters:
notificationId- The id of the notification.- Returns:
Notification- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#get-the-status-of-one-message-error-codes
-
getPdfForLetter
byte[] getPdfForLetter(java.lang.String notificationId) throws NotificationClientExceptionThe getPdfForLetter method will return abyte[]containing the PDF contents of a given letter notification. The id can be retrieved from theNotificationResponseof asendLetter.- Parameters:
notificationId- The id of the notification.- Returns:
byte[]The raw pdf data.- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#get-a-pdf-for-a-letter-notification-error-codes
-
getNotifications
NotificationList getNotifications(java.lang.String status, java.lang.String notification_type, java.lang.String reference, java.lang.String olderThanId) throws NotificationClientException
The getNotifications method will create a GET HTTPS request to retrieve all the notifications.- Parameters:
status- If status is not empty or null notifications will only return notifications for the given status. Possible statuses are created|sending|delivered|permanent-failure|temporary-failure|technical-failurenotification_type- If notification_type is not empty or null only notifications of the given status will be returned. Possible notificationTypes are sms|emailreference- If reference is not empty or null only the notifications with that reference are returned.olderThanId- If olderThanId is not empty or null only the notifications older than that notification id are returned.- Returns:
NotificationList- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#get-the-status-of-multiple-messages-error-codes
-
getTemplateById
Template getTemplateById(java.lang.String templateId) throws NotificationClientException
The getTemplateById returns aTemplategiven the template id.- Parameters:
templateId- The template id is visible on the template page in the application.- Returns:
Template- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#get-a-template-by-id-error-codes
-
getTemplateVersion
Template getTemplateVersion(java.lang.String templateId, int version) throws NotificationClientException
The getTemplateVersion returns aTemplategiven the template id and version.- Parameters:
templateId- The template id is visible on the template page in the application.version- The version of the template to return- Returns:
Template- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#get-a-template-by-id-and-version-error-codes
-
getAllTemplates
TemplateList getAllTemplates(java.lang.String templateType) throws NotificationClientException
Returns all the templates for your service. Filtered by template type if not null.- Parameters:
templateType- If templateType is not empty or null templates will be filtered by type. Possible template types are email|sms|letter- Returns:
TemplateList- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#get-a-template-by-id-error-codes
-
generateTemplatePreview
TemplatePreview generateTemplatePreview(java.lang.String templateId, java.util.Map<java.lang.String,java.lang.Object> personalisation) throws NotificationClientException
The generateTemplatePreview returns a template with the placeholders replaced with the given personalisation.- Parameters:
templateId- The template id is visible from the template page in the application.personalisation- Map representing the placeholders for the template if any. For example, key=name value=Bob Can be an empty map or null when the template does not require placeholders.- Returns:
Template- Throws:
NotificationClientException- see https://docs.notifications.service.gov.uk/java.html#generate-a-preview-template-error-codes
-
getReceivedTextMessages
ReceivedTextMessageList getReceivedTextMessages(java.lang.String olderThanId) throws NotificationClientException
The getReceivedTextMessages returns a list ofReceivedTextMessage, the list is sorted by createdAt descending.- Parameters:
olderThanId- If olderThanId is not empty or null only the received text messages older than that id are returned.- Returns:
ReceivedTextMessageList- Throws:
NotificationClientException
-
-