notifications-ruby-client 3.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba933202a1dfa0c6f3ceb4c368a9464fadf69e515123ef2799b543bbd05f0ab4
4
- data.tar.gz: 2e92cb7452ba11d8c35630291c204ec3b2c6c960ca1d237a435a1c33105bf0d5
3
+ metadata.gz: 5c2ca0e37a78051cacf6b35de97f7a2a6e1e45e41355d2cb91a3ded84571a357
4
+ data.tar.gz: cf2652751ae7b86361688e18ddd6dc6487e88dfb7d7758a119720cb5b7544ecd
5
5
  SHA512:
6
- metadata.gz: d8003252e3acca422ccf95b1e280ad87cb2c6fd32f8c6bb8c599823fa6aceaae4f7e1913c0033dd34700caaa1ae89b346959b8d56343c447f5acdb922cada589
7
- data.tar.gz: a20da50f07aac17fc2d632246033f09f57a891593b7eb54124728906246e78fc348d22e394a5d928f81e720ac9cdc9497843098041046edf38cf2937efa39a5a
6
+ metadata.gz: 037f381822efe210e32e3a4a398f946cba3923f2593826a91486ea0710544cf0c72bc0d38b88ff223705bcb984763bbb51052d0a43090223f47bf0607f82348d
7
+ data.tar.gz: b0980abf21fd435ad2350f256b04b4cc9ef3db892d642f753e5ba3be4d029f4359a1e37efff6b2197d74b0652c1b4ae49857f3d253a332f9b4ffad945b730afb
data/.gitignore CHANGED
@@ -11,7 +11,5 @@
11
11
  /vendor
12
12
  environment.sh
13
13
  docker.env
14
- /.idea/
15
- /.idea/vcs.xml
16
- docker.env
17
- vendor
14
+ .idea
15
+ *.gem
@@ -1,3 +1,29 @@
1
+ ## 5.2.0
2
+
3
+ * Add support for an optional `is_csv` parameter in the `prepare_upload()` function. This fixes a bug when sending a CSV file by email. This ensures that the file is downloaded as a CSV rather than a TXT file.
4
+
5
+ ## 5.1.2
6
+
7
+ * Change filesize too big exception message to refer to files rather than documents.
8
+
9
+ ## 5.1.1
10
+
11
+ * Exceptions now return the error message when calling `#to_s` on them. This will make services like Sentry correctly display the full error description.
12
+
13
+ ## 5.1.0
14
+
15
+ * Added new `get_pdf_for_letter` method
16
+ * accepts a notification id argument
17
+ * returns a string containing the final printable PDF for a precompiled or templated letter
18
+
19
+ ## 5.0.0
20
+
21
+ * Dropped support for Ruby 2.3. Official support for this version ended in March (https://www.ruby-lang.org/en/news/2019/03/31/support-of-ruby-2-3-has-ended/)
22
+
23
+ ## 4.0.0
24
+
25
+ * `RequestError.message` now returns a string, not an array of hashes – see https://github.com/alphagov/notifications-ruby-client/pull/72
26
+
1
27
  ## 3.1.0
2
28
 
3
29
  * Added `html` field to the TemplatePreview response, so users can see
@@ -28,7 +28,7 @@ export SMS_TEMPLATE_ID="valid sms_template_id"
28
28
  export LETTER_TEMPLATE_ID="valid letter_template_id"
29
29
  export EMAIL_REPLY_TO_ID="valid email reply to id"
30
30
  export SMS_SENDER_ID="valid sms_sender_id - to test sending to a receiving number, so needs to be a valid number"
31
- export API_SENDING_KEY="API_whitelist_key for sending a SMS to a receiving number"
31
+ export API_SENDING_KEY="API_team_key for sending a SMS to a receiving number"
32
32
  export INBOUND_SMS_QUERY_KEY="API_test_key to get received text messages"
33
33
  ```
34
34
 
@@ -37,3 +37,8 @@ To run the integration tests:
37
37
  ```
38
38
  make integration-test
39
39
  ```
40
+
41
+
42
+ ## Releasing (for notify developers only)
43
+
44
+ To release manually, run `make publish-to-rubygems`. You will need to set the environment variable `GEM_HOST_API_KEY`, which can be found in the credentials repo under `credentials/rubygems/api_key`.
@@ -23,7 +23,7 @@ require 'notifications/client'
23
23
  client = Notifications::Client.new(api_key)
24
24
  ```
25
25
 
26
- To get an API key, [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/) and go to the __API integration__ page. You can find more information in the [API keys](/ruby.html#api-keys) section of this documentation.
26
+ To get an API key, [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page. You can find more information in the [API keys](#api-keys) section of this documentation.
27
27
 
28
28
  # Send a message
29
29
 
@@ -52,7 +52,13 @@ phone_number:"+447900900123"
52
52
 
53
53
  #### template_id (required)
54
54
 
55
- Sign in to [GOV.UK Notify](https://www.notifications.service.gov.uk/) and go to the __Templates__ page to find the template ID. For example:
55
+ To find the template ID:
56
+
57
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
58
+ 1. Go to the __Templates__ page and select the relevant template.
59
+ 1. Select __Copy template ID to clipboard__.
60
+
61
+ For example:
56
62
 
57
63
  ```ruby
58
64
  template_id:"f33517ff-2a88-4f6e-b855-c550268ce08a"
@@ -65,7 +71,7 @@ If a template has placeholder fields for personalised information such as name o
65
71
  ```ruby
66
72
  personalisation: {
67
73
  name: "John Smith",
68
- ID: "300241",
74
+ ID: "300241",
69
75
  }
70
76
  ```
71
77
 
@@ -83,12 +89,13 @@ You can leave out this argument if you do not have a reference.
83
89
 
84
90
  #### sms_sender_id (optional)
85
91
 
86
- A unique identifier of the sender of the text message notification. You can find this information on the __Text Message sender__ settings screen.
92
+ A unique identifier of the sender of the text message notification.
93
+
94
+ To find the text message sender:
87
95
 
88
- 1. Sign in to your GOV.UK Notify account.
89
- 1. Go to __Settings__.
90
- 1. If you need to change to another service, select __Switch service__ in the top right corner of the screen and select the correct one.
91
- 1. Go to the __Text Messages__ section and select __Manage__ on the __Text Message sender__ row.
96
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
97
+ 1. Go to the __Settings__ page.
98
+ 1. In the __Text Messages__ section, select __Manage__ on the __Text Message sender__ row.
92
99
 
93
100
  You can then either:
94
101
 
@@ -106,7 +113,7 @@ You can leave out this argument if your service only has one text message sender
106
113
 
107
114
  ### Response
108
115
 
109
- If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](/ruby.html#method), the object is named `smsresponse`.
116
+ If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](#method), the object is named `smsresponse`.
110
117
 
111
118
  You can then call different methods on this object:
112
119
 
@@ -118,23 +125,23 @@ You can then call different methods on this object:
118
125
  |`smsresponse.template`|Contains the `id`, `version` and `uri` of the template|Hash|
119
126
  |`smsresponse.uri`|Notification URL|String|
120
127
 
121
- If you are using the [test API key](/ruby.html#test), all your messages come back with a `delivered` status.
128
+ If you are using the [test API key](#test), all your messages come back with a `delivered` status.
122
129
 
123
- All messages sent using the [team and whitelist](#team-and-whitelist) or [live](#live) keys appear on your GOV.UK Notify dashboard.
130
+ All messages sent using the [team and guest list](#team-and-guest-list) or [live](#live) keys appear on your GOV.UK Notify dashboard.
124
131
 
125
132
  ### Error codes
126
133
 
127
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
134
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
128
135
 
129
136
  |error.code|error.message|class|How to fix|
130
137
  |:---|:---|:---|:---|
131
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
132
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
133
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
134
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
135
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"`<br>`}]`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
136
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|`ClientError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
137
- |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|`ServerError`|Notify was unable to process the request, resend your notification|
138
+ |`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
139
+ |`400`|`BadRequestError: Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
140
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
141
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
142
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#rate-limits) for more information|
143
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`ClientError`|Refer to [service limits](#daily-limits) for the limit number|
144
+ |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
138
145
 
139
146
  ## Send an email
140
147
 
@@ -159,7 +166,13 @@ email_address: "sender@something.com"
159
166
 
160
167
  #### template_id (required)
161
168
 
162
- Sign in to [GOV.UK Notify](https://www.notifications.service.gov.uk/) and go to the __Templates__ page to find the template ID. For example:
169
+ To find the template ID:
170
+
171
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
172
+ 1. Go to the __Templates__ page and select the relevant template.
173
+ 1. Select __Copy template ID to clipboard__.
174
+
175
+ For example:
163
176
 
164
177
  ```ruby
165
178
  template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
@@ -172,7 +185,7 @@ If a template has placeholder fields for personalised information such as name o
172
185
  ```ruby
173
186
  personalisation: {
174
187
  name: "John Smith",
175
- year: "2016"
188
+ year: "2016"
176
189
  }
177
190
  ```
178
191
 
@@ -190,14 +203,15 @@ You can leave out this argument if you do not have a reference.
190
203
 
191
204
  #### email_reply_to_id (optional)
192
205
 
193
- This is an email reply-to address specified by you to receive replies from your users. Your service cannot go live until you set up at least one of these email addresses.
206
+ This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.
194
207
 
195
- 1. Sign into your GOV.UK Notify account.
196
- 1. Go to __Settings__.
197
- 1. If you need to change to another service, select __Switch service__ in the top right corner of the screen and select the correct one.
198
- 1. Go to the __Email__ section and select __Manage__ on the __Email reply-to addresses__ row.
199
- 1. Select __Change__ to specify the email address to receive replies, and select __Save__.
208
+ To add a reply-to email address:
200
209
 
210
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
211
+ 1. Go to the __Settings__ page.
212
+ 1. In the __Email__ section, select __Manage__ on the __Reply-to email addresses__ row.
213
+ 1. Select __Add reply-to address__.
214
+ 1. Enter the email address you want to use, and select __Add__.
201
215
 
202
216
  For example:
203
217
 
@@ -207,25 +221,31 @@ email_reply_to_id: '8e222534-7f05-4972-86e3-17c5d9f894e2'
207
221
 
208
222
  You can leave out this argument if your service only has one email reply-to address, or you want to use the default email address.
209
223
 
210
- ## Send a document by email
224
+ ## Send a file by email
211
225
 
212
- Send files without the need for email attachments.
226
+ To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.
213
227
 
214
- This is an invitation-only feature. [Contact the GOV.UK Notify team](https://www.notifications.service.gov.uk/support) to enable this function for your service.
228
+ The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
215
229
 
216
- To send a document by email, add a placeholder field to the template then upload a file. The placeholder field will contain a secure link to download the document.
230
+ ### Add contact details to the file download page
217
231
 
218
- ### Add a placeholder field to the template
232
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
233
+ 1. Go to the __Settings__ page.
234
+ 1. In the __Email__ section, select __Manage__ on the __Send files by email__ row.
235
+ 1. Enter the contact details you want to use, and select __Save__.
219
236
 
220
- 1. Sign in to [GOV.UK Notify](https://www.notifications.service.gov.uk/).
237
+ ### Add a placeholder to the template
238
+
239
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
221
240
  1. Go to the __Templates__ page and select the relevant email template.
222
- 1. Add a placeholder field to the email template using double brackets. For example:
241
+ 1. Select __Edit__.
242
+ 1. Add a placeholder to the email template using double brackets. For example:
223
243
 
224
- "Download your document at: ((link_to_document))"
244
+ "Download your file at: ((link_to_file))"
225
245
 
226
- ### Upload your document
246
+ ### Upload your file
227
247
 
228
- The document you upload must be a PDF file smaller than 2MB.
248
+ You can upload PDF, CSV, .odt, .txt and MS Word Document files. Your file must be smaller than 2MB. [Contact the GOV.UK Notify team](https://www.notifications.service.gov.uk/support/ask-question-give-feedback) if you need to send other file types.
229
249
 
230
250
  1. Pass the file object as an argument to the `Notifications.prepare_upload` helper method.
231
251
  1. Pass the result into the personalisation argument.
@@ -238,14 +258,29 @@ File.open("file.pdf", "rb") do |f|
238
258
  personalisation: {
239
259
  first_name: "Amala",
240
260
  application_date: "2018-01-01",
241
- link_to_document: Notifications.prepare_upload(f),
261
+ link_to_file: Notifications.prepare_upload(f),
262
+ }
263
+ end
264
+ ```
265
+
266
+ #### CSV Files
267
+
268
+ Uploads for CSV files should use the `is_csv` parameter on the `prepare_upload()` helper method. For example:
269
+
270
+ ```ruby
271
+ File.open("file.csv", "rb") do |f|
272
+ ...
273
+ personalisation: {
274
+ first_name: "Amala",
275
+ application_date: "2018-01-01",
276
+ link_to_file: Notifications.prepare_upload(f, is_csv=true),
242
277
  }
243
278
  end
244
279
  ```
245
280
 
246
281
  ### Response
247
282
 
248
- If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](/ruby.html#send-an-email-method), the object is named `emailresponse`.
283
+ If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](#send-an-email-method), the object is named `emailresponse`.
249
284
 
250
285
  You can then call different methods on this object to return the requested information.
251
286
 
@@ -259,29 +294,31 @@ You can then call different methods on this object to return the requested infor
259
294
 
260
295
  ### Error codes
261
296
 
262
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
297
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
263
298
 
264
299
  |error.code|error.message|class|How to fix|
265
300
  |:--- |:---|:---|:---|
266
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
267
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
268
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Unsupported document type '{}'. Supported types are: {}"`<br>`}]`|`BadRequestError`|The document you upload must be a PDF file|
269
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Document didn't pass the virus scan"`<br>`}]`|`BadRequestError`|The document you upload must be virus free|
270
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Service is not allowed to send documents"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
271
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
272
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
273
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"`<br>`}]`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
274
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|`RateLimitError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
275
- |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|`ServerError`|Notify was unable to process the request, resend your notification|
276
- |-|`[{`<br>`"error": "ArgumentError",`<br>`"message": "Document is larger than 2MB")`<br>`}]`|-|Document size was too large, upload a smaller document|
301
+ |`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
302
+ |`400`|`BadRequestError: Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
303
+ |`400`|`BadRequestError: Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'`|`BadRequestError`|Wrong file type. You can only upload .pdf, .csv, .txt, .doc, .docx or .odt files|
304
+ |`400`|`BadRequestError: File did not pass the virus scan`|`BadRequestError`|The file contains a virus|
305
+ |`400`|`BadRequestError: Send files by email has not been set up - add contact details for your service at https://www.notifications.service.gov.uk/services/(SERVICE ID)/service-settings/send-files-by-email`|`BadRequestError`|See how to [add contact details to the file download page](#add-contact-details-to-the-file-download-page)|
306
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
307
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
308
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#rate-limits) for more information|
309
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number|
310
+ |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
311
+ |-|`ArgumentError: File is larger than 2MB")`|-|The file is too big. Files must be smaller than 2MB|
277
312
 
278
313
  ## Send a letter
279
314
 
280
- When your service first signs up to GOV.UK Notify, you’ll start in trial mode. You can only send letters in live mode. You must ask GOV.UK Notify to make your service live.
315
+ When you add a new service it will start in [trial mode](https://www.notifications.service.gov.uk/features/trial-mode). You can only send letters when your service is live.
316
+
317
+ To send Notify a request to go live:
281
318
 
282
- 1. Sign in to [GOV.UK Notify](https://www.notifications.service.gov.uk/).
283
- 1. Select __Using Notify__.
284
- 1. Select __requesting to go live__.
319
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
320
+ 1. Go to the __Settings__ page.
321
+ 1. In the __Your service is in trial mode__ section, select __request to go live__.
285
322
 
286
323
  ### Method
287
324
 
@@ -289,7 +326,7 @@ When your service first signs up to GOV.UK Notify, you’ll start in trial mode.
289
326
  letterresponse = client.send_letter(
290
327
  template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a",
291
328
  personalisation: {
292
- address_line_1: 'The Occupier',
329
+ address_line_1: 'The Occupier',
293
330
  address_line_2: '123 High Street',
294
331
  postcode: 'SW14 6BH',
295
332
  },
@@ -300,7 +337,13 @@ letterresponse = client.send_letter(
300
337
 
301
338
  #### template_id (required)
302
339
 
303
- Sign in to GOV.UK Notify and go to the __Templates__ page to find the template ID. For example:
340
+ To find the template ID:
341
+
342
+ 1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
343
+ 1. Go to the __Templates__ page and select the relevant template.
344
+ 1. Select __Copy template ID to clipboard__.
345
+
346
+ For example:
304
347
 
305
348
  ```ruby
306
349
  template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
@@ -308,11 +351,11 @@ template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
308
351
 
309
352
  #### personalisation (required)
310
353
 
311
- The personalisation argument always contains the following parameters for the letter recipient's address:
354
+ The personalisation argument always contains the following parameters for the letter recipients address:
312
355
 
313
356
  - `address_line_1`
314
357
  - `address_line_2`
315
- - `postcode`
358
+ - `postcode` (this needs to be a real UK postcode)
316
359
 
317
360
  Any other placeholder fields included in the letter template also count as required parameters. You must provide their values in a hash. For example:
318
361
 
@@ -329,7 +372,7 @@ personalisation: {
329
372
 
330
373
  #### personalisation (optional)
331
374
 
332
- The following parameters in the letter recipient's address are optional:
375
+ The following parameters in the letter recipients address are optional:
333
376
 
334
377
  ```ruby
335
378
  personalisation: {
@@ -350,7 +393,7 @@ reference: 'your_reference_string'
350
393
 
351
394
  ### Response
352
395
 
353
- If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](/ruby.html#send-a-letter-method), the object is named `letterresponse`.
396
+ If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](#send-a-letter-method), the object is named `letterresponse`.
354
397
 
355
398
  You can then call different methods on this object to return the requested information.
356
399
 
@@ -365,21 +408,21 @@ You can then call different methods on this object to return the requested infor
365
408
 
366
409
  ### Error codes
367
410
 
368
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
411
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
369
412
 
370
413
  |error.code|error.message|class|How to fix|
371
414
  |:--- |:---|:---|:---|
372
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
373
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
374
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "personalisation address_line_1 is a required property"`<br>`}]`|`BadRequestError`|Ensure that your template has a field for the first line of the address, refer to [personalisation](/ruby.html#personalisation-required) for more information|
375
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
376
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
377
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"`<br>`}]`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
378
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|`RateLimitError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
379
- |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|`ServerError`|Notify was unable to process the request, resend your notification|
415
+ |`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
416
+ |`400`|`BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
417
+ |`400`|`ValidationError: personalisation address_line_1 is a required property`|`BadRequestError`|Ensure that your template has a field for the first line of the address, refer to [personalisation](#personalisation-required) for more information|
418
+ |`400`|`ValidationError: Must be a real UK postcode`|`BadRequestError`|Ensure that the value for the postcode field in your letter is a real UK postcode|
419
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
420
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
421
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#rate-limits) for more information|
422
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number|
423
+ |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
380
424
 
381
425
  ## Send a precompiled letter
382
- This is an invitation-only feature. Contact the GOV.UK Notify team on the [support page](https://www.notifications.service.gov.uk/support) or through the [Slack channel](https://ukgovernmentdigital.slack.com/messages/govuk-notify) for more information.
383
426
 
384
427
  ### Method
385
428
  ```ruby
@@ -393,7 +436,7 @@ A unique identifier you create. This reference identifies a single unique notifi
393
436
 
394
437
  #### pdf_file (required)
395
438
 
396
- The precompiled letter must be a PDF file.
439
+ The precompiled letter must be a PDF file which meets [the GOV.UK Notify PDF letter specification](https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.4.pdf).
397
440
 
398
441
  ```ruby
399
442
  File.open("path/to/pdf_file", "rb") do |pdf_file|
@@ -408,7 +451,7 @@ You can choose first or second class postage for your precompiled letter. Set th
408
451
 
409
452
  ### Response
410
453
 
411
- If the request to the client is successful, the client returns a `Notifications::Client:ResponsePrecompiledLetter` object. In the example shown in the [Method section](/ruby.html#send-a-pre-compiled-letter-method), the object is named `precompiled_letter`.
454
+ If the request to the client is successful, the client returns a `Notifications::Client:ResponsePrecompiledLetter` object. In the example shown in the [Method section](#send-a-pre-compiled-letter-method), the object is named `precompiled_letter`.
412
455
 
413
456
  You can then call different methods on this object to return the requested information.
414
457
 
@@ -421,19 +464,17 @@ You can then call different methods on this object to return the requested infor
421
464
 
422
465
  ### Error codes
423
466
 
424
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
467
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
425
468
 
426
469
  |error.status_code|error.message|class|How to fix|
427
470
  |:---|:---|:---|:---|
428
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
429
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send precompiled letters"`<br>`]}`|`BadRequestError`|This is an invitation-only feature. Contact the GOV.UK Notify team on the [support page](https://www.notifications.service.gov.uk/support) or through the [Slack channel](https://ukgovernmentdigital.slack.com/messages/govuk-notify) for more information|
430
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Letter content is not a valid PDF"`<br>`]}`|`BadRequestError`|PDF file format is required|
431
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
432
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "reference is a required property"`<br>`}]`|`BadRequestError`|Add a `reference` argument to the method call|
433
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "postage invalid. It must be either first or second."`<br>`}]`|`BadRequestError`|Change the value of `postage` argument in the method call to either 'first' or 'second'|
434
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Service is not allowed to send precompiled letters"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
435
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type live of 10 requests per 20 seconds"`<br>`}]`|`RateLimitError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
436
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (50) for today"`<br>`}]`|`RateLimitError`|Refer to [service limits](#service-limits) for the limit number|
471
+ |`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
472
+ |`400`|`BadRequestError: Letter content is not a valid PDF`|`BadRequestError`|PDF file format is required|
473
+ |`400`|`BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
474
+ |`400`|`ValidationError: reference is a required property`|`BadRequestError`|Add a `reference` argument to the method call|
475
+ |`400`|`ValidationError: postage invalid. It must be either first or second.`|`BadRequestError`|Change the value of `postage` argument in the method call to either 'first' or 'second'|
476
+ |`429`|`RateLimitError: Exceeded rate limit for key type live of 10 requests per 20 seconds`|`RateLimitError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
477
+ |`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number|
437
478
 
438
479
  # Get message status
439
480
 
@@ -441,21 +482,25 @@ Message status depends on the type of message you have sent.
441
482
 
442
483
  You can only get the status of messages that are 7 days old or newer.
443
484
 
444
- ## Status - text and email
485
+ ## Status - email
445
486
 
446
487
  |Status|Information|
447
488
  |:---|:---|
448
489
  |Created|GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.|
449
- |Sending|GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient. GOV.UK Notify is waiting for delivery information.|
490
+ |Sending|GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.|
450
491
  |Delivered|The message was successfully delivered.|
451
- |Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message because the email address or phone number was wrong. You should remove these email addresses or phone numbers from your database. You’ll still be charged for text messages to numbers that do not exist."<br>- `temporary-failure` - "The provider could not deliver the message after trying for 72 hours. This can happen when the recipient's inbox is full or their phone is off. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure."|
492
+ |Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database."<br>- `temporary-failure` - "The provider could not deliver the message. This can happen when the recipients inbox is full. You can try to send the message again."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again."|
452
493
 
453
- ## Status - text only
494
+ ## Status - text message
454
495
 
455
496
  |Status|Information|
456
497
  |:---|:---|
457
- |Pending|GOV.UK Notify is waiting for more delivery information.<br>GOV.UK Notify received a callback from the provider but the recipient's device has not yet responded. Another callback from the provider determines the final status of the notification.|
498
+ |Created|GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.|
499
+ |Sending|GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.|
500
+ |Pending|GOV.UK Notify is waiting for more delivery information.<br>GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the notification.|
458
501
  |Sent / Sent internationally|The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information. The GOV.UK Notify client API returns this status as `sent`. The GOV.UK Notify client app returns this status as `Sent internationally`.|
502
+ |Delivered|The message was successfully delivered.|
503
+ |Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message. This can happen if the phone number was wrong or if the network operator rejects the message. If you’re sure that these phone numbers are correct, you should [contact GOV.UK Notify support](https://www.notifications.service.gov.uk/support). If not, you should remove them from your database. You’ll still be charged for text messages that cannot be delivered."<br>- `temporary-failure` - "The provider could not deliver the message. This can happen when the recipient’s phone is off, has no signal, or their text message inbox is full. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure."|
459
504
 
460
505
  ## Status - letter
461
506
 
@@ -471,7 +516,7 @@ You can only get the status of messages that are 7 days old or newer.
471
516
  |:---|:---|
472
517
  |Pending virus check|GOV.UK Notify has not completed a virus scan of the precompiled letter file.|
473
518
  |Virus scan failed|GOV.UK Notify found a potential virus in the precompiled letter file.|
474
- |Validation failed|Content in the precompiled letter file is outside the printable area.|
519
+ |Validation failed|Content in the precompiled letter file is outside the printable area. See the [GOV.UK Notify PDF letter specification](https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.3.pdf) for more information.|
475
520
 
476
521
  ## Get the status of one message
477
522
 
@@ -487,18 +532,13 @@ response = client.get_notification(id)
487
532
 
488
533
  #### id (required)
489
534
 
490
- The ID of the notification. You can find the notification ID in the response to the [original notification method call](/ruby.html#response).
491
-
492
- You can also find it in your [GOV.UK Notify Dashboard](https://www.notifications.service.gov.uk).
535
+ The ID of the notification. You can find the notification ID in the response to the [original notification method call](#response).
493
536
 
494
- 1. Sign into GOV.UK Notify and select __Dashboard__.
495
- 1. Select either __emails sent__, __text messages sent__, or __letters sent__.
496
- 1. Select the relevant notification.
497
- 1. Copy the notification ID from the end of the page URL, for example `https://www.notifications.service.gov.uk/services/af90d4cb-ae88-4a7c-a197-5c30c7db423b/notification/ID`.
537
+ You can also find it by [signing in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and going to the __API integration__ page.
498
538
 
499
539
  ### Response
500
540
 
501
- If the request to the client is successful, the client returns a `Notifications::Client::Notification` object. In the example shown in the [Method section](/ruby.html#get-the-status-of-one-message-method), the object is named `response`.
541
+ If the request to the client is successful, the client returns a `Notifications::Client::Notification` object. In the example shown in the [Method section](#get-the-status-of-one-message-method), the object is named `response`.
502
542
 
503
543
  You can then call different methods on this object to return the requested information.
504
544
 
@@ -528,14 +568,14 @@ You can then call different methods on this object to return the requested infor
528
568
 
529
569
  ### Error codes
530
570
 
531
- If the request is not successful, the client returns a `Notification::Client::RequestError` and an error code:
571
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
532
572
 
533
573
  |error.code|error.message|class|How to fix|
534
574
  |:---|:---|:---|:---|
535
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|`BadRequestError`|Check the notification ID|
536
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
537
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
538
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
575
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
576
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
577
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
578
+ |`404`|`NoResultFound: No result found`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
539
579
 
540
580
  ## Get the status of multiple messages
541
581
 
@@ -565,22 +605,14 @@ You can leave out these arguments to ignore these filters.
565
605
 
566
606
  #### status (optional)
567
607
 
568
- | status | description | text | email | letter |Precompiled letter|
569
- |:--- |:--- |:--- |:--- |:--- |:--- |
570
- |created|GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.|Yes|Yes|||
571
- |sending|GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient. GOV.UK Notify is waiting for delivery information.|Yes|Yes|||
572
- |delivered|The message was successfully delivered|Yes|Yes|||
573
- |sent / sent internationally|The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information.|Yes||||
574
- |pending|GOV.UK Notify is waiting for more delivery information.<br>GOV.UK Notify received a callback from the provider but the recipient's device has not yet responded. Another callback from the provider determines the final status of the notification.|Yes||||
575
- |failed|This returns all failure statuses:<br>- permanent-failure<br>- temporary-failure<br>- technical-failure|Yes|Yes|||
576
- |permanent-failure|The provider could not deliver the message because the email address or phone number was wrong. You should remove these email addresses or phone numbers from your database. You’ll still be charged for text messages to numbers that do not exist.|Yes|Yes|||
577
- |temporary-failure|The provider could not deliver the message after trying for 72 hours. This can happen when the recipient's inbox is full or their phone is off. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages.|Yes|Yes|||
578
- |technical-failure|Email / Text: Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure. <br><br>Letter: Notify had an unexpected error while sending to our printing provider. <br><br>You can leave out this argument to ignore this filter.|Yes|Yes|||
579
- |accepted|GOV.UK Notify has sent the letter to the provider to be printed.|||Yes||
580
- |received|The provider has printed and dispatched the letter.|||Yes||
581
- |pending-virus-check|GOV.UK Notify is scanning the precompiled letter file for viruses.||||Yes|
582
- |virus-scan-failed|GOV.UK Notify found a potential virus in the precompiled letter file.||||Yes|
583
- |validation-failed|Content in the precompiled letter file is outside the printable area.||||Yes|
608
+ You can filter by each:
609
+
610
+ * [email status](#status-email)
611
+ * [text message status](#status-text-message)
612
+ * [letter status](#status-letter)
613
+ * [precompiled letter status](#status-precompiled-letter)
614
+
615
+ You can leave out this argument to ignore this filter.
584
616
 
585
617
  #### templateType (optional)
586
618
 
@@ -612,7 +644,7 @@ The client only returns notifications that are 7 days old or newer. If the notif
612
644
 
613
645
  ### Response
614
646
 
615
- If the request to the client is successful, the client returns a `Notifications::Client::NotificationsCollection` object. In the example shown in the [Method section](/ruby.html#get-the-status-of-multiple-messages-method), the object is named `response`.
647
+ If the request to the client is successful, the client returns a `Notifications::Client::NotificationsCollection` object. In the example shown in the [Method section](#get-the-status-of-multiple-messages-method), the object is named `response`.
616
648
 
617
649
  You must then call either the `.links` method or the `.collection` method on this object.
618
650
 
@@ -650,14 +682,54 @@ If the notification specified in the `older_than` argument is older than 7 days,
650
682
 
651
683
  ### Error codes
652
684
 
653
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
685
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
686
+
687
+ |error.code|error.message|class|How to fix|
688
+ |:---|:---|:---|:---|
689
+ |`400`|`ValidationError: bad status is not one of [created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, accepted, received]`|`BadRequestError`|Contact the GOV.UK Notify team|
690
+ |`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the GOV.UK Notify team|
691
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
692
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
693
+
694
+ ## Get a PDF for a letter notification
695
+
696
+ ### Method
697
+
698
+ This returns the pdf contents of a letter notification.
699
+
700
+ ```ruby
701
+ pdf_file = client.get_pdf_for_letter(
702
+ 'f33517ff-2a88-4f6e-b855-c550268ce08a' # notification id (required)
703
+ )
704
+ ```
705
+
706
+ ### Arguments
707
+
708
+ #### id (required)
709
+
710
+ The ID of the notification. You can find the notification ID in the response to the [original notification method call](#get-the-status-of-one-message-response).
711
+
712
+ You can also find it by [signing in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and going to the __API integration__ page.
713
+
714
+ ### Response
715
+
716
+ If the request to the client is successful, the client will return a `string` containing the raw PDF data.
717
+
718
+ ### Error codes
719
+
720
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
654
721
 
655
722
  |error.code|error.message|class|How to fix|
656
723
  |:---|:---|:---|:---|
657
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "bad status is not one of [created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, accepted, received]"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
658
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Template type is not one of [sms, email, letter]"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
659
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
660
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
724
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
725
+ |`400`|`PDFNotReadyError: PDF not available yet, try again later`|`BadRequestError`|Wait for the notification to finish processing. This usually takes a few seconds|
726
+ |`400`|`BadRequestError: File did not pass the virus scan`|`BadRequestError`|You cannot retrieve the contents of a letter notification that contains a virus|
727
+ |`400`|`BadRequestError: PDF not available for letters in technical-failure`|`BadRequestError`|You cannot retrieve the contents of a letter notification in technical-failure|
728
+ |`400`|`ValidationError: Notification is not a letter`|`BadRequestError`|Check that you are looking up the correct notification|
729
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`BadRequestError`|Check your system clock|
730
+ |`403`|`AuthError: Invalid token: API key not found`|`BadRequestError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
731
+ |`404`|`NoResultFound: No result found`|`BadRequestError`|Check the notification ID|
732
+
661
733
 
662
734
  # Get a template
663
735
 
@@ -675,7 +747,7 @@ response = client.get_template_by_id(id)
675
747
 
676
748
  #### id (required)
677
749
 
678
- The ID of the template. Sign into GOV.UK Notify and go to the __Templates__ page to find this. For example:
750
+ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __Templates__ page to find it. For example:
679
751
 
680
752
  ```
681
753
  'f33517ff-2a88-4f6e-b855-c550268ce08a'
@@ -683,7 +755,7 @@ The ID of the template. Sign into GOV.UK Notify and go to the __Templates__ page
683
755
 
684
756
  ### Response
685
757
 
686
- If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](/ruby.html#get-a-template-by-id-method), the object is named `response`.
758
+ If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](#get-a-template-by-id-method), the object is named `response`.
687
759
 
688
760
  You can then call different methods on this object to return the requested information.
689
761
 
@@ -701,14 +773,14 @@ You can then call different methods on this object to return the requested infor
701
773
 
702
774
  ### Error codes
703
775
 
704
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
776
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
705
777
 
706
778
  |error.code|error.message|class|How to fix|
707
779
  |:---|:---|:---|:---|
708
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|`BadRequestError`|Check the notification ID|
709
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
710
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
711
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|`NotFoundError`|Check your [template ID](/ruby.html#get-a-template-by-id-arguments-id-required)|
780
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
781
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
782
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
783
+ |`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-arguments-id-required)|
712
784
 
713
785
  ## Get a template by ID and version
714
786
 
@@ -722,7 +794,7 @@ response = client.get_template_version(id, version)
722
794
 
723
795
  #### id (required)
724
796
 
725
- The ID of the template. Sign in to GOV.UK Notify and go to the __Templates__ page to find this. For example:
797
+ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __Templates__ page to find it. For example:
726
798
 
727
799
  ```ruby
728
800
  'f33517ff-2a88-4f6e-b855-c550268ce08a'
@@ -734,7 +806,7 @@ The version number of the template.
734
806
 
735
807
  ### Response
736
808
 
737
- If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](/ruby.html#get-a-template-by-id-and-version-method), the object is named `response`.
809
+ If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](#get-a-template-by-id-and-version-method), the object is named `response`.
738
810
 
739
811
  You can then call different methods on this object to return the requested information.
740
812
 
@@ -752,14 +824,14 @@ You can then call different methods on this object to return the requested infor
752
824
 
753
825
  ### Error codes
754
826
 
755
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
827
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
756
828
 
757
829
  |error.code|error.message|class|How to fix|
758
830
  |:---|:---|:---|:---|
759
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|`BadRequestError`|Check the notification ID|
760
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
761
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
762
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|`NotFoundError`|Check your [template ID](/ruby.html#get-a-template-by-id-and-version-arguments-id-required) and [version](/ruby.html#version-required)|
831
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
832
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
833
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
834
+ |`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-and-version-arguments-id-required) and [version](#version-required)|
763
835
 
764
836
  ## Get all templates
765
837
 
@@ -786,7 +858,7 @@ If you do not use `type`, the client returns all templates. Otherwise you can fi
786
858
 
787
859
  ### Response
788
860
 
789
- If the request to the client is successful, the client returns a `Notifications::Client::TemplateCollection` object. In the example shown in the [Method section](/ruby.html#get-all-templates-method), the object is named `response`.
861
+ If the request to the client is successful, the client returns a `Notifications::Client::TemplateCollection` object. In the example shown in the [Method section](#get-all-templates-method), the object is named `response`.
790
862
 
791
863
  You must then call the `.collection` method on this object to return an array of the required templates.
792
864
 
@@ -808,11 +880,11 @@ If no templates exist for a template type or there no templates for a service, t
808
880
 
809
881
  ### Error codes
810
882
 
811
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
883
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
812
884
 
813
885
  |error.code|error.message|class|How to fix|
814
886
  |:---|:---|:---|:---|
815
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Template type is not one of [sms, email, letter]"`<br>`}]`|`BadRequestError`|Contact the Notify team|
887
+ |`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the Notify team|
816
888
 
817
889
  ## Generate a preview template
818
890
 
@@ -830,7 +902,7 @@ The parameters in the personalisation argument must match the placeholder fields
830
902
 
831
903
  #### id (required)
832
904
 
833
- The ID of the template. Sign into GOV.UK Notify and go to the __Templates__ page. For example:
905
+ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __Templates__ page to find it. For example:
834
906
 
835
907
  ```ruby
836
908
  'f33517ff-2a88-4f6e-b855-c550268ce08a'
@@ -843,7 +915,7 @@ If a template has placeholder fields for personalised information such as name o
843
915
  ```ruby
844
916
  personalisation: {
845
917
  name: "John Smith",
846
- ID: "300241",
918
+ ID: "300241",
847
919
  }
848
920
  ```
849
921
 
@@ -851,7 +923,7 @@ You can leave out this argument if a template does not have any placeholder fiel
851
923
 
852
924
  ### Response
853
925
 
854
- If the request to the client is successful, the client returns a `Notifications::Client::TemplatePreview` object. In the example shown in the [Method section](/ruby.html#generate-a-preview-template-method), the object is named `response`.
926
+ If the request to the client is successful, the client returns a `Notifications::Client::TemplatePreview` object. In the example shown in the [Method section](#generate-a-preview-template-method), the object is named `response`.
855
927
 
856
928
  You can then call different methods on this object to return the requested information.
857
929
 
@@ -866,14 +938,14 @@ You can then call different methods on this object to return the requested infor
866
938
 
867
939
  ### Error codes
868
940
 
869
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
941
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
870
942
 
871
943
  |error.code|error.message|class|How to fix|
872
944
  |:---|:---|:---|:---|
873
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Missing personalisation: [PERSONALISATION FIELD]"`<br>`}]`|`BadRequestError`|Check that the personalisation arguments in the method match the placeholder fields in the template|
874
- |`400`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|`BadRequestError`|Check the [template ID](/ruby.html#generate-a-preview-template-arguments-id-required)|
875
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
876
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
945
+ |`400`|`BadRequestError: Missing personalisation: [PERSONALISATION FIELD]`|`BadRequestError`|Check that the personalisation arguments in the method match the placeholder fields in the template|
946
+ |`400`|`NoResultFound: No result found`|`BadRequestError`|Check the [template ID](#generate-a-preview-template-arguments-id-required)|
947
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
948
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
877
949
 
878
950
  # Get received text messages
879
951
 
@@ -881,11 +953,11 @@ This API call returns one page of up to 250 received text messages. You can get
881
953
 
882
954
  You can only get the status of messages that are 7 days old or newer.
883
955
 
884
- You can also set up [callbacks](/ruby.html#callbacks) for received text messages.
956
+ You can also set up [callbacks](#callbacks) for received text messages.
885
957
 
886
958
  ## Enable received text messages
887
959
 
888
- Contact the GOV.UK Notify team on the [support page](https://www.notifications.service.gov.uk/support) or through the [Slack channel](https://ukgovernmentdigital.slack.com/messages/govuk-notify) to enable receiving text messages for your service.
960
+ Contact the GOV.UK Notify team using the [support page](https://www.notifications.service.gov.uk/support) or [chat to us on Slack](https://ukgovernmentdigital.slack.com/messages/C0E1ADVPC) to request a unique number for text message replies.
889
961
 
890
962
  ## Get a page of received text messages
891
963
 
@@ -918,7 +990,7 @@ The client only returns notifications that are 7 days old or newer. If the notif
918
990
 
919
991
  ### Response
920
992
 
921
- If the request to the client is successful, the client returns a `Notifications::Client::ReceivedTextCollection` object. In the example shown in the [Method section](/ruby.html#get-received-text-messages-method), the object is named `response`.
993
+ If the request to the client is successful, the client returns a `Notifications::Client::ReceivedTextCollection` object. In the example shown in the [Method section](#get-received-text-messages-method), the object is named `response`.
922
994
 
923
995
  You must then call either the `.links` method or the `.collection` method on this object.
924
996
 
@@ -942,9 +1014,9 @@ If the notification specified in the `older_than` argument is older than 7 days,
942
1014
 
943
1015
  ### Error codes
944
1016
 
945
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
1017
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
946
1018
 
947
1019
  |error.code|error.message|class|How to fix|
948
1020
  |:---|:---|:---|:---|
949
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
950
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
1021
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
1022
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|