notifications-node-client 5.0.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## 5.1.1 - 2022-01-18
2
+
3
+ Upgrade axios version from ^0.21.1 to ^0.25.0
4
+
5
+ ## 5.1.0 - 2020-12-30
6
+
7
+ ### Changed
8
+
9
+ * Upgrade axios version from 0.19.2 to 0.21.1
10
+ * Allow any compatible version of axios to be used (0.21.1 to <1.0.0)
11
+ * Allow any compatible version of jsonwebtoken to be used (8.2.1 to <9.0.0)
12
+
13
+ ## 5.0.2 - 2020-11-20
14
+
15
+ ### Changed
16
+
17
+ Correct incorrect description of parameter to be used by `NotifyClient.setProxy`
18
+
19
+ ## 5.0.1 - 2020-11-18
20
+
21
+ ### Changed
22
+
23
+ Remove unintentional global nature of variable `version`
24
+
1
25
  ## 5.0.0 - 2020-09-02
2
26
 
3
27
  ### Changed
package/CONTRIBUTING.md CHANGED
@@ -2,52 +2,58 @@
2
2
 
3
3
  Pull requests welcome.
4
4
 
5
- ## Working on the client locally
5
+ ## Setting Up
6
6
 
7
- `npm install --save notifications-node-client`
7
+ ### Docker container
8
8
 
9
- ## Tests
9
+ This app uses dependencies that are difficult to install locally. In order to make local development easy, we run app commands through a Docker container. Run the following to set this up:
10
10
 
11
- There are unit and integration tests that can be run to test functionality of the client.
11
+ ```shell
12
+ make bootstrap-with-docker
13
+ ```
12
14
 
13
- To run the unit tests:
15
+ ### `environment.sh`
16
+
17
+ In the root directory of the repo, run:
18
+
19
+ ```
20
+ notify-pass credentials/client-integration-tests > environment.sh
21
+ ```
22
+
23
+ Unless you're part of the GOV.UK Notify team, you won't be able to run this command or the Integration Tests. However, the file still needs to exist - run `touch environment.sh` instead.
24
+
25
+ ## Tests
14
26
 
15
- `make test`
27
+ There are unit and integration tests that can be run to test functionality of the client.
16
28
 
17
- ## Integration Tests
29
+ ### Unit tests
18
30
 
19
- Before running the integration tests, please ensure that the environment variables are set up.
31
+ To run the unit tests:
20
32
 
21
33
  ```
22
- export NOTIFY_API_URL="https://example.notify-api.url"
23
- export API_KEY="example_API_test_key"
24
- export FUNCTIONAL_TEST_NUMBER="valid mobile number"
25
- export FUNCTIONAL_TEST_EMAIL="valid email address"
26
- export EMAIL_TEMPLATE_ID="valid email_template_id"
27
- export SMS_TEMPLATE_ID="valid sms_template_id"
28
- export LETTER_TEMPLATE_ID="valid letter_template_id"
29
- export EMAIL_REPLY_TO_ID="valid email reply to id"
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_team_key for sending a SMS to a receiving number"
32
- export INBOUND_SMS_QUERY_KEY="API_test_key to get received text messages - leave blank for local development as cannot test locally"
34
+ make test-with-docker
33
35
  ```
34
36
 
37
+ ### Integration Tests
35
38
 
36
39
  To run the integration tests:
37
40
 
38
- `make integration-test`
39
-
40
- The integration tests are used to test the contract of the response to all the api calls, ensuring the latest version of notifications-api do not break the contract of the notifications-node-client.
41
+ ```
42
+ make integration-test-with-docker
43
+ ```
41
44
 
42
- ## Testing JavaScript examples in Markdown
45
+ ## Working on the client locally
43
46
 
44
- We automatically test that the JavaScript in the documentation examples matched [our linting standards](https://gds-way.cloudapps.digital/manuals/programming-languages/nodejs/#source-formatting-and-linting),
45
- this also catches some issues that could stop an example from running when copied.
47
+ ```
48
+ npm install --save notifications-node-client
49
+ ```
46
50
 
47
- To test the JavaScript for syntax and linting errors run:
51
+ ## Testing JavaScript examples in Markdown
48
52
 
49
- `make markdown-standard-test`
53
+ We automatically test that the JavaScript in the documentation examples matches [our linting standards](https://gds-way.cloudapps.digital/manuals/programming-languages/nodejs/#source-formatting-and-linting). This also catches some issues that could stop an example from running when copied.
50
54
 
51
- You can then fix some issues automatically by running:
55
+ You can fix issues automatically by running:
52
56
 
53
- `make markdown-standard-test-fix`
57
+ ```
58
+ npm run test:markdown:standard -- --fix
59
+ ```
package/DOCUMENTATION.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  This documentation is for developers interested in using the GOV.UK Notify Node.js client to send emails, text messages or letters.
4
4
 
5
- # Set up the client
5
+ ## Set up the client
6
6
 
7
- ## Install the client
7
+ ### Install the client
8
8
 
9
9
  Run the following in the command line:
10
10
 
@@ -12,7 +12,7 @@ Run the following in the command line:
12
12
  npm install --save notifications-node-client
13
13
  ```
14
14
 
15
- ## Create a new instance of the client
15
+ ### Create a new instance of the client
16
16
 
17
17
  Add this code to your application:
18
18
 
@@ -24,7 +24,7 @@ var notifyClient = new NotifyClient(apiKey)
24
24
 
25
25
  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.
26
26
 
27
- ### Connect through a proxy (optional)
27
+ #### Connect through a proxy (optional)
28
28
 
29
29
  Add this code to your application:
30
30
 
@@ -39,13 +39,13 @@ notifyClient.setProxy(proxyConfig)
39
39
 
40
40
  where the `proxyConfig` should be an object supported by [axios](https://github.com/axios/axios).
41
41
 
42
- # Send a message
42
+ ## Send a message
43
43
 
44
44
  You can use GOV.UK Notify to send text messages, emails (including documents) and letters.
45
45
 
46
- ## Send a text message
46
+ ### Send a text message
47
47
 
48
- ### Method
48
+ #### Method
49
49
 
50
50
  ```javascript
51
51
  notifyClient
@@ -63,9 +63,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
63
63
  - resolve with a `response` if successful
64
64
  - fail with an `err` if unsuccessful
65
65
 
66
- ### Arguments
66
+ #### Arguments
67
67
 
68
- #### templateId (required)
68
+ ##### templateId (required)
69
69
 
70
70
  To find the template ID:
71
71
 
@@ -79,7 +79,7 @@ For example:
79
79
  'f33517ff-2a88-4f6e-b855-c550268ce08a'
80
80
  ```
81
81
 
82
- #### phoneNumber (required)
82
+ ##### phoneNumber (required)
83
83
 
84
84
  The phone number of the recipient of the text message. This number can be a UK or international number. For example:
85
85
 
@@ -87,7 +87,7 @@ The phone number of the recipient of the text message. This number can be a UK o
87
87
  '+447900900123'
88
88
  ```
89
89
 
90
- #### personalisation (required)
90
+ ##### personalisation (required)
91
91
 
92
92
  If a template has placeholder fields for personalised information such as name or reference number, you must provide their values in an `object`. For example:
93
93
 
@@ -98,7 +98,7 @@ If a template has placeholder fields for personalised information such as name o
98
98
  }
99
99
  ```
100
100
 
101
- #### reference (required)
101
+ ##### reference (required)
102
102
 
103
103
  A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. If you do not have a reference, you must pass in an empty string or `null`. For example:
104
104
 
@@ -106,7 +106,7 @@ A unique identifier you create. This reference identifies a single unique notifi
106
106
  'your_reference_here'
107
107
  ```
108
108
 
109
- #### smsSenderId (optional)
109
+ ##### smsSenderId (optional)
110
110
 
111
111
  A unique identifier of the sender of the text message notification. For example:
112
112
 
@@ -127,7 +127,7 @@ In this screen, you can either:
127
127
 
128
128
  You can leave out this argument if your service only has one text message sender, or if you want to use the default sender.
129
129
 
130
- ### Response
130
+ #### Response
131
131
 
132
132
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
133
133
 
@@ -152,13 +152,13 @@ If you are using the [test API key](#test), all your messages come back with a `
152
152
 
153
153
  All messages sent using the [team and guest list](#team-and-guest-list) or [live](#live) keys appear on your dashboard.
154
154
 
155
- ### Error codes
155
+ #### Error codes
156
156
 
157
157
  If the request is not successful, the promise fails with an `err`.
158
158
 
159
159
  |err.response.data.status_code|err.response.data.errors|How to fix|
160
160
  |:---|:---|:---|
161
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|Use the correct type of [API key](#api-keys)|
161
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`}]`|Use the correct type of [API key](#api-keys)|
162
162
  |`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>`}]`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
163
163
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
164
164
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: API key not found"`<br>`}]`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
@@ -166,9 +166,9 @@ If the request is not successful, the promise fails with an `err`.
166
166
  |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|Refer to [service limits](#daily-limits) for the limit number|
167
167
  |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|Notify was unable to process the request, resend your notification|
168
168
 
169
- ## Send an email
169
+ ### Send an email
170
170
 
171
- ### Method
171
+ #### Method
172
172
 
173
173
  ```javascript
174
174
  notifyClient
@@ -186,9 +186,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
186
186
  - resolve with a `response` if successful
187
187
  - fail with an `err` if unsuccessful
188
188
 
189
- ### Arguments
189
+ #### Arguments
190
190
 
191
- #### templateId (required)
191
+ ##### templateId (required)
192
192
 
193
193
  To find the template ID:
194
194
 
@@ -202,7 +202,7 @@ For example:
202
202
  "f33517ff-2a88-4f6e-b855-c550268ce08a"
203
203
  ```
204
204
 
205
- #### emailAddress (required)
205
+ ##### emailAddress (required)
206
206
 
207
207
  The email address of the recipient. For example:
208
208
 
@@ -210,7 +210,7 @@ The email address of the recipient. For example:
210
210
  "sender@something.com"
211
211
  ```
212
212
 
213
- #### personalisation (required)
213
+ ##### personalisation (required)
214
214
 
215
215
  If a template has placeholder fields for personalised information such as name or application date, you must provide their values in an `object`. For example:
216
216
 
@@ -223,7 +223,7 @@ If a template has placeholder fields for personalised information such as name o
223
223
  }
224
224
  ```
225
225
 
226
- #### reference (required)
226
+ ##### reference (required)
227
227
 
228
228
  A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. If you do not have a reference, you must pass in an empty string or `null`. For example:
229
229
 
@@ -231,7 +231,7 @@ A unique identifier you create. This reference identifies a single unique notifi
231
231
  "your_reference_here"
232
232
  ```
233
233
 
234
- #### emailReplyToId (optional)
234
+ ##### emailReplyToId (optional)
235
235
 
236
236
  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.
237
237
 
@@ -249,7 +249,7 @@ emailReplyToId='8e222534-7f05-4972-86e3-17c5d9f894e2'
249
249
 
250
250
  You can leave out this argument if your service only has one reply-to email address, or you want to use the default email address.
251
251
 
252
- ### Response
252
+ #### Response
253
253
 
254
254
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
255
255
 
@@ -271,13 +271,13 @@ If the request is successful, the promise resolves with a `response` `object`. F
271
271
  }
272
272
  ```
273
273
 
274
- ### Error codes
274
+ #### Error codes
275
275
 
276
276
  If the request is not successful, the promise fails with an `err`.
277
277
 
278
278
  |err.response.data.status_code|err.response.data.errors|How to fix|
279
279
  |:--- |:---|:---|
280
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|Use the correct type of [API key](#api-keys)|
280
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`}]`|Use the correct type of [API key](#api-keys)|
281
281
  |`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>`}]`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
282
282
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
283
283
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: API key not found"`<br>`}]`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
@@ -285,20 +285,22 @@ If the request is not successful, the promise fails with an `err`.
285
285
  |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|Refer to [service limits](#daily-limits) for the limit number|
286
286
  |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|Notify was unable to process the request, resend your notification|
287
287
 
288
- ## Send a file by email
288
+ ### Send a file by email
289
289
 
290
290
  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.
291
291
 
292
+ The file will be available for the recipient to download for 18 months.
293
+
292
294
  The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
293
295
 
294
- ### Add contact details to the file download page
296
+ #### Add contact details to the file download page
295
297
 
296
298
  1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
297
299
  1. Go to the __Settings__ page.
298
300
  1. In the __Email__ section, select __Manage__ on the __Send files by email__ row.
299
301
  1. Enter the contact details you want to use, and select __Save__.
300
302
 
301
- ### Add a placeholder to the template
303
+ #### Add a placeholder to the template
302
304
 
303
305
  1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
304
306
  1. Go to the __Templates__ page and select the relevant email template.
@@ -307,9 +309,9 @@ The links are unique and unguessable. GOV.UK Notify cannot access or decrypt you
307
309
 
308
310
  "Download your file at: ((link_to_file))"
309
311
 
310
- ### Upload your file
312
+ #### Upload your file
311
313
 
312
- 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.
314
+ You can upload PDF, CSV, .odt, .txt, .rtf, .xlsx 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.
313
315
 
314
316
  Pass the file object as a value into the `personalisation` argument. For example:
315
317
 
@@ -333,7 +335,7 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
333
335
  - resolve with a `response` if successful
334
336
  - fail with an `err` if unsuccessful
335
337
 
336
- #### CSV Files
338
+ ##### CSV Files
337
339
 
338
340
  Uploads for CSV files should use the `isCsv` parameter on the `prepareUpload()` function. For example:
339
341
 
@@ -352,7 +354,7 @@ fs.readFile('path/to/document.csv', function (err, csvFile) {
352
354
  })
353
355
  ```
354
356
 
355
- ### Response
357
+ #### Response
356
358
 
357
359
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
358
360
 
@@ -374,15 +376,15 @@ If the request is successful, the promise resolves with a `response` `object`. F
374
376
  }
375
377
  ```
376
378
 
377
- ### Error codes
379
+ #### Error codes
378
380
 
379
381
  If the request is not successful, the promise fails with an `err`.
380
382
 
381
383
  |err.response.data.status_code|err.response.data.errors|How to fix|
382
384
  |:---|:---|:---|
383
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|Use the correct type of [API key](#api-keys)|
385
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`}]`|Use the correct type of [API key](#api-keys)|
384
386
  |`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>`}]`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
385
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'"`<br>`}]`|Wrong file type. You can only upload .pdf, .csv, .txt, .doc, .docx or .odt files|
387
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'"`<br>`}]`|Wrong file type. You can only upload .pdf, .csv, .txt, .doc, .docx, .xlsx, .rtf or .odt files|
386
388
  |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "File did not pass the virus scan"`<br>`}]`|The file contains a virus|
387
389
  |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "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"`<br>`}]`|See how to [add contact details to the file download page](#add-contact-details-to-the-file-download-page)|
388
390
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
@@ -392,7 +394,7 @@ If the request is not successful, the promise fails with an `err`.
392
394
  |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|Notify was unable to process the request, resend your notification.|
393
395
  |`N/A`|`File is larger than 2MB`|The file is too big. Files must be smaller than 2MB|
394
396
 
395
- ## Send a letter
397
+ ### Send a letter
396
398
 
397
399
  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.
398
400
 
@@ -402,7 +404,7 @@ To send Notify a request to go live:
402
404
  1. Go to the __Settings__ page.
403
405
  1. In the __Your service is in trial mode__ section, select __request to go live__.
404
406
 
405
- ### Method
407
+ #### Method
406
408
 
407
409
  ```javascript
408
410
  notifyClient
@@ -419,9 +421,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
419
421
  - resolve with a `response` if successful
420
422
  - fail with an `err` if unsuccessful
421
423
 
422
- ### Arguments
424
+ #### Arguments
423
425
 
424
- #### templateId (required)
426
+ ##### templateId (required)
425
427
 
426
428
  To find the template ID:
427
429
 
@@ -435,15 +437,15 @@ For example:
435
437
  "f33517ff-2a88-4f6e-b855-c550268ce08a"
436
438
  ```
437
439
 
438
- #### personalisation (required)
440
+ ##### personalisation (required)
439
441
 
440
442
  The personalisation argument always contains the following parameters for the letter recipient’s address:
441
443
 
442
444
  - `address_line_1`
443
445
  - `address_line_2`
444
- - `address_line_3`
445
- - `address_line_4`
446
- - `address_line_5`
446
+ - `address_line_3`
447
+ - `address_line_4`
448
+ - `address_line_5`
447
449
  - `address_line_6`
448
450
  - `address_line_7`
449
451
 
@@ -468,7 +470,7 @@ Any other placeholder fields included in the letter template also count as requi
468
470
  }
469
471
  ```
470
472
 
471
- #### reference (optional)
473
+ ##### reference (optional)
472
474
 
473
475
  A unique identifier you can create if required. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:
474
476
 
@@ -476,7 +478,7 @@ A unique identifier you can create if required. This reference identifies a sing
476
478
  "your_reference_here"
477
479
  ```
478
480
 
479
- ### Response
481
+ #### Response
480
482
 
481
483
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
482
484
 
@@ -498,13 +500,13 @@ If the request is successful, the promise resolves with a `response` `object`. F
498
500
  }
499
501
  ```
500
502
 
501
- ### Error codes
503
+ #### Error codes
502
504
 
503
505
  If the request is not successful, the promise fails with an `err`.
504
506
 
505
507
  |err.response.data.status_code|err.response.data.errors|How to fix|
506
508
  |:--- |:---|:---|
507
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`]}`|Use the correct type of [API key](#api-keys).|
509
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`}]`|Use the correct type of [API key](#api-keys).|
508
510
  |`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>`}]`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode).|
509
511
  |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "personalisation address_line_1 is a required property"`<br>`}]`|Ensure that your template has a field for the first line of the address, refer to [personalisation](#send-a-letter-arguments-personalisation-required) for more information.|
510
512
  |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Must be a real UK postcode"`<br>`}]`|Ensure that the value for the last line of the address is a real UK postcode.|
@@ -516,9 +518,9 @@ If the request is not successful, the promise fails with an `err`.
516
518
  |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|Notify was unable to process the request, resend your notification.|
517
519
 
518
520
 
519
- ## Send a precompiled letter
521
+ ### Send a precompiled letter
520
522
 
521
- ### Method
523
+ #### Method
522
524
 
523
525
  ```javascript
524
526
  var response = notifyClient.sendPrecompiledLetter(
@@ -528,9 +530,9 @@ var response = notifyClient.sendPrecompiledLetter(
528
530
  )
529
531
  ```
530
532
 
531
- ### Arguments
533
+ #### Arguments
532
534
 
533
- #### reference (required)
535
+ ##### reference (required)
534
536
 
535
537
  A unique identifier you create. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:
536
538
 
@@ -538,9 +540,9 @@ A unique identifier you create. This reference identifies a single unique notifi
538
540
  "your_reference_here"
539
541
  ```
540
542
 
541
- #### pdfFile
543
+ ##### pdfFile
542
544
 
543
- 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). For example:
545
+ The precompiled letter must be a PDF file which meets [the GOV.UK Notify letter specification](https://www.notifications.service.gov.uk/using-notify/guidance/letter-specification). For example:
544
546
 
545
547
  ```javascript
546
548
  var fs = require('fs')
@@ -555,12 +557,12 @@ fs.readFile('path/to/document.pdf', function (err, pdfFile) {
555
557
  })
556
558
  ```
557
559
 
558
- #### postage (optional)
560
+ ##### postage (optional)
559
561
 
560
562
  You can choose first or second class postage for your precompiled letter. Set the value to `first` for first class, or `second` for second class. If you do not pass in this argument, the postage will default to second class.
561
563
 
562
564
 
563
- ### Response
565
+ #### Response
564
566
 
565
567
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
566
568
 
@@ -572,13 +574,13 @@ If the request is successful, the promise resolves with a `response` `object`. F
572
574
  }
573
575
  ```
574
576
 
575
- ### Error codes
577
+ #### Error codes
576
578
 
577
579
  If the request is not successful, the promise fails with an `err`.
578
580
 
579
581
  |err.response.data.status_code|err.response.data.errors|How to fix|
580
582
  |:--- |:---|:---|
581
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`]}`|Use the correct type of [API key](#api-keys)|
583
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`}]`|Use the correct type of [API key](#api-keys)|
582
584
  |`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>`}]`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
583
585
  |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "personalisation address_line_1 is a required property"`<br>`}]`|Send a valid PDF file|
584
586
  |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "postage invalid. It must be either first or second."`<br>`}]`|Change the value of `postage` argument in the method call to either 'first' or 'second'|
@@ -590,51 +592,14 @@ If the request is not successful, the promise fails with an `err`.
590
592
  |N/A|`"message":"reference cannot be null or empty"`|Populate the reference parameter|
591
593
  |N/A|`"message":"precompiledPDF cannot be null or empty"`|Send a PDF file with data in it|
592
594
 
593
- # Get message status
594
-
595
- Message status depends on the type of message you have sent.
596
-
597
- You can only get the status of messages that are 7 days old or newer.
598
-
599
- ## Status - email
600
-
601
- |Status|Information|
602
- |:---|:---|
603
- |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.|
604
- |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.|
605
- |Delivered|The message was successfully delivered.|
606
- |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."|
607
-
608
- ## Status - text message
609
-
610
- |Status|Information|
611
- |:---|:---|
612
- |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.|
613
- |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.|
614
- |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.|
615
- |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`.|
616
- |Delivered|The message was successfully delivered.|
617
- |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."|
595
+ ## Get message status
618
596
 
619
- ## Status - letter
620
597
 
621
- |Status|information|
622
- |:---|:---|
623
- |Failed|The only failure status that applies to letters is `technical-failure`. GOV.UK Notify had an unexpected error while sending to our printing provider.|
624
- |Accepted|GOV.UK Notify has sent the letter to the provider to be printed.|
625
- |Received|The provider has printed and dispatched the letter.|
598
+ ### Get the status of one message
626
599
 
627
- ## Status - precompiled letter
600
+ You can only get the status of messages sent within the retention period. The default retention period is 7 days.
628
601
 
629
- |Status|information|
630
- |:---|:---|
631
- |Pending virus check|GOV.UK Notify has not completed a virus scan of the precompiled letter file.|
632
- |Virus scan failed|GOV.UK Notify found a potential virus in the precompiled letter file.|
633
- |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. |
634
-
635
- ## Get the status of one message
636
-
637
- ### Method
602
+ #### Method
638
603
 
639
604
  ```javascript
640
605
  notifyClient
@@ -648,15 +613,16 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
648
613
  - resolve with a `response` if successful
649
614
  - fail with an `err` if unsuccessful
650
615
 
651
- ### Arguments
616
+ #### Arguments
652
617
 
653
- #### notificationId (required)
618
+ ##### notificationId (required)
654
619
 
655
- The ID of the notification. You can find the notification ID in the response to the original notification method call.
620
+ The ID of the notification. To find the notification ID, you can either:
656
621
 
657
- 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.
622
+ * check the response to the [original notification method call](#response)
623
+ * [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page
658
624
 
659
- ### Response
625
+ #### Response
660
626
 
661
627
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
662
628
 
@@ -689,7 +655,7 @@ If the request is successful, the promise resolves with a `response` `object`. F
689
655
  }
690
656
  ```
691
657
 
692
- ### Error codes
658
+ #### Error codes
693
659
 
694
660
  If the request is not successful, the promise fails with an `err`.
695
661
 
@@ -701,13 +667,13 @@ If the request is not successful, the promise fails with an `err`.
701
667
  |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|Check the notification ID|
702
668
 
703
669
 
704
- ## Get the status of multiple messages
670
+ ### Get the status of multiple messages
705
671
 
706
- This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the [`olderThanId`](#olderthanid) argument.
672
+ This API call returns one page of up to 250 messages and statuses. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the [`olderThan`](#olderthan-optional) argument.
707
673
 
708
674
  You can only get the status of messages that are 7 days old or newer.
709
675
 
710
- ### Method
676
+ #### Method
711
677
 
712
678
  ```javascript
713
679
  notifyClient
@@ -725,22 +691,22 @@ To get the most recent messages, you must pass in an empty `olderThan` argument
725
691
 
726
692
  To get older messages, pass the ID of an older notification into the `olderThan` argument. This returns the next oldest messages from the specified notification ID.
727
693
 
728
- ### Arguments
694
+ #### Arguments
729
695
 
730
696
  You can pass in empty arguments or `null` to ignore these filters.
731
697
 
732
- #### status (optional)
698
+ ##### status (optional)
733
699
 
734
700
  You can filter by each:
735
701
 
736
- * [email status](#status-email)
737
- * [text message status](#status-text-message)
738
- * [letter status](#status-letter)
739
- * [precompiled letter status](#status-precompiled-letter)
702
+ * [email status](#email-status-descriptions)
703
+ * [text message status](#text-message-status-descriptions)
704
+ * [letter status](#letter-status-descriptions)
705
+ * [precompiled letter status](#precompiled-letter-status-descriptions)
740
706
 
741
707
  You can leave out this argument to ignore this filter.
742
708
 
743
- #### notificationType (optional)
709
+ ##### notificationType (optional)
744
710
 
745
711
  You can filter by:
746
712
 
@@ -748,7 +714,7 @@ You can filter by:
748
714
  * `sms`
749
715
  * `letter`
750
716
 
751
- #### reference (optional)
717
+ ##### reference (optional)
752
718
 
753
719
  A unique identifier you create if necessary. This reference identifies a single unique notification or a batch of notifications. It must not contain any personal information such as name or postal address. For example:
754
720
 
@@ -756,7 +722,7 @@ A unique identifier you create if necessary. This reference identifies a single
756
722
  "your_reference_here"
757
723
  ```
758
724
 
759
- #### olderThan (optional)
725
+ ##### olderThan (optional)
760
726
 
761
727
  Input the ID of a notification into this argument. If you use this argument, the client returns the next 250 received notifications older than the given ID. For example:
762
728
 
@@ -766,7 +732,7 @@ Input the ID of a notification into this argument. If you use this argument, the
766
732
 
767
733
  If you pass in an empty argument or `null`, the client returns the most recent 250 notifications.
768
734
 
769
- ### Response
735
+ #### Response
770
736
 
771
737
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
772
738
 
@@ -806,7 +772,7 @@ If the request is successful, the promise resolves with a `response` `object`. F
806
772
  }
807
773
  ```
808
774
 
809
- ### Error codes
775
+ #### Error codes
810
776
 
811
777
  If the request is not successful, the promise fails with an `err`.
812
778
 
@@ -817,10 +783,56 @@ If the request is not successful, the promise fails with an `err`.
817
783
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
818
784
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: API key not found"`<br>`}]`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
819
785
 
786
+ ### Email status descriptions
787
+
788
+ |Status|Description|
789
+ |:---|:---|
790
+ |#`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.|
791
+ |#`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.|
792
+ |#`delivered`|The message was successfully delivered.|
793
+ |#`permanent-failure`|The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database.|
794
+ |#`temporary-failure`|The provider could not deliver the message. This can happen when the recipient’s inbox is full or their anti-spam filter rejects your email. [Check your content does not look like spam](https://www.gov.uk/service-manual/design/sending-emails-and-text-messages#protect-your-users-from-spam-and-phishing) before you try to send the message again.|
795
+ |#`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.|
796
+
797
+ ### Text message status descriptions
798
+
799
+ |Status|Description|
800
+ |:---|:---|
801
+ |#`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.|
802
+ |#`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.|
803
+ |#`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 text message.|
804
+ |#`sent`|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 website displays this status as 'Sent to an international number'.|
805
+ |#`delivered`|The message was successfully delivered.|
806
+ |#`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.
807
+ |#`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.|
808
+ |#`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.|
809
+
810
+ ### Letter status descriptions
811
+
812
+ |Status|Description|
813
+ |:---|:---|
814
+ |#`accepted`|GOV.UK Notify has sent the letter to the provider to be printed.|
815
+ |#`received`|The provider has printed and dispatched the letter.|
816
+ |#`cancelled`|Sending cancelled. The letter will not be printed or dispatched.|
817
+ |#`technical-failure`|GOV.UK Notify had an unexpected error while sending the letter to our printing provider.|
818
+ |#`permanent-failure`|The provider cannot print the letter. Your letter will not be dispatched.|
819
+
820
+ ### Precompiled letter status descriptions
821
+
822
+ |Status|Description|
823
+ |:---|:---|
824
+ |#`accepted`|GOV.UK Notify has sent the letter to the provider to be printed.|
825
+ |#`received`|The provider has printed and dispatched the letter.|
826
+ |#`cancelled`|Sending cancelled. The letter will not be printed or dispatched.|
827
+ |#`pending-virus-check`|GOV.UK Notify has not completed a virus scan of the precompiled letter file.|
828
+ |#`virus-scan-failed`|GOV.UK Notify found a potential virus in the precompiled letter file.|
829
+ |#`validation-failed`|Content in the precompiled letter file is outside the printable area. See the [GOV.UK Notify letter specification](https://www.notifications.service.gov.uk/using-notify/guidance/letter-specification) for more information.|
830
+ |#`technical-failure`|GOV.UK Notify had an unexpected error while sending the letter to our printing provider.|
831
+ |#`permanent-failure`|The provider cannot print the letter. Your letter will not be dispatched.|
820
832
 
821
- ## Get a PDF for a letter notification
833
+ ### Get a PDF for a letter notification
822
834
 
823
- ### Method
835
+ #### Method
824
836
 
825
837
  ```javascript
826
838
  notifyClient
@@ -836,19 +848,20 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
836
848
  - resolve with `fileBuffer` if successful
837
849
  - fail with an `err` if unsuccessful
838
850
 
839
- ### Arguments
851
+ #### Arguments
840
852
 
841
- #### notification_id (required)
853
+ ##### notificationId (required)
842
854
 
843
- The ID of the notification. You can find the notification ID in the response to the [original notification method call](/python.html#get-the-status-of-one-message-response).
855
+ The ID of the notification. To find the notification ID, you can either:
844
856
 
845
- 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.
857
+ * check the response to the [original notification method call](#get-the-status-of-one-message-response)
858
+ * [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page
846
859
 
847
- ### Response
860
+ #### Response
848
861
 
849
862
  If the request to the client is successful, the client will return an instance of the [Buffer](https://nodejs.org/api/buffer.html#buffer_buffer) class containing the raw PDF data.
850
863
 
851
- ### Error codes
864
+ #### Error codes
852
865
 
853
866
  If the request is not successful, the client will return an `HTTPError` containing the relevant error code:
854
867
 
@@ -864,11 +877,11 @@ If the request is not successful, the client will return an `HTTPError` containi
864
877
  |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|Check the notification ID|
865
878
 
866
879
 
867
- # Get a template
880
+ ## Get a template
868
881
 
869
- ## Get a template by ID
882
+ ### Get a template by ID
870
883
 
871
- ### Method
884
+ #### Method
872
885
 
873
886
  This returns the latest version of the template.
874
887
 
@@ -884,9 +897,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
884
897
  - resolve with a `response` if successful
885
898
  - fail with an `err` if unsuccessful
886
899
 
887
- ### Arguments
900
+ #### Arguments
888
901
 
889
- #### templateId (required)
902
+ ##### templateId (required)
890
903
 
891
904
  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:
892
905
 
@@ -894,7 +907,7 @@ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.ser
894
907
  "f33517ff-2a88-4f6e-b855-c550268ce08a"
895
908
  ```
896
909
 
897
- ### Response
910
+ #### Response
898
911
 
899
912
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
900
913
 
@@ -913,7 +926,7 @@ If the request is successful, the promise resolves with a `response` `object`. F
913
926
  }
914
927
  ```
915
928
 
916
- ### Error codes
929
+ #### Error codes
917
930
 
918
931
  If the request is not successful, the promise fails with an `err`.
919
932
 
@@ -921,12 +934,12 @@ If the request is not successful, the promise fails with an `err`.
921
934
  |:---|:---|:---|
922
935
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
923
936
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: API key not found"`<br>`}]`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
924
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|Check your [template ID](#arguments-template-id-required)|
937
+ |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|Check your [template ID](#get-a-template-by-id-arguments-templateid-required)|
925
938
 
926
939
 
927
- ## Get a template by ID and version
940
+ ### Get a template by ID and version
928
941
 
929
- ### Method
942
+ #### Method
930
943
 
931
944
  ```javascript
932
945
  notifyClient
@@ -940,9 +953,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
940
953
  - resolve with a `response` if successful
941
954
  - fail with an `err` if unsuccessful
942
955
 
943
- ### Arguments
956
+ #### Arguments
944
957
 
945
- #### templateId (required)
958
+ ##### templateId (required)
946
959
 
947
960
  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:
948
961
 
@@ -950,11 +963,11 @@ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.ser
950
963
  "f33517ff-2a88-4f6e-b855-c550268ce08a"
951
964
  ```
952
965
 
953
- #### version (required)
966
+ ##### version (required)
954
967
 
955
968
  The version number of the template.
956
969
 
957
- ### Response
970
+ #### Response
958
971
 
959
972
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
960
973
 
@@ -973,7 +986,7 @@ If the request is successful, the promise resolves with a `response` `object`. F
973
986
  }
974
987
  ```
975
988
 
976
- ### Error codes
989
+ #### Error codes
977
990
 
978
991
  If the request is not successful, the promise fails with an `err`.
979
992
 
@@ -982,12 +995,12 @@ If the request is not successful, the promise fails with an `err`.
982
995
  |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|Check the notification ID|
983
996
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
984
997
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: API key not found"`<br>`}]`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
985
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|Check your [template ID](#get-a-template-by-id-and-version-arguments-template-id-required) and [version](#version)|
998
+ |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|Check your [template ID](#get-a-template-by-id-and-version-arguments-templateid-required) and [version](#version-required)|
986
999
 
987
1000
 
988
- ## Get all templates
1001
+ ### Get all templates
989
1002
 
990
- ### Method
1003
+ #### Method
991
1004
 
992
1005
  This returns the latest version of all templates.
993
1006
 
@@ -1003,9 +1016,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
1003
1016
  - resolve with a `response` if successful
1004
1017
  - fail with an `err` if unsuccessful
1005
1018
 
1006
- ### Arguments
1019
+ #### Arguments
1007
1020
 
1008
- #### templateType (optional)
1021
+ ##### templateType (optional)
1009
1022
 
1010
1023
  If you do not use `templateType`, the client returns all templates. Otherwise you can filter by:
1011
1024
 
@@ -1013,7 +1026,7 @@ If you do not use `templateType`, the client returns all templates. Otherwise yo
1013
1026
  - `sms`
1014
1027
  - `letter`
1015
1028
 
1016
- ### Response
1029
+ #### Response
1017
1030
 
1018
1031
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
1019
1032
 
@@ -1041,9 +1054,9 @@ If the request is successful, the promise resolves with a `response` `object`. F
1041
1054
 
1042
1055
  If no templates exist for a template type or there no templates for a service, the object is empty.
1043
1056
 
1044
- ## Generate a preview template
1057
+ ### Generate a preview template
1045
1058
 
1046
- ### Method
1059
+ #### Method
1047
1060
 
1048
1061
  This generates a preview version of a template.
1049
1062
 
@@ -1062,9 +1075,9 @@ The method returns a [promise](https://developer.mozilla.org/en-US/docs/Web/Java
1062
1075
 
1063
1076
  The parameters in the personalisation argument must match the placeholder fields in the actual template. The API notification client ignores any extra fields in the method.
1064
1077
 
1065
- ### Arguments
1078
+ #### Arguments
1066
1079
 
1067
- #### templateId (required)
1080
+ ##### templateId (required)
1068
1081
 
1069
1082
  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:
1070
1083
 
@@ -1072,7 +1085,7 @@ The ID of the template. [Sign in to GOV.UK Notify](https://www.notifications.ser
1072
1085
  "f33517ff-2a88-4f6e-b855-c550268ce08a"
1073
1086
  ```
1074
1087
 
1075
- #### personalisation (optional)
1088
+ ##### personalisation (optional)
1076
1089
 
1077
1090
  If a template has placeholder fields for personalised information such as name or application date, you must provide their values in an `object`. For example:
1078
1091
 
@@ -1087,7 +1100,7 @@ If a template has placeholder fields for personalised information such as name o
1087
1100
 
1088
1101
  You can leave out this argument if a template does not have any placeholder fields for personalised information.
1089
1102
 
1090
- ### Response
1103
+ #### Response
1091
1104
 
1092
1105
  If the request is successful, the promise resolves with a `response` `object`. For example, the `response.data` property will look like this:
1093
1106
 
@@ -1102,33 +1115,33 @@ If the request is successful, the promise resolves with a `response` `object`. F
1102
1115
  }
1103
1116
  ```
1104
1117
 
1105
- ### Error codes
1118
+ #### Error codes
1106
1119
 
1107
1120
  If the request is not successful, the promise fails with an `err`.
1108
1121
 
1109
1122
  |err.response.data.status_code|err.response.data.errors|How to fix|
1110
1123
  |:---|:---|:---|
1111
1124
  |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Missing personalisation: [PERSONALISATION FIELD]"`<br>`}]`|Check that the personalisation arguments in the method match the placeholder fields in the template|
1112
- |`400`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|Check the [template ID](#generate-a-preview-template-required-arguments-template-id)|
1125
+ |`400`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|Check the [template ID](#generate-a-preview-template-arguments-templateid-required)|
1113
1126
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|Check your system clock|
1114
1127
  |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: API key not found"`<br>`}]`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
1115
1128
 
1116
1129
 
1117
- # Get received text messages
1130
+ ## Get received text messages
1118
1131
 
1119
- This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the [`olderThanId`](#olderThanId) argument.
1132
+ This API call returns one page of up to 250 received text messages. You can get either the most recent messages, or get older messages by specifying a particular notification ID in the [`olderThan`](#get-a-page-of-received-text-messages-arguments-olderthan-optional) argument.
1120
1133
 
1121
1134
  You can only get messages that are 7 days old or newer.
1122
1135
 
1123
1136
  You can also set up [callbacks](#callbacks) for received text messages.
1124
1137
 
1125
- ## Enable received text messages
1138
+ ### Enable received text messages
1126
1139
 
1127
1140
  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.
1128
1141
 
1129
- ## Get a page of received text messages
1142
+ ### Get a page of received text messages
1130
1143
 
1131
- ### Method
1144
+ #### Method
1132
1145
 
1133
1146
  ```javascript
1134
1147
  notifyClient
@@ -1146,9 +1159,9 @@ To get the most recent messages, you must pass in an empty argument or `null`.
1146
1159
 
1147
1160
  To get older messages, pass the ID of an older notification into the `olderThan` argument. This returns the next oldest messages from the specified notification ID.
1148
1161
 
1149
- ### Arguments
1162
+ #### Arguments
1150
1163
 
1151
- #### olderThan (optional)
1164
+ ##### olderThan (optional)
1152
1165
 
1153
1166
  Input the ID of a received text message into this argument. If you use this argument, the client returns the next 250 received text messages older than the given ID. For example:
1154
1167
 
@@ -1158,7 +1171,7 @@ Input the ID of a received text message into this argument. If you use this argu
1158
1171
 
1159
1172
  If you pass in an empty argument or `null`, the client returns the most recent 250 text messages.
1160
1173
 
1161
- ### Response
1174
+ #### Response
1162
1175
 
1163
1176
  If the request to the client is successful, the promise resolves with an `object` containing all received texts.
1164
1177
 
@@ -1185,7 +1198,7 @@ If the request to the client is successful, the promise resolves with an `object
1185
1198
 
1186
1199
  If the notification specified in the `olderThan` argument is older than 7 days, the promise resolves an empty response.
1187
1200
 
1188
- ### Error codes
1201
+ #### Error codes
1189
1202
 
1190
1203
  If the request is not successful, the promise fails with an `err`.
1191
1204
 
package/Makefile CHANGED
@@ -1,22 +1,16 @@
1
1
  .DEFAULT_GOAL := help
2
2
  SHELL := /bin/bash
3
3
 
4
- DOCKER_BUILDER_IMAGE_NAME = govuk/notify-nodejs-client-runner
5
-
6
- BUILD_TAG ?= notifications-nodejs-client-manual
7
-
8
- DOCKER_CONTAINER_PREFIX = ${USER}-${BUILD_TAG}
9
-
10
4
  .PHONY: help
11
5
  help:
12
6
  @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
13
7
 
14
- .PHONY: dependencies
15
- dependencies: ## Install build dependencies
16
- npm install
8
+ .PHONY: bootstrap
9
+ bootstrap: ## Install build dependencies
10
+ npm ci
17
11
 
18
12
  .PHONY: build
19
- build: dependencies ## Build project
13
+ build: bootstrap ## Build project (dummy task for CI)
20
14
 
21
15
  .PHONY: test
22
16
  test: ## Run tests
@@ -26,70 +20,22 @@ test: ## Run tests
26
20
  integration-test: ## Run integration tests
27
21
  npm test --integration
28
22
 
29
- .PHONY: markdown-standard-test
30
- markdown-standard-test: ## Run linting on JavaScript examples in markdown using StandardJS
31
- npm run test:markdown:standard
32
-
33
- .PHONY: markdown-standard-test-fix
34
- markdown-standard-test-fix: ## Fix errors found from linting
35
- npm run test:markdown:standard -- --fix
36
-
37
- .PHONY: generate-env-file
38
- generate-env-file: ## Generate the environment file for running the tests inside a Docker container
39
- script/generate_docker_env.sh
40
-
41
- .PHONY: prepare-docker-runner-image
42
- prepare-docker-runner-image: ## Prepare the Docker builder image
43
- make -C docker build
44
-
45
- .PHONY: build-with-docker
46
- build-with-docker: prepare-docker-runner-image ## Build inside a Docker container
47
- docker run -i --rm \
48
- --name "${DOCKER_CONTAINER_PREFIX}-build" \
49
- -v "`pwd`:/var/project" \
50
- -e http_proxy="${HTTP_PROXY}" \
51
- -e HTTP_PROXY="${HTTP_PROXY}" \
52
- -e https_proxy="${HTTPS_PROXY}" \
53
- -e HTTPS_PROXY="${HTTPS_PROXY}" \
54
- -e NO_PROXY="${NO_PROXY}" \
55
- ${DOCKER_BUILDER_IMAGE_NAME} \
56
- make build
23
+ .PHONY: bootstrap-with-docker
24
+ bootstrap-with-docker: ## Prepare the Docker builder image
25
+ docker build -t notifications-node-client .
26
+ ./scripts/run_with_docker.sh make bootstrap
57
27
 
58
28
  .PHONY: test-with-docker
59
- test-with-docker: prepare-docker-runner-image generate-env-file ## Run tests inside a Docker container
60
- docker run -i --rm \
61
- --name "${DOCKER_CONTAINER_PREFIX}-test" \
62
- -v "`pwd`:/var/project" \
63
- -e http_proxy="${HTTP_PROXY}" \
64
- -e HTTP_PROXY="${HTTP_PROXY}" \
65
- -e https_proxy="${HTTPS_PROXY}" \
66
- -e HTTPS_PROXY="${HTTPS_PROXY}" \
67
- -e NO_PROXY="${NO_PROXY}" \
68
- --env-file docker.env \
69
- ${DOCKER_BUILDER_IMAGE_NAME} \
70
- make test
29
+ test-with-docker: ## Run tests inside a Docker container
30
+ ./scripts/run_with_docker.sh make test
71
31
 
72
32
  .PHONY: integration-test-with-docker
73
- integration-test-with-docker: prepare-docker-runner-image generate-env-file ## Run integration tests inside a Docker container
74
- docker run -i --rm \
75
- --name "${DOCKER_CONTAINER_PREFIX}-integration-test" \
76
- -v "`pwd`:/var/project" \
77
- -e http_proxy="${HTTP_PROXY}" \
78
- -e HTTP_PROXY="${HTTP_PROXY}" \
79
- -e https_proxy="${HTTPS_PROXY}" \
80
- -e HTTPS_PROXY="${HTTPS_PROXY}" \
81
- -e NO_PROXY="${NO_PROXY}" \
82
- --env-file docker.env \
83
- ${DOCKER_BUILDER_IMAGE_NAME} \
84
- make integration-test
33
+ integration-test-with-docker: ## Run integration tests inside a Docker container
34
+ ./scripts/run_with_docker.sh make integration-test
85
35
 
86
36
  .PHONY: get-client-version
87
37
  get-client-version: ## Retrieve client version number from source code
88
38
  @node -p "require('./package.json').version"
89
39
 
90
- .PHONY: clean-docker-containers
91
- clean-docker-containers: ## Clean up any remaining docker containers
92
- docker rm -f $(shell docker ps -q -f "name=${DOCKER_CONTAINER_PREFIX}") 2> /dev/null || true
93
-
94
40
  clean:
95
41
  rm -rf .cache venv
@@ -1,7 +1,7 @@
1
1
  var restClient = require('axios').default,
2
2
  _ = require('underscore'),
3
3
  createGovukNotifyToken = require('../client/authentication.js'),
4
- notifyProductionAPI = 'https://api.notifications.service.gov.uk'
4
+ notifyProductionAPI = 'https://api.notifications.service.gov.uk',
5
5
  version = require('../package.json').version;
6
6
 
7
7
  /**
@@ -336,10 +336,10 @@ _.extend(NotifyClient.prototype, {
336
336
 
337
337
  /**
338
338
  *
339
- * @param {String} url
339
+ * @param {object} an axios proxy config
340
340
  */
341
- setProxy: function(url) {
342
- this.apiClient.setProxy(url);
341
+ setProxy: function(proxyConfig) {
342
+ this.apiClient.setProxy(proxyConfig);
343
343
  },
344
344
 
345
345
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notifications-node-client",
3
- "version": "5.0.0",
3
+ "version": "5.1.1",
4
4
  "homepage": "https://docs.notifications.service.gov.uk/node.html",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,8 +16,8 @@
16
16
  "author": "GDS developers",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "jsonwebtoken": "8.2.1",
20
- "axios": "0.19.2",
19
+ "jsonwebtoken": "^8.2.1",
20
+ "axios": "^0.25.0",
21
21
  "underscore": "^1.9.0"
22
22
  },
23
23
  "devDependencies": {
@@ -0,0 +1,21 @@
1
+ DOCKER_IMAGE_NAME=notifications-node-client
2
+
3
+ source environment.sh
4
+
5
+ docker run \
6
+ --rm \
7
+ -v "`pwd`:/var/project" \
8
+ -e NOTIFY_API_URL=${NOTIFY_API_URL} \
9
+ -e API_KEY=${API_KEY} \
10
+ -e FUNCTIONAL_TEST_NUMBER=${FUNCTIONAL_TEST_NUMBER} \
11
+ -e FUNCTIONAL_TEST_EMAIL=${FUNCTIONAL_TEST_EMAIL} \
12
+ -e EMAIL_TEMPLATE_ID=${EMAIL_TEMPLATE_ID} \
13
+ -e SMS_TEMPLATE_ID=${SMS_TEMPLATE_ID} \
14
+ -e LETTER_TEMPLATE_ID=${LETTER_TEMPLATE_ID} \
15
+ -e EMAIL_REPLY_TO_ID=${EMAIL_REPLY_TO_ID} \
16
+ -e SMS_SENDER_ID=${SMS_SENDER_ID} \
17
+ -e API_SENDING_KEY=${API_SENDING_KEY} \
18
+ -e INBOUND_SMS_QUERY_KEY=${INBOUND_SMS_QUERY_KEY} \
19
+ -it \
20
+ ${DOCKER_IMAGE_NAME} \
21
+ ${@}
File without changes
package/.npmignore DELETED
@@ -1,6 +0,0 @@
1
- node_modules
2
- .idea/
3
- environment.sh
4
- package-lock.json
5
- .eslintrc.js
6
- docker.env
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -eo pipefail
4
-
5
- function exit_with_msg {
6
- echo $1
7
- exit $2
8
- }
9
-
10
- echo -n "" > docker.env
11
-
12
- env_vars=(
13
- NOTIFY_API_URL
14
- API_KEY
15
- FUNCTIONAL_TEST_EMAIL
16
- FUNCTIONAL_TEST_NUMBER
17
- EMAIL_TEMPLATE_ID
18
- LETTER_TEMPLATE_ID
19
- SMS_TEMPLATE_ID
20
- EMAIL_REPLY_TO_ID
21
- SMS_SENDER_ID
22
- API_SENDING_KEY
23
- INBOUND_SMS_QUERY_KEY
24
- )
25
-
26
- for env_var in "${env_vars[@]}"; do
27
- echo "${env_var}=${!env_var}" >> docker.env
28
- done