Interface NotificationClientApi

  • All Known Implementing Classes:
    NotificationClient

    public interface NotificationClientApi
    • Method Summary

      Modifier and Type Method Description
      TemplatePreview generateTemplatePreview​(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.
      TemplateList getAllTemplates​(java.lang.String templateType)
      Returns all the templates for your service.
      Notification getNotificationById​(java.lang.String notificationId)
      The getNotificationById method will return a Notification for a given notification id.
      NotificationList getNotifications​(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 a byte[] containing the PDF contents of a given letter notification.
      ReceivedTextMessageList getReceivedTextMessages​(java.lang.String olderThanId)
      The getReceivedTextMessages returns a list of ReceivedTextMessage, the list is sorted by createdAt descending.
      Template getTemplateById​(java.lang.String templateId)
      The getTemplateById returns a Template given the template id.
      Template getTemplateVersion​(java.lang.String templateId, int version)
      The getTemplateVersion returns a Template given the template id and version.
      SendEmailResponse sendEmail​(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.
      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)
      The sendEmail method will create an HTTPS POST request.
      SendLetterResponse sendLetter​(java.lang.String templateId, java.util.Map<java.lang.String,​?> personalisation, java.lang.String reference)
      The sendLetter method will create an HTTPS POST request.
      LetterResponse sendPrecompiledLetter​(java.lang.String reference, java.io.File precompiledPDF)
      The sendPrecompiledLetter method will create an HTTPS POST request.
      LetterResponse sendPrecompiledLetter​(java.lang.String reference, java.io.File precompiledPDF, java.lang.String postage)
      The sendPrecompiledLetter method will create an HTTPS POST request.
      LetterResponse sendPrecompiledLetterWithInputStream​(java.lang.String reference, java.io.InputStream stream)
      The sendPrecompiledLetterWithInputStream method will create an HTTPS POST request.
      LetterResponse sendPrecompiledLetterWithInputStream​(java.lang.String reference, java.io.InputStream stream, java.lang.String postage)
      The sendPrecompiledLetterWithInputStream method will create an HTTPS POST request.
      SendSmsResponse sendSms​(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.
      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)
      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 address
        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.
        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 address
        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.
        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 number
        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.
        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 number
        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.
        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 send
        personalisation - 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 - An InputStream conforming 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 - An InputStream conforming 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 a Notification for a given notification id. The id can be retrieved from the NotificationResponse of a sendEmail, sendLetter or sendSms request.
        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 NotificationClientException
        The getPdfForLetter method will return a byte[] containing the PDF contents of a given letter notification. The id can be retrieved from the NotificationResponse of a sendLetter.
        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-failure
        notification_type - If notification_type is not empty or null only notifications of the given status will be returned. Possible notificationTypes are sms|email
        reference - 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 a Template given 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 a Template given 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 of ReceivedTextMessage, 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