notifications-ruby-client 5.1.2 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7416ac0a7966ad68c26abb64d8e2a9584317267d2a783d24045eeefeee7386e2
4
- data.tar.gz: 065f683863555d3daa8eb77f3ce36f2b7c8ab7760c590bee06da8065de687a8e
3
+ metadata.gz: 5c2ca0e37a78051cacf6b35de97f7a2a6e1e45e41355d2cb91a3ded84571a357
4
+ data.tar.gz: cf2652751ae7b86361688e18ddd6dc6487e88dfb7d7758a119720cb5b7544ecd
5
5
  SHA512:
6
- metadata.gz: e631494bb2d5129c904b3f6ab50d0083f7f041c4d5949c0cf5e868b2c56a9edef808b97a8e89a67c8809387798da5eb3db6be9ad02419018a95a96529706f225
7
- data.tar.gz: 231279595fa4ca0af2304932507a27e382e42ed483df1833ed547d9df2f2184e679fd1f4900b0895daf19bd5d25b34148ef255b6c38351935015ebf670d08e04
6
+ metadata.gz: 037f381822efe210e32e3a4a398f946cba3923f2593826a91486ea0710544cf0c72bc0d38b88ff223705bcb984763bbb51052d0a43090223f47bf0607f82348d
7
+ data.tar.gz: b0980abf21fd435ad2350f256b04b4cc9ef3db892d642f753e5ba3be4d029f4359a1e37efff6b2197d74b0652c1b4ae49857f3d253a332f9b4ffad945b730afb
@@ -1,3 +1,7 @@
1
+ ## 5.2.0
2
+
3
+ * Add support for an optional `is_csv` parameter in the `prepare_upload()` function. This fixes a bug when sending a CSV file by email. This ensures that the file is downloaded as a CSV rather than a TXT file.
4
+
1
5
  ## 5.1.2
2
6
 
3
7
  * Change filesize too big exception message to refer to files rather than documents.
@@ -28,7 +28,7 @@ export SMS_TEMPLATE_ID="valid sms_template_id"
28
28
  export LETTER_TEMPLATE_ID="valid letter_template_id"
29
29
  export EMAIL_REPLY_TO_ID="valid email reply to id"
30
30
  export SMS_SENDER_ID="valid sms_sender_id - to test sending to a receiving number, so needs to be a valid number"
31
- export API_SENDING_KEY="API_whitelist_key for sending a SMS to a receiving number"
31
+ export API_SENDING_KEY="API_team_key for sending a SMS to a receiving number"
32
32
  export INBOUND_SMS_QUERY_KEY="API_test_key to get received text messages"
33
33
  ```
34
34
 
@@ -127,20 +127,20 @@ You can then call different methods on this object:
127
127
 
128
128
  If you are using the [test API key](#test), all your messages come back with a `delivered` status.
129
129
 
130
- All messages sent using the [team and whitelist](#team-and-whitelist) or [live](#live) keys appear on your GOV.UK Notify dashboard.
130
+ All messages sent using the [team and guest list](#team-and-guest-list) or [live](#live) keys appear on your GOV.UK Notify dashboard.
131
131
 
132
132
  ### Error codes
133
133
 
134
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
134
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
135
135
 
136
136
  |error.code|error.message|class|How to fix|
137
137
  |:---|:---|:---|:---|
138
138
  |`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
139
139
  |`400`|`BadRequestError: Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
140
140
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
141
- |`403`|`AuthError: Invalid token: signature, api token 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](#api-rate-limits) for more information|
143
- |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`ClientError`|Refer to [service limits](#service-limits) for the limit number|
141
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
142
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#rate-limits) for more information|
143
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`ClientError`|Refer to [service limits](#daily-limits) for the limit number|
144
144
  |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
145
145
 
146
146
  ## Send an email
@@ -223,26 +223,29 @@ You can leave out this argument if your service only has one email reply-to addr
223
223
 
224
224
  ## Send a file by email
225
225
 
226
- Send files without the need for email attachments.
226
+ To send a file by email, add a placeholder to the template then upload a file. The placeholder will contain a secure link to download the file.
227
227
 
228
- This is an invitation-only feature. [Contact the GOV.UK Notify team](https://www.notifications.service.gov.uk/support/ask-question-give-feedback) to enable this function for your service.
228
+ The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
229
229
 
230
- To send a file by email, add a placeholder field to the template then upload a file. The placeholder field will contain a secure link to download the file.
230
+ ### Add contact details to the file download page
231
231
 
232
- The links are unique and unguessable. GOV.UK Notify cannot access or decrypt your file.
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__.
233
236
 
234
- ### Add a placeholder field to the template
237
+ ### Add a placeholder to the template
235
238
 
236
239
  1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
237
240
  1. Go to the __Templates__ page and select the relevant email template.
238
241
  1. Select __Edit__.
239
- 1. Add a placeholder field to the email template using double brackets. For example:
242
+ 1. Add a placeholder to the email template using double brackets. For example:
240
243
 
241
244
  "Download your file at: ((link_to_file))"
242
245
 
243
246
  ### Upload your file
244
247
 
245
- The file you upload must be a PDF, CSV, text file or Microsoft Word document 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.
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.
246
249
 
247
250
  1. Pass the file object as an argument to the `Notifications.prepare_upload` helper method.
248
251
  1. Pass the result into the personalisation argument.
@@ -260,6 +263,21 @@ File.open("file.pdf", "rb") do |f|
260
263
  end
261
264
  ```
262
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),
277
+ }
278
+ end
279
+ ```
280
+
263
281
  ### Response
264
282
 
265
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`.
@@ -276,19 +294,19 @@ You can then call different methods on this object to return the requested infor
276
294
 
277
295
  ### Error codes
278
296
 
279
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
297
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
280
298
 
281
299
  |error.code|error.message|class|How to fix|
282
300
  |:--- |:---|:---|:---|
283
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)|
284
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)|
285
- |`400`|`BadRequestError: Unsupported file type '(FILE TYPE)'. Supported types are: '(ALLOWED TYPES)'`|`BadRequestError`|Wrong file type. You can only upload .pdf, .csv, .txt, .doc or .docx files|
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|
286
304
  |`400`|`BadRequestError: File did not pass the virus scan`|`BadRequestError`|The file contains a virus|
287
- |`400`|`BadRequestError: Service is not allowed to send documents`|`BadRequestError`|Contact the GOV.UK Notify team|
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)|
288
306
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
289
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
290
- |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#api-rate-limits) for more information|
291
- |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](#service-limits) for the limit number|
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|
292
310
  |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
293
311
  |-|`ArgumentError: File is larger than 2MB")`|-|The file is too big. Files must be smaller than 2MB|
294
312
 
@@ -337,7 +355,7 @@ The personalisation argument always contains the following parameters for the le
337
355
 
338
356
  - `address_line_1`
339
357
  - `address_line_2`
340
- - `postcode`
358
+ - `postcode` (this needs to be a real UK postcode)
341
359
 
342
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:
343
361
 
@@ -390,17 +408,18 @@ You can then call different methods on this object to return the requested infor
390
408
 
391
409
  ### Error codes
392
410
 
393
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
411
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
394
412
 
395
413
  |error.code|error.message|class|How to fix|
396
414
  |:--- |:---|:---|:---|
397
415
  |`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
398
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)|
399
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|
400
419
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
401
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
402
- |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](#api-rate-limits) for more information|
403
- |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](#service-limits) for the limit number|
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|
404
423
  |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
405
424
 
406
425
  ## Send a precompiled letter
@@ -445,7 +464,7 @@ You can then call different methods on this object to return the requested infor
445
464
 
446
465
  ### Error codes
447
466
 
448
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
467
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
449
468
 
450
469
  |error.status_code|error.message|class|How to fix|
451
470
  |:---|:---|:---|:---|
@@ -455,7 +474,7 @@ If the request is not successful, the client returns a `Notifications::Client::R
455
474
  |`400`|`ValidationError: reference is a required property`|`BadRequestError`|Add a `reference` argument to the method call|
456
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'|
457
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|
458
- |`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#service-limits) for the limit number|
477
+ |`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#daily-limits) for the limit number|
459
478
 
460
479
  # Get message status
461
480
 
@@ -463,21 +482,25 @@ Message status depends on the type of message you have sent.
463
482
 
464
483
  You can only get the status of messages that are 7 days old or newer.
465
484
 
466
- ## Status - text and email
485
+ ## Status - email
467
486
 
468
487
  |Status|Information|
469
488
  |:---|:---|
470
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.|
471
- |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.|
472
491
  |Delivered|The message was successfully delivered.|
473
- |Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message because the email address or phone number was wrong. You should remove these email addresses or phone numbers from your database. You’ll still be charged for text messages to numbers that do not exist."<br>- `temporary-failure` - "The provider could not deliver the message after trying for 72 hours. This can happen when the recipient's inbox is full or their phone is off. You can try to send the message again. You’ll still be charged for text messages to phones that are not accepting messages."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again. You will not be charged for text messages that are affected by a technical failure."|
492
+ |Failed|This covers all failure statuses:<br>- `permanent-failure` - "The provider could not deliver the message because the email address was wrong. You should remove these email addresses from your database."<br>- `temporary-failure` - "The provider could not deliver the message. This can happen when the recipients inbox is full. You can try to send the message again."<br>- `technical-failure` - "Your message was not sent because there was a problem between Notify and the provider.<br>You’ll have to try sending your messages again."|
474
493
 
475
- ## Status - text only
494
+ ## Status - text message
476
495
 
477
496
  |Status|Information|
478
497
  |:---|:---|
479
- |Pending|GOV.UK Notify is waiting for more delivery information.<br>GOV.UK Notify received a callback from the provider but the recipient's device has not yet responded. Another callback from the provider determines the final status of the notification.|
498
+ |Created|GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.|
499
+ |Sending|GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient for up to 72 hours. GOV.UK Notify is waiting for delivery information.|
500
+ |Pending|GOV.UK Notify is waiting for more delivery information.<br>GOV.UK Notify received a callback from the provider but the recipient’s device has not yet responded. Another callback from the provider determines the final status of the notification.|
480
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."|
481
504
 
482
505
  ## Status - letter
483
506
 
@@ -545,13 +568,13 @@ You can then call different methods on this object to return the requested infor
545
568
 
546
569
  ### Error codes
547
570
 
548
- If the request is not successful, the client returns a `Notification::Client::RequestError` and an error code:
571
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
549
572
 
550
573
  |error.code|error.message|class|How to fix|
551
574
  |:---|:---|:---|:---|
552
575
  |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
553
576
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
554
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
577
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
555
578
  |`404`|`NoResultFound: No result found`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
556
579
 
557
580
  ## Get the status of multiple messages
@@ -582,22 +605,14 @@ You can leave out these arguments to ignore these filters.
582
605
 
583
606
  #### status (optional)
584
607
 
585
- | status | description | text | email | letter |Precompiled letter|
586
- |:--- |:--- |:--- |:--- |:--- |:--- |
587
- |created|GOV.UK Notify has placed the message in a queue, ready to be sent to the provider. It should only remain in this state for a few seconds.|Yes|Yes|||
588
- |sending|GOV.UK Notify has sent the message to the provider. The provider will try to deliver the message to the recipient. GOV.UK Notify is waiting for delivery information.|Yes|Yes|||
589
- |delivered|The message was successfully delivered|Yes|Yes|||
590
- |sent / sent internationally|The message was sent to an international number. The mobile networks in some countries do not provide any more delivery information.|Yes||||
591
- |pending|GOV.UK Notify is waiting for more delivery information.<br>GOV.UK Notify received a callback from the provider but the recipient's device has not yet responded. Another callback from the provider determines the final status of the notification.|Yes||||
592
- |failed|This returns all failure statuses:<br>- permanent-failure<br>- temporary-failure<br>- technical-failure|Yes|Yes|||
593
- |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|||
594
- |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|||
595
- |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|||
596
- |accepted|GOV.UK Notify has sent the letter to the provider to be printed.|||Yes||
597
- |received|The provider has printed and dispatched the letter.|||Yes||
598
- |pending-virus-check|GOV.UK Notify is scanning the precompiled letter file for viruses.||||Yes|
599
- |virus-scan-failed|GOV.UK Notify found a potential virus in the precompiled letter file.||||Yes|
600
- |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.
601
616
 
602
617
  #### templateType (optional)
603
618
 
@@ -667,14 +682,14 @@ If the notification specified in the `older_than` argument is older than 7 days,
667
682
 
668
683
  ### Error codes
669
684
 
670
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
685
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
671
686
 
672
687
  |error.code|error.message|class|How to fix|
673
688
  |:---|:---|:---|:---|
674
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|
675
690
  |`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the GOV.UK Notify team|
676
691
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
677
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
692
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
678
693
 
679
694
  ## Get a PDF for a letter notification
680
695
 
@@ -702,7 +717,7 @@ If the request to the client is successful, the client will return a `string` co
702
717
 
703
718
  ### Error codes
704
719
 
705
- If the request is not successful, the client throws a `Notifications::Client::RequestError` and an error code.
720
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
706
721
 
707
722
  |error.code|error.message|class|How to fix|
708
723
  |:---|:---|:---|:---|
@@ -712,7 +727,7 @@ If the request is not successful, the client throws a `Notifications::Client::Re
712
727
  |`400`|`BadRequestError: PDF not available for letters in technical-failure`|`BadRequestError`|You cannot retrieve the contents of a letter notification in technical-failure|
713
728
  |`400`|`ValidationError: Notification is not a letter`|`BadRequestError`|Check that you are looking up the correct notification|
714
729
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`BadRequestError`|Check your system clock|
715
- |`403`|`AuthError: Invalid token: signature, api token not found`|`BadRequestError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
730
+ |`403`|`AuthError: Invalid token: API key not found`|`BadRequestError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
716
731
  |`404`|`NoResultFound: No result found`|`BadRequestError`|Check the notification ID|
717
732
 
718
733
 
@@ -758,13 +773,13 @@ You can then call different methods on this object to return the requested infor
758
773
 
759
774
  ### Error codes
760
775
 
761
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
776
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
762
777
 
763
778
  |error.code|error.message|class|How to fix|
764
779
  |:---|:---|:---|:---|
765
780
  |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
766
781
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
767
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
782
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
768
783
  |`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-arguments-id-required)|
769
784
 
770
785
  ## Get a template by ID and version
@@ -809,13 +824,13 @@ You can then call different methods on this object to return the requested infor
809
824
 
810
825
  ### Error codes
811
826
 
812
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
827
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
813
828
 
814
829
  |error.code|error.message|class|How to fix|
815
830
  |:---|:---|:---|:---|
816
831
  |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
817
832
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
818
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
833
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
819
834
  |`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](#get-a-template-by-id-and-version-arguments-id-required) and [version](#version-required)|
820
835
 
821
836
  ## Get all templates
@@ -865,7 +880,7 @@ If no templates exist for a template type or there no templates for a service, t
865
880
 
866
881
  ### Error codes
867
882
 
868
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
883
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
869
884
 
870
885
  |error.code|error.message|class|How to fix|
871
886
  |:---|:---|:---|:---|
@@ -923,14 +938,14 @@ You can then call different methods on this object to return the requested infor
923
938
 
924
939
  ### Error codes
925
940
 
926
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code:
941
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
927
942
 
928
943
  |error.code|error.message|class|How to fix|
929
944
  |:---|:---|:---|:---|
930
945
  |`400`|`BadRequestError: Missing personalisation: [PERSONALISATION FIELD]`|`BadRequestError`|Check that the personalisation arguments in the method match the placeholder fields in the template|
931
946
  |`400`|`NoResultFound: No result found`|`BadRequestError`|Check the [template ID](#generate-a-preview-template-arguments-id-required)|
932
947
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
933
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
948
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
934
949
 
935
950
  # Get received text messages
936
951
 
@@ -999,9 +1014,9 @@ If the notification specified in the `older_than` argument is older than 7 days,
999
1014
 
1000
1015
  ### Error codes
1001
1016
 
1002
- If the request is not successful, the client returns a `Notifications::Client::RequestError` and an error code.
1017
+ If the request is not successful, the client raises a `Notifications::Client::RequestError` exception (or a subclass), which contains a code:
1003
1018
 
1004
1019
  |error.code|error.message|class|How to fix|
1005
1020
  |:---|:---|:---|:---|
1006
1021
  |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
1007
- |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
1022
+ |`403`|`AuthError: Invalid token: API key not found`|`AuthError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.4-slim
1
+ FROM ruby:2.6-slim
2
2
 
3
3
  RUN \
4
4
  echo "Install Debian packages" \
data/Makefile CHANGED
@@ -32,18 +32,14 @@ generate-env-file: ## Generate the environment file for running the tests inside
32
32
 
33
33
  .PHONY: prepare-docker-runner-image
34
34
  prepare-docker-runner-image: ## Prepare the Docker builder image
35
- make -C docker build
35
+ docker pull `grep "FROM " Dockerfile | cut -d ' ' -f 2` || true
36
+ docker build -t ${DOCKER_BUILDER_IMAGE_NAME} .
36
37
 
37
38
  .PHONY: build-with-docker
38
39
  build-with-docker: prepare-docker-runner-image ## Build inside a Docker container
39
40
  docker run -i --rm \
40
41
  --name "${DOCKER_CONTAINER_PREFIX}-build" \
41
42
  -v "`pwd`:/var/project" \
42
- -e http_proxy="${HTTP_PROXY}" \
43
- -e HTTP_PROXY="${HTTP_PROXY}" \
44
- -e https_proxy="${HTTPS_PROXY}" \
45
- -e HTTPS_PROXY="${HTTPS_PROXY}" \
46
- -e NO_PROXY="${NO_PROXY}" \
47
43
  ${DOCKER_BUILDER_IMAGE_NAME} \
48
44
  make build
49
45
 
@@ -52,28 +48,18 @@ test-with-docker: prepare-docker-runner-image generate-env-file ## Run tests ins
52
48
  docker run -i --rm \
53
49
  --name "${DOCKER_CONTAINER_PREFIX}-test" \
54
50
  -v "`pwd`:/var/project" \
55
- -e http_proxy="${HTTP_PROXY}" \
56
- -e HTTP_PROXY="${HTTP_PROXY}" \
57
- -e https_proxy="${HTTPS_PROXY}" \
58
- -e HTTPS_PROXY="${HTTPS_PROXY}" \
59
- -e NO_PROXY="${NO_PROXY}" \
60
51
  --env-file docker.env \
61
52
  ${DOCKER_BUILDER_IMAGE_NAME} \
62
- make test
53
+ make build test
63
54
 
64
55
  .PHONY: integration-test-with-docker
65
56
  integration-test-with-docker: prepare-docker-runner-image generate-env-file ## Run integration tests inside a Docker container
66
57
  docker run -i --rm \
67
58
  --name "${DOCKER_CONTAINER_PREFIX}-integration-test" \
68
59
  -v "`pwd`:/var/project" \
69
- -e http_proxy="${HTTP_PROXY}" \
70
- -e HTTP_PROXY="${HTTP_PROXY}" \
71
- -e https_proxy="${HTTPS_PROXY}" \
72
- -e HTTPS_PROXY="${HTTPS_PROXY}" \
73
- -e NO_PROXY="${NO_PROXY}" \
74
60
  --env-file docker.env \
75
61
  ${DOCKER_BUILDER_IMAGE_NAME} \
76
- make integration-test
62
+ make build integration-test
77
63
 
78
64
  .PHONY: get-client-version
79
65
  get-client-version: ## Retrieve client version number from source code
@@ -89,9 +75,5 @@ publish-to-rubygems: ## Create gemspec file and publish to rubygems
89
75
  clean-docker-containers: ## Clean up any remaining docker containers
90
76
  docker rm -f $(shell docker ps -q -f "name=${DOCKER_CONTAINER_PREFIX}") 2> /dev/null || true
91
77
 
92
- .PHONY: run-govuk-lint
93
- run-govuk-lint: ## Runs GOVUK-lint for Ruby
94
- bundle exec govuk-lint-ruby lib spec bin/test_client
95
-
96
78
  clean:
97
79
  rm -rf vendor
@@ -1,9 +1,9 @@
1
1
  require "base64"
2
2
 
3
3
  module Notifications
4
- def self.prepare_upload(file)
4
+ def self.prepare_upload(file, is_csv=false)
5
5
  raise ArgumentError.new("File is larger than 2MB") if file.size > Client::MAX_FILE_UPLOAD_SIZE
6
6
 
7
- { file: Base64.strict_encode64(file.read) }
7
+ { file: Base64.strict_encode64(file.read), is_csv: is_csv }
8
8
  end
9
9
  end
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Notifications
11
11
  class Client
12
- VERSION = "5.1.2".freeze
12
+ VERSION = "5.2.0".freeze
13
13
  end
14
14
  end
@@ -22,10 +22,9 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency "jwt", ">= 1.5", "< 3"
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.13"
26
- spec.add_development_dependency "rake", "~> 12.3"
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 13.0"
27
27
  spec.add_development_dependency "rspec", "~> 3.7"
28
28
  spec.add_development_dependency "webmock", "~> 3.4"
29
- spec.add_development_dependency "factory_bot", "~> 4.10"
30
- spec.add_development_dependency "govuk-lint", "~> 3.8"
29
+ spec.add_development_dependency "factory_bot", "~> 5.2"
31
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifications-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.2
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-28 00:00:00.000000000 Z
11
+ date: 2020-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -36,28 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '1.13'
39
+ version: '1.7'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '1.13'
46
+ version: '1.7'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '12.3'
53
+ version: '13.0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '12.3'
60
+ version: '13.0'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rspec
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '4.10'
95
+ version: '5.2'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '4.10'
103
- - !ruby/object:Gem::Dependency
104
- name: govuk-lint
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.8'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '3.8'
102
+ version: '5.2'
117
103
  description:
118
104
  email:
119
105
  - notify@digital.cabinet-office.gov.uk
@@ -138,8 +124,6 @@ files:
138
124
  - bin/generate_docker_env.sh
139
125
  - bin/setup
140
126
  - bin/test_client.rb
141
- - docker/Dockerfile
142
- - docker/Makefile
143
127
  - lib/notifications/client.rb
144
128
  - lib/notifications/client/helper_methods.rb
145
129
  - lib/notifications/client/notification.rb
@@ -1,25 +0,0 @@
1
- FROM ruby:2.4-slim
2
-
3
- ARG HTTP_PROXY
4
- ARG HTTPS_PROXY
5
- ARG NO_PROXY
6
-
7
- RUN \
8
- echo "Install Debian packages" \
9
- && ([ -z "$HTTP_PROXY" ] || echo "Acquire::http::Proxy \"${HTTP_PROXY}\";" > /etc/apt/apt.conf.d/99HttpProxy) \
10
- && apt-get update \
11
- && apt-get install -y --no-install-recommends \
12
- gcc \
13
- make \
14
- curl \
15
- git \
16
- && echo "Clean up" \
17
- && rm -rf /var/lib/apt/lists/* /tmp/*
18
-
19
- ENV PATH=/var/project/vendor/bin:$PATH \
20
- BUNDLE_PATH="/var/project/vendor/bundle" \
21
- BUNDLE_BIN="/var/project/vendor/bin" \
22
- BUNDLE_APP_CONFIG="/var/project/.bundle"
23
-
24
-
25
- WORKDIR /var/project
@@ -1,16 +0,0 @@
1
- .DEFAULT_GOAL := help
2
- SHELL := /bin/bash
3
-
4
- .PHONY: help
5
- help:
6
- @cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7
-
8
- .PHONY: build
9
- build:
10
- docker pull `grep "FROM " Dockerfile | cut -d ' ' -f 2` || true
11
- docker build \
12
- --build-arg HTTP_PROXY="${HTTP_PROXY}" \
13
- --build-arg HTTPS_PROXY="${HTTP_PROXY}" \
14
- --build-arg NO_PROXY="${NO_PROXY}" \
15
- -t govuk/notify-ruby-client-builder \
16
- .