Documentation
¶
Index ¶
- Constants
- type APIError
- type Client
- func (c *Client) GetNotification(id string) (*Notification, error)
- func (c *Client) ListNotifications(filters Filters) (*NotificationList, error)
- func (c *Client) SendEmail(emailAddress, templateID string, personalisation templateData, ...) (*NotificationEntry, error)
- func (c *Client) SendLetter(letter, templateID string, personalisation templateData, reference string) (*NotificationEntry, error)
- func (c *Client) SendSms(phoneNumber, templateID string, personalisation templateData, reference string) (*NotificationEntry, error)
- type Configuration
- type Error
- type Filters
- type Notification
- type NotificationEntry
- type NotificationList
- type Pagination
- type Payload
- type Template
Constants ¶
const BaseURLProduction = "https://api.notifications.service.gov.uk"
BaseURLProduction is the The API endpoint for Notify production.
const PathNotificationList = "/v2/notifications"
PathNotificationList directs to the appropriate endpoint responsible for retrieving the list of notifications.
const PathNotificationLookup = "/v2/notifications/%s"
PathNotificationLookup directs to the appropriate endpoint responsible for lookup of any notifications.
const PathNotificationSendEmail = "/v2/notifications/email"
PathNotificationSendEmail directs to the appropriate endpoint responsible for sending an email message.
const PathNotificationSendLetter = "/v2/notifications/letter"
PathNotificationSendLetter directs to the appropriate endpoint responsible for sending a letter.
const PathNotificationSendSms = "/v2/notifications/sms"
PathNotificationSendSms directs to the appropriate endpoint responsible for sending a text message.
const Version = "1.0.0"
Version of this client. This follows Semantic Versioning (http://semver.org/)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Configuration Configuration
}
Client for accessing GOV.UK Notify.
Before using this client you must have:
- created an account with GOV.UK Notify
- found your Service ID and generated an API Key.
- created at least one template and know its ID.
func New ¶
func New(configuration Configuration) (*Client, error)
New instance of a client will be generated for the use
func (*Client) GetNotification ¶
func (c *Client) GetNotification(id string) (*Notification, error)
GetNotification will fire a request that returns details about the passed notification ID.
func (*Client) ListNotifications ¶
func (c *Client) ListNotifications(filters Filters) (*NotificationList, error)
ListNotifications will fire a request that returns a list of all notifications for the current Service ID.
func (*Client) SendEmail ¶
func (c *Client) SendEmail(emailAddress, templateID string, personalisation templateData, reference string) (*NotificationEntry, error)
SendEmail will fire a request to Send an Email message.
func (*Client) SendLetter ¶
func (c *Client) SendLetter(letter, templateID string, personalisation templateData, reference string) (*NotificationEntry, error)
SendLetter will fire a request to Send a Letter. TODO Establish what this actually is and prepare for usage.
type Configuration ¶
type Configuration struct { APIKey []byte BaseURL *url.URL Claims *jwt.StandardClaims HTTPClient *http.Client ServiceID string }
Configuration of the Notifications Go Client.
func (*Configuration) Authenticate ¶
func (c *Configuration) Authenticate(secret []byte) (*string, error)
Authenticate a JWT token. JwtTokenCreator uses HMAC-SHA256 signature, by default.
type Filters ¶
type Filters struct { OlderThan string `json:"older_than"` Reference string `json:"reference"` Status string `json:"status"` TemplateType string `json:"template_type"` }
Filters for the notifications to be looked at.
func (*Filters) ToURLValues ¶
ToURLValues will convert the struct into the url.Values.
type Notification ¶
type Notification struct { ID string `json:"id"` Body string `json:"body"` Subject string `json:"subject"` Reference string `json:"reference"` Email string `json:"email_address"` Phone string `json:"phone_number"` Line1 string `json:"line_1"` Line2 string `json:"line_2"` Line3 string `json:"line_3"` Line4 string `json:"line_4"` Line5 string `json:"line_5"` Line6 string `json:"line_6"` Postcode string `json:"postcode"` Type string `json:"type"` Status string `json:"status"` Template Template `json:"template"` CreatedAt time.Time `json:"created_at"` SentAt time.Time `json:"sent_at"` }
Notification is the object build and returned by GOV.UK Notify.
type NotificationEntry ¶
type NotificationEntry struct { Content map[string]string `json:"content"` ID string `json:"id"` Reference string `json:"reference"` Template Template `json:"template"` URI string `json:"uri"` }
NotificationEntry is the struct aroung the successful response from the API collected upon the creation of a new Notification.
type NotificationList ¶
type NotificationList struct { Client *Client `json:"-"` Notifications []Notification `json:"notifications"` Links Pagination `json:"links"` }
NotificationList is one the responses from GOV.UK Notify.
func (*NotificationList) Next ¶
func (nl *NotificationList) Next() error
Next page of the list should be loaded in place of the old one.
func (*NotificationList) Previous ¶
func (nl *NotificationList) Previous() error
Previous page of the list should be loaded in place of the old one.
type Pagination ¶
type Pagination struct { Current string `json:"current"` Next string `json:"next"` Previous string `json:"previous"` }
Pagination of the list that's returned as part of the JSON response.
type Payload ¶
type Payload struct { EmailAddress string `json:"email_address,omitempty"` Letter string `json:"letter,omitempty"` // TODO Establish what this actually is and prepare for usage. Personalisation map[string]string `json:"personalisation,omitempty"` PhoneNumber string `json:"phone_number,omitempty"` Reference string `json:"reference,omitempty"` TemplateID string `json:"template_id,omitempty"` }
Payload that will be send with different set of requests by the client.
func NewPayload ¶
func NewPayload(service, recipient, templateID string, personalisation templateData, reference string) *Payload
NewPayload is a function that takes different parameters and initialises the Payload struct, to be used in the calls.