notifications-ruby-client 4.0.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -4
- data/CHANGELOG.md +26 -0
- data/CONTRIBUTING.md +6 -1
- data/DOCUMENTATION.md +200 -124
- data/Dockerfile +13 -0
- data/Makefile +14 -22
- data/bin/test_client.rb +70 -18
- data/lib/notifications/client.rb +8 -0
- data/lib/notifications/client/helper_methods.rb +3 -3
- data/lib/notifications/client/request_error.rb +4 -1
- data/lib/notifications/client/response_template.rb +1 -0
- data/lib/notifications/client/speaker.rb +13 -0
- data/lib/notifications/client/version.rb +1 -1
- data/notifications-ruby-client.gemspec +3 -4
- metadata +10 -26
- data/docker/Dockerfile +0 -26
- data/docker/Makefile +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c7ff68fddc3b2837e47a1b89476f0d391ec432cc096176733a5944ed20dd107
|
4
|
+
data.tar.gz: 84e59511973f65604fc0617c14871848517e23fe615d7d0c075733a435ce06e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92f58edf7ea3cc8966d51e2902f0846082d6667290bdb1123e9c399354fb975dd33e297e4f30667aef275ee2482750932f160857c97459ae89200d162d459373
|
7
|
+
data.tar.gz: d3d5784f52bce5bc164ce10d76ef14f83a82caab0f6b3b2e540db3a9ff45d7ea10e0c145deacb8d9501fa3d3ada8770041b5ff80839701526fece51f4391dc7f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
## 5.3.0
|
2
|
+
|
3
|
+
* Added `letter_contact_block` as a new attribute of the `Notifications::Client::Template` class. This affects the responses from the `get_template_by_id`, `get_template_version` and `get_all_templates` methods.
|
4
|
+
|
5
|
+
## 5.2.0
|
6
|
+
|
7
|
+
* 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.
|
8
|
+
|
9
|
+
## 5.1.2
|
10
|
+
|
11
|
+
* Change filesize too big exception message to refer to files rather than documents.
|
12
|
+
|
13
|
+
## 5.1.1
|
14
|
+
|
15
|
+
* Exceptions now return the error message when calling `#to_s` on them. This will make services like Sentry correctly display the full error description.
|
16
|
+
|
17
|
+
## 5.1.0
|
18
|
+
|
19
|
+
* Added new `get_pdf_for_letter` method
|
20
|
+
* accepts a notification id argument
|
21
|
+
* returns a string containing the final printable PDF for a precompiled or templated letter
|
22
|
+
|
23
|
+
## 5.0.0
|
24
|
+
|
25
|
+
* 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/)
|
26
|
+
|
1
27
|
## 4.0.0
|
2
28
|
|
3
29
|
* `RequestError.message` now returns a string, not an array of hashes – see https://github.com/alphagov/notifications-ruby-client/pull/72
|
data/CONTRIBUTING.md
CHANGED
@@ -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="
|
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`.
|
data/DOCUMENTATION.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
This documentation is for developers interested in using the GOV.UK Notify Ruby client to send emails, text messages or letters.
|
4
4
|
|
5
|
-
We recommend that you use this client library rather than use the [GOV.UK Notify API](https://github.com/alphagov/notifications-api) directly, as there is no documentation for using the API in this way.
|
6
|
-
|
7
5
|
# Set up the client
|
8
6
|
|
9
7
|
## Install the client
|
@@ -25,7 +23,7 @@ require 'notifications/client'
|
|
25
23
|
client = Notifications::Client.new(api_key)
|
26
24
|
```
|
27
25
|
|
28
|
-
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](
|
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.
|
29
27
|
|
30
28
|
# Send a message
|
31
29
|
|
@@ -54,7 +52,13 @@ phone_number:"+447900900123"
|
|
54
52
|
|
55
53
|
#### template_id (required)
|
56
54
|
|
57
|
-
|
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:
|
58
62
|
|
59
63
|
```ruby
|
60
64
|
template_id:"f33517ff-2a88-4f6e-b855-c550268ce08a"
|
@@ -67,7 +71,7 @@ If a template has placeholder fields for personalised information such as name o
|
|
67
71
|
```ruby
|
68
72
|
personalisation: {
|
69
73
|
name: "John Smith",
|
70
|
-
ID: "300241",
|
74
|
+
ID: "300241",
|
71
75
|
}
|
72
76
|
```
|
73
77
|
|
@@ -85,12 +89,13 @@ You can leave out this argument if you do not have a reference.
|
|
85
89
|
|
86
90
|
#### sms_sender_id (optional)
|
87
91
|
|
88
|
-
A unique identifier of the sender of the text message notification.
|
92
|
+
A unique identifier of the sender of the text message notification.
|
89
93
|
|
90
|
-
|
91
|
-
|
92
|
-
1.
|
93
|
-
1. Go to the
|
94
|
+
To find the text message sender:
|
95
|
+
|
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.
|
94
99
|
|
95
100
|
You can then either:
|
96
101
|
|
@@ -108,7 +113,7 @@ You can leave out this argument if your service only has one text message sender
|
|
108
113
|
|
109
114
|
### Response
|
110
115
|
|
111
|
-
If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](
|
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`.
|
112
117
|
|
113
118
|
You can then call different methods on this object:
|
114
119
|
|
@@ -120,22 +125,22 @@ You can then call different methods on this object:
|
|
120
125
|
|`smsresponse.template`|Contains the `id`, `version` and `uri` of the template|Hash|
|
121
126
|
|`smsresponse.uri`|Notification URL|String|
|
122
127
|
|
123
|
-
If you are using the [test API key](
|
128
|
+
If you are using the [test API key](#test), all your messages come back with a `delivered` status.
|
124
129
|
|
125
|
-
All messages sent using the [team and
|
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.
|
126
131
|
|
127
132
|
### Error codes
|
128
133
|
|
129
|
-
If the request is not successful, the client
|
134
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
130
135
|
|
131
136
|
|error.code|error.message|class|How to fix|
|
132
137
|
|:---|:---|:---|:---|
|
133
|
-
|`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](
|
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)|
|
134
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)|
|
135
140
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
136
|
-
|`403`|`AuthError: Invalid token:
|
137
|
-
|`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](
|
138
|
-
|`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`ClientError`|Refer to [service limits](
|
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|
|
139
144
|
|`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
|
140
145
|
|
141
146
|
## Send an email
|
@@ -161,7 +166,13 @@ email_address: "sender@something.com"
|
|
161
166
|
|
162
167
|
#### template_id (required)
|
163
168
|
|
164
|
-
|
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:
|
165
176
|
|
166
177
|
```ruby
|
167
178
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
@@ -174,7 +185,7 @@ If a template has placeholder fields for personalised information such as name o
|
|
174
185
|
```ruby
|
175
186
|
personalisation: {
|
176
187
|
name: "John Smith",
|
177
|
-
year: "2016"
|
188
|
+
year: "2016"
|
178
189
|
}
|
179
190
|
```
|
180
191
|
|
@@ -192,14 +203,15 @@ You can leave out this argument if you do not have a reference.
|
|
192
203
|
|
193
204
|
#### email_reply_to_id (optional)
|
194
205
|
|
195
|
-
This is an email
|
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.
|
196
207
|
|
197
|
-
|
198
|
-
1. Go to __Settings__.
|
199
|
-
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.
|
200
|
-
1. Go to the __Email__ section and select __Manage__ on the __Email reply-to addresses__ row.
|
201
|
-
1. Select __Change__ to specify the email address to receive replies, and select __Save__.
|
208
|
+
To add a reply-to email address:
|
202
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__.
|
203
215
|
|
204
216
|
For example:
|
205
217
|
|
@@ -209,25 +221,31 @@ email_reply_to_id: '8e222534-7f05-4972-86e3-17c5d9f894e2'
|
|
209
221
|
|
210
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.
|
211
223
|
|
212
|
-
## Send a
|
224
|
+
## Send a file by email
|
225
|
+
|
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
|
-
|
228
|
+
The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
|
215
229
|
|
216
|
-
|
230
|
+
### Add contact details to the file download page
|
217
231
|
|
218
|
-
|
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
|
-
### Add a placeholder
|
237
|
+
### Add a placeholder to the template
|
221
238
|
|
222
|
-
1. Sign in to
|
239
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
223
240
|
1. Go to the __Templates__ page and select the relevant email template.
|
224
|
-
1.
|
241
|
+
1. Select __Edit__.
|
242
|
+
1. Add a placeholder to the email template using double brackets. For example:
|
225
243
|
|
226
|
-
"Download your
|
244
|
+
"Download your file at: ((link_to_file))"
|
227
245
|
|
228
|
-
### Upload your
|
246
|
+
### Upload your file
|
229
247
|
|
230
|
-
|
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.
|
231
249
|
|
232
250
|
1. Pass the file object as an argument to the `Notifications.prepare_upload` helper method.
|
233
251
|
1. Pass the result into the personalisation argument.
|
@@ -240,14 +258,29 @@ File.open("file.pdf", "rb") do |f|
|
|
240
258
|
personalisation: {
|
241
259
|
first_name: "Amala",
|
242
260
|
application_date: "2018-01-01",
|
243
|
-
|
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),
|
244
277
|
}
|
245
278
|
end
|
246
279
|
```
|
247
280
|
|
248
281
|
### Response
|
249
282
|
|
250
|
-
If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](
|
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`.
|
251
284
|
|
252
285
|
You can then call different methods on this object to return the requested information.
|
253
286
|
|
@@ -261,29 +294,31 @@ You can then call different methods on this object to return the requested infor
|
|
261
294
|
|
262
295
|
### Error codes
|
263
296
|
|
264
|
-
If the request is not successful, the client
|
297
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
265
298
|
|
266
299
|
|error.code|error.message|class|How to fix|
|
267
300
|
|:--- |:---|:---|:---|
|
268
|
-
|`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](
|
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)|
|
269
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)|
|
270
|
-
|`400`|`BadRequestError: Unsupported
|
271
|
-
|`400`|`BadRequestError:
|
272
|
-
|`400`|`BadRequestError:
|
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)|
|
273
306
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
274
|
-
|`403`|`AuthError: Invalid token:
|
275
|
-
|`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](
|
276
|
-
|`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](
|
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|
|
277
310
|
|`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
|
278
|
-
|-|`ArgumentError:
|
311
|
+
|-|`ArgumentError: File is larger than 2MB")`|-|The file is too big. Files must be smaller than 2MB|
|
279
312
|
|
280
313
|
## Send a letter
|
281
314
|
|
282
|
-
When
|
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:
|
283
318
|
|
284
|
-
1. Sign in to
|
285
|
-
1.
|
286
|
-
1.
|
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__.
|
287
322
|
|
288
323
|
### Method
|
289
324
|
|
@@ -291,7 +326,7 @@ When your service first signs up to GOV.UK Notify, you’ll start in trial mode.
|
|
291
326
|
letterresponse = client.send_letter(
|
292
327
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a",
|
293
328
|
personalisation: {
|
294
|
-
address_line_1: 'The Occupier',
|
329
|
+
address_line_1: 'The Occupier',
|
295
330
|
address_line_2: '123 High Street',
|
296
331
|
postcode: 'SW14 6BH',
|
297
332
|
},
|
@@ -302,7 +337,13 @@ letterresponse = client.send_letter(
|
|
302
337
|
|
303
338
|
#### template_id (required)
|
304
339
|
|
305
|
-
|
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:
|
306
347
|
|
307
348
|
```ruby
|
308
349
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
@@ -310,11 +351,11 @@ template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
|
310
351
|
|
311
352
|
#### personalisation (required)
|
312
353
|
|
313
|
-
The personalisation argument always contains the following parameters for the letter recipient
|
354
|
+
The personalisation argument always contains the following parameters for the letter recipient’s address:
|
314
355
|
|
315
356
|
- `address_line_1`
|
316
357
|
- `address_line_2`
|
317
|
-
- `postcode`
|
358
|
+
- `postcode` (this needs to be a real UK postcode)
|
318
359
|
|
319
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:
|
320
361
|
|
@@ -331,7 +372,7 @@ personalisation: {
|
|
331
372
|
|
332
373
|
#### personalisation (optional)
|
333
374
|
|
334
|
-
The following parameters in the letter recipient
|
375
|
+
The following parameters in the letter recipient’s address are optional:
|
335
376
|
|
336
377
|
```ruby
|
337
378
|
personalisation: {
|
@@ -352,7 +393,7 @@ reference: 'your_reference_string'
|
|
352
393
|
|
353
394
|
### Response
|
354
395
|
|
355
|
-
If the request to the client is successful, the client returns a `Notifications::Client:ResponseNotification` object. In the example shown in the [Method section](
|
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`.
|
356
397
|
|
357
398
|
You can then call different methods on this object to return the requested information.
|
358
399
|
|
@@ -367,17 +408,18 @@ You can then call different methods on this object to return the requested infor
|
|
367
408
|
|
368
409
|
### Error codes
|
369
410
|
|
370
|
-
If the request is not successful, the client
|
411
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
371
412
|
|
372
413
|
|error.code|error.message|class|How to fix|
|
373
414
|
|:--- |:---|:---|:---|
|
374
|
-
|`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](
|
415
|
+
|`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
|
375
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)|
|
376
|
-
|`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](
|
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|
|
377
419
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
378
|
-
|`403`|`AuthError: Invalid token:
|
379
|
-
|`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](
|
380
|
-
|`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](
|
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|
|
381
423
|
|`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
|
382
424
|
|
383
425
|
## Send a precompiled letter
|
@@ -394,7 +436,7 @@ A unique identifier you create. This reference identifies a single unique notifi
|
|
394
436
|
|
395
437
|
#### pdf_file (required)
|
396
438
|
|
397
|
-
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.
|
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).
|
398
440
|
|
399
441
|
```ruby
|
400
442
|
File.open("path/to/pdf_file", "rb") do |pdf_file|
|
@@ -409,7 +451,7 @@ You can choose first or second class postage for your precompiled letter. Set th
|
|
409
451
|
|
410
452
|
### Response
|
411
453
|
|
412
|
-
If the request to the client is successful, the client returns a `Notifications::Client:ResponsePrecompiledLetter` object. In the example shown in the [Method section](
|
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`.
|
413
455
|
|
414
456
|
You can then call different methods on this object to return the requested information.
|
415
457
|
|
@@ -422,7 +464,7 @@ You can then call different methods on this object to return the requested infor
|
|
422
464
|
|
423
465
|
### Error codes
|
424
466
|
|
425
|
-
If the request is not successful, the client
|
467
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
426
468
|
|
427
469
|
|error.status_code|error.message|class|How to fix|
|
428
470
|
|:---|:---|:---|:---|
|
@@ -432,7 +474,7 @@ If the request is not successful, the client returns a `Notifications::Client::R
|
|
432
474
|
|`400`|`ValidationError: reference is a required property`|`BadRequestError`|Add a `reference` argument to the method call|
|
433
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'|
|
434
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|
|
435
|
-
|`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#
|
477
|
+
|`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number|
|
436
478
|
|
437
479
|
# Get message status
|
438
480
|
|
@@ -440,21 +482,25 @@ Message status depends on the type of message you have sent.
|
|
440
482
|
|
441
483
|
You can only get the status of messages that are 7 days old or newer.
|
442
484
|
|
443
|
-
## Status -
|
485
|
+
## Status - email
|
444
486
|
|
445
487
|
|Status|Information|
|
446
488
|
|:---|:---|
|
447
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.|
|
448
|
-
|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.|
|
449
491
|
|Delivered|The message was successfully delivered.|
|
450
|
-
|Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message because the email address
|
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 recipient’s 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."|
|
451
493
|
|
452
|
-
## Status - text
|
494
|
+
## Status - text message
|
453
495
|
|
454
496
|
|Status|Information|
|
455
497
|
|:---|:---|
|
456
|
-
|
|
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.|
|
457
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."|
|
458
504
|
|
459
505
|
## Status - letter
|
460
506
|
|
@@ -486,18 +532,13 @@ response = client.get_notification(id)
|
|
486
532
|
|
487
533
|
#### id (required)
|
488
534
|
|
489
|
-
The ID of the notification. You can find the notification ID in the response to the [original notification method call](
|
490
|
-
|
491
|
-
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).
|
492
536
|
|
493
|
-
|
494
|
-
1. Select either __emails sent__, __text messages sent__, or __letters sent__.
|
495
|
-
1. Select the relevant notification.
|
496
|
-
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.
|
497
538
|
|
498
539
|
### Response
|
499
540
|
|
500
|
-
If the request to the client is successful, the client returns a `Notifications::Client::Notification` object. In the example shown in the [Method section](
|
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`.
|
501
542
|
|
502
543
|
You can then call different methods on this object to return the requested information.
|
503
544
|
|
@@ -527,13 +568,13 @@ You can then call different methods on this object to return the requested infor
|
|
527
568
|
|
528
569
|
### Error codes
|
529
570
|
|
530
|
-
If the request is not successful, the client
|
571
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
531
572
|
|
532
573
|
|error.code|error.message|class|How to fix|
|
533
574
|
|:---|:---|:---|:---|
|
534
575
|
|`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
|
535
576
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
536
|
-
|`403`|`AuthError: Invalid token:
|
577
|
+
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
537
578
|
|`404`|`NoResultFound: No result found`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
|
538
579
|
|
539
580
|
## Get the status of multiple messages
|
@@ -564,22 +605,14 @@ You can leave out these arguments to ignore these filters.
|
|
564
605
|
|
565
606
|
#### status (optional)
|
566
607
|
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|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|||
|
576
|
-
|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|||
|
577
|
-
|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|||
|
578
|
-
|accepted|GOV.UK Notify has sent the letter to the provider to be printed.|||Yes||
|
579
|
-
|received|The provider has printed and dispatched the letter.|||Yes||
|
580
|
-
|pending-virus-check|GOV.UK Notify is scanning the precompiled letter file for viruses.||||Yes|
|
581
|
-
|virus-scan-failed|GOV.UK Notify found a potential virus in the precompiled letter file.||||Yes|
|
582
|
-
|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.
|
583
616
|
|
584
617
|
#### templateType (optional)
|
585
618
|
|
@@ -611,7 +644,7 @@ The client only returns notifications that are 7 days old or newer. If the notif
|
|
611
644
|
|
612
645
|
### Response
|
613
646
|
|
614
|
-
If the request to the client is successful, the client returns a `Notifications::Client::NotificationsCollection` object. In the example shown in the [Method section](
|
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`.
|
615
648
|
|
616
649
|
You must then call either the `.links` method or the `.collection` method on this object.
|
617
650
|
|
@@ -649,14 +682,54 @@ If the notification specified in the `older_than` argument is older than 7 days,
|
|
649
682
|
|
650
683
|
### Error codes
|
651
684
|
|
652
|
-
If the request is not successful, the client
|
685
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
653
686
|
|
654
687
|
|error.code|error.message|class|How to fix|
|
655
688
|
|:---|:---|:---|:---|
|
656
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|
|
657
690
|
|`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the GOV.UK Notify team|
|
658
691
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
659
|
-
|`403`|`AuthError: Invalid token:
|
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:
|
721
|
+
|
722
|
+
|error.code|error.message|class|How to fix|
|
723
|
+
|:---|:---|:---|:---|
|
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
|
+
|
660
733
|
|
661
734
|
# Get a template
|
662
735
|
|
@@ -674,7 +747,7 @@ response = client.get_template_by_id(id)
|
|
674
747
|
|
675
748
|
#### id (required)
|
676
749
|
|
677
|
-
The ID of the template. Sign
|
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:
|
678
751
|
|
679
752
|
```
|
680
753
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
@@ -682,7 +755,7 @@ The ID of the template. Sign into GOV.UK Notify and go to the __Templates__ page
|
|
682
755
|
|
683
756
|
### Response
|
684
757
|
|
685
|
-
If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](
|
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`.
|
686
759
|
|
687
760
|
You can then call different methods on this object to return the requested information.
|
688
761
|
|
@@ -697,17 +770,18 @@ You can then call different methods on this object to return the requested infor
|
|
697
770
|
|`response.version`|Template version|String|
|
698
771
|
|`response.body`|Template content|String|
|
699
772
|
|`response.subject`|Template subject (email and letter)|String|
|
773
|
+
|`response.letter_contact_block`|Template letter contact block (letter)|String|
|
700
774
|
|
701
775
|
### Error codes
|
702
776
|
|
703
|
-
If the request is not successful, the client
|
777
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
704
778
|
|
705
779
|
|error.code|error.message|class|How to fix|
|
706
780
|
|:---|:---|:---|:---|
|
707
781
|
|`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
|
708
782
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
709
|
-
|`403`|`AuthError: Invalid token:
|
710
|
-
|`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](
|
783
|
+
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
784
|
+
|`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-arguments-id-required)|
|
711
785
|
|
712
786
|
## Get a template by ID and version
|
713
787
|
|
@@ -721,7 +795,7 @@ response = client.get_template_version(id, version)
|
|
721
795
|
|
722
796
|
#### id (required)
|
723
797
|
|
724
|
-
The ID of the template. Sign in to GOV.UK Notify and go to the __Templates__ page to find
|
798
|
+
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:
|
725
799
|
|
726
800
|
```ruby
|
727
801
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
@@ -733,7 +807,7 @@ The version number of the template.
|
|
733
807
|
|
734
808
|
### Response
|
735
809
|
|
736
|
-
If the request to the client is successful, the client returns a `Notifications::Client::Template` object. In the example shown in the [Method section](
|
810
|
+
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`.
|
737
811
|
|
738
812
|
You can then call different methods on this object to return the requested information.
|
739
813
|
|
@@ -748,17 +822,18 @@ You can then call different methods on this object to return the requested infor
|
|
748
822
|
|`response.version`|Template version|String|
|
749
823
|
|`response.body`|Template content|String|
|
750
824
|
|`response.subject`|Template subject (email and letter)|String|
|
825
|
+
|`response.letter_contact_block`|Template letter contact block (letter)|String|
|
751
826
|
|
752
827
|
### Error codes
|
753
828
|
|
754
|
-
If the request is not successful, the client
|
829
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
755
830
|
|
756
831
|
|error.code|error.message|class|How to fix|
|
757
832
|
|:---|:---|:---|:---|
|
758
833
|
|`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
|
759
834
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
760
|
-
|`403`|`AuthError: Invalid token:
|
761
|
-
|`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](
|
835
|
+
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
836
|
+
|`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-and-version-arguments-id-required) and [version](#version-required)|
|
762
837
|
|
763
838
|
## Get all templates
|
764
839
|
|
@@ -785,7 +860,7 @@ If you do not use `type`, the client returns all templates. Otherwise you can fi
|
|
785
860
|
|
786
861
|
### Response
|
787
862
|
|
788
|
-
If the request to the client is successful, the client returns a `Notifications::Client::TemplateCollection` object. In the example shown in the [Method section](
|
863
|
+
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`.
|
789
864
|
|
790
865
|
You must then call the `.collection` method on this object to return an array of the required templates.
|
791
866
|
|
@@ -802,12 +877,13 @@ Once the client has returned a template array, you must then call the following
|
|
802
877
|
|`response.version`|Template version|String|
|
803
878
|
|`response.body`|Template content|String|
|
804
879
|
|`response.subject`|Template subject (email and letter)|String|
|
880
|
+
|`response.letter_contact_block`|Template letter contact block (letter)|String|
|
805
881
|
|
806
882
|
If no templates exist for a template type or there no templates for a service, the templates array will be empty.
|
807
883
|
|
808
884
|
### Error codes
|
809
885
|
|
810
|
-
If the request is not successful, the client
|
886
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
811
887
|
|
812
888
|
|error.code|error.message|class|How to fix|
|
813
889
|
|:---|:---|:---|:---|
|
@@ -829,7 +905,7 @@ The parameters in the personalisation argument must match the placeholder fields
|
|
829
905
|
|
830
906
|
#### id (required)
|
831
907
|
|
832
|
-
The ID of the template. Sign
|
908
|
+
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:
|
833
909
|
|
834
910
|
```ruby
|
835
911
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
@@ -842,7 +918,7 @@ If a template has placeholder fields for personalised information such as name o
|
|
842
918
|
```ruby
|
843
919
|
personalisation: {
|
844
920
|
name: "John Smith",
|
845
|
-
ID: "300241",
|
921
|
+
ID: "300241",
|
846
922
|
}
|
847
923
|
```
|
848
924
|
|
@@ -850,7 +926,7 @@ You can leave out this argument if a template does not have any placeholder fiel
|
|
850
926
|
|
851
927
|
### Response
|
852
928
|
|
853
|
-
If the request to the client is successful, the client returns a `Notifications::Client::TemplatePreview` object. In the example shown in the [Method section](
|
929
|
+
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`.
|
854
930
|
|
855
931
|
You can then call different methods on this object to return the requested information.
|
856
932
|
|
@@ -865,14 +941,14 @@ You can then call different methods on this object to return the requested infor
|
|
865
941
|
|
866
942
|
### Error codes
|
867
943
|
|
868
|
-
If the request is not successful, the client
|
944
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
869
945
|
|
870
946
|
|error.code|error.message|class|How to fix|
|
871
947
|
|:---|:---|:---|:---|
|
872
948
|
|`400`|`BadRequestError: Missing personalisation: [PERSONALISATION FIELD]`|`BadRequestError`|Check that the personalisation arguments in the method match the placeholder fields in the template|
|
873
|
-
|`400`|`NoResultFound: No result found`|`BadRequestError`|Check the [template ID](
|
949
|
+
|`400`|`NoResultFound: No result found`|`BadRequestError`|Check the [template ID](#generate-a-preview-template-arguments-id-required)|
|
874
950
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
875
|
-
|`403`|`AuthError: Invalid token:
|
951
|
+
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|
876
952
|
|
877
953
|
# Get received text messages
|
878
954
|
|
@@ -880,11 +956,11 @@ This API call returns one page of up to 250 received text messages. You can get
|
|
880
956
|
|
881
957
|
You can only get the status of messages that are 7 days old or newer.
|
882
958
|
|
883
|
-
You can also set up [callbacks](
|
959
|
+
You can also set up [callbacks](#callbacks) for received text messages.
|
884
960
|
|
885
961
|
## Enable received text messages
|
886
962
|
|
887
|
-
Contact the GOV.UK Notify team
|
963
|
+
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.
|
888
964
|
|
889
965
|
## Get a page of received text messages
|
890
966
|
|
@@ -917,7 +993,7 @@ The client only returns notifications that are 7 days old or newer. If the notif
|
|
917
993
|
|
918
994
|
### Response
|
919
995
|
|
920
|
-
If the request to the client is successful, the client returns a `Notifications::Client::ReceivedTextCollection` object. In the example shown in the [Method section](
|
996
|
+
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`.
|
921
997
|
|
922
998
|
You must then call either the `.links` method or the `.collection` method on this object.
|
923
999
|
|
@@ -941,9 +1017,9 @@ If the notification specified in the `older_than` argument is older than 7 days,
|
|
941
1017
|
|
942
1018
|
### Error codes
|
943
1019
|
|
944
|
-
If the request is not successful, the client
|
1020
|
+
If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
|
945
1021
|
|
946
1022
|
|error.code|error.message|class|How to fix|
|
947
1023
|
|:---|:---|:---|:---|
|
948
1024
|
|`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
|
949
|
-
|`403`|`AuthError: Invalid token:
|
1025
|
+
|`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
|