notifications-ruby-client 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba933202a1dfa0c6f3ceb4c368a9464fadf69e515123ef2799b543bbd05f0ab4
4
- data.tar.gz: 2e92cb7452ba11d8c35630291c204ec3b2c6c960ca1d237a435a1c33105bf0d5
3
+ metadata.gz: 3bb224294830c1d0d4c4d776597d7ce144ca14fb993500f432275188914ab4cb
4
+ data.tar.gz: 94b010994127fbb3bcea06a408ec33587b3dbef34b8eaf404f6ece05d26eaf5b
5
5
  SHA512:
6
- metadata.gz: d8003252e3acca422ccf95b1e280ad87cb2c6fd32f8c6bb8c599823fa6aceaae4f7e1913c0033dd34700caaa1ae89b346959b8d56343c447f5acdb922cada589
7
- data.tar.gz: a20da50f07aac17fc2d632246033f09f57a891593b7eb54124728906246e78fc348d22e394a5d928f81e720ac9cdc9497843098041046edf38cf2937efa39a5a
6
+ metadata.gz: 3c9f30f36f38523e8c36a784b9780f434f3cc798b9e6824dcbfa06dd2fcb96802dff67c9dd2affe7c294243929ab734da477aea8c89dc39aa9646aba8e815966
7
+ data.tar.gz: cd81acb5965952e29c3e5c26c6c5c6144b8a8eca2b60ee6e2a40e81789f839c2d7876dd7f2b492c157585e16f19f184b8bef0eb6aa23eb502bee89d53a2a6885
@@ -1,3 +1,7 @@
1
+ ## 4.0.0
2
+
3
+ * `RequestError.message` now returns a string, not an array of hashes – see https://github.com/alphagov/notifications-ruby-client/pull/72
4
+
1
5
  ## 3.1.0
2
6
 
3
7
  * Added `html` field to the TemplatePreview response, so users can see
@@ -2,6 +2,8 @@
2
2
 
3
3
  This documentation is for developers interested in using the GOV.UK Notify Ruby client to send emails, text messages or letters.
4
4
 
5
+ We recommend that you use this client library rather than use the [GOV.UK Notify API](https://github.com/alphagov/notifications-api) directly, as there is no documentation for using the API in this way.
6
+
5
7
  # Set up the client
6
8
 
7
9
  ## Install the client
@@ -128,13 +130,13 @@ If the request is not successful, the client returns a `Notifications::Client::R
128
130
 
129
131
  |error.code|error.message|class|How to fix|
130
132
  |:---|:---|:---|:---|
131
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
132
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
133
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
134
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
135
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"`<br>`}]`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
136
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|`ClientError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
137
- |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|`ServerError`|Notify was unable to process the request, resend your notification|
133
+ |`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
134
+ |`400`|`BadRequestError: Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
135
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
136
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
137
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
138
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`ClientError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
139
+ |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
138
140
 
139
141
  ## Send an email
140
142
 
@@ -263,17 +265,17 @@ If the request is not successful, the client returns a `Notifications::Client::R
263
265
 
264
266
  |error.code|error.message|class|How to fix|
265
267
  |:--- |:---|:---|:---|
266
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient using a team-only API key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
267
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
268
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Unsupported document type '{}'. Supported types are: {}"`<br>`}]`|`BadRequestError`|The document you upload must be a PDF file|
269
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Document didn't pass the virus scan"`<br>`}]`|`BadRequestError`|The document you upload must be virus free|
270
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Service is not allowed to send documents"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
271
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
272
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
273
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"`<br>`}]`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
274
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|`RateLimitError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
275
- |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|`ServerError`|Notify was unable to process the request, resend your notification|
276
- |-|`[{`<br>`"error": "ArgumentError",`<br>`"message": "Document is larger than 2MB")`<br>`}]`|-|Document size was too large, upload a smaller document|
268
+ |`400`|`BadRequestError: Can't send to this recipient using a team-only API key`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
269
+ |`400`|`BadRequestError: Can't send to this recipient when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
270
+ |`400`|`BadRequestError: Unsupported document type '{}'. Supported types are: {}`|`BadRequestError`|The document you upload must be a PDF file|
271
+ |`400`|`BadRequestError: Document didn't pass the virus scan`|`BadRequestError`|The document you upload must be virus free|
272
+ |`400`|`BadRequestError: Service is not allowed to send documents`|`BadRequestError`|Contact the GOV.UK Notify team|
273
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
274
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
275
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
276
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
277
+ |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
278
+ |-|`ArgumentError: Document is larger than 2MB")`|-|Document size was too large, upload a smaller document|
277
279
 
278
280
  ## Send a letter
279
281
 
@@ -369,17 +371,16 @@ If the request is not successful, the client returns a `Notifications::Client::R
369
371
 
370
372
  |error.code|error.message|class|How to fix|
371
373
  |:--- |:---|:---|:---|
372
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
373
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
374
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "personalisation address_line_1 is a required property"`<br>`}]`|`BadRequestError`|Ensure that your template has a field for the first line of the address, refer to [personalisation](/ruby.html#personalisation-required) for more information|
375
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
376
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
377
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds"`<br>`}]`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
378
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (LIMIT NUMBER) for today"`<br>`}]`|`RateLimitError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
379
- |`500`|`[{`<br>`"error": "Exception",`<br>`"message": "Internal server error"`<br>`}]`|`ServerError`|Notify was unable to process the request, resend your notification|
374
+ |`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](/ruby.html#api-keys)|
375
+ |`400`|`BadRequestError: Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
376
+ |`400`|`ValidationError: personalisation address_line_1 is a required property`|`BadRequestError`|Ensure that your template has a field for the first line of the address, refer to [personalisation](/ruby.html#personalisation-required) for more information|
377
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
378
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
379
+ |`429`|`RateLimitError: Exceeded rate limit for key type TEAM/TEST/LIVE of 3000 requests per 60 seconds`|`RateLimitError`|Refer to [API rate limits](/ruby.html#api-rate-limits) for more information|
380
+ |`429`|`TooManyRequestsError: Exceeded send limits (LIMIT NUMBER) for today`|`RateLimitError`|Refer to [service limits](/ruby.html#service-limits) for the limit number|
381
+ |`500`|`Exception: Internal server error`|`ServerError`|Notify was unable to process the request, resend your notification|
380
382
 
381
383
  ## Send a precompiled letter
382
- This is an invitation-only feature. Contact the GOV.UK Notify team on the [support page](https://www.notifications.service.gov.uk/support) or through the [Slack channel](https://ukgovernmentdigital.slack.com/messages/govuk-notify) for more information.
383
384
 
384
385
  ### Method
385
386
  ```ruby
@@ -393,7 +394,7 @@ A unique identifier you create. This reference identifies a single unique notifi
393
394
 
394
395
  #### pdf_file (required)
395
396
 
396
- The precompiled letter must be a PDF file.
397
+ The precompiled letter must be a PDF file which meets [the GOV.UK Notify PDF letter specification](https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.3.pdf).
397
398
 
398
399
  ```ruby
399
400
  File.open("path/to/pdf_file", "rb") do |pdf_file|
@@ -425,15 +426,13 @@ If the request is not successful, the client returns a `Notifications::Client::R
425
426
 
426
427
  |error.status_code|error.message|class|How to fix|
427
428
  |:---|:---|:---|:---|
428
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters with a team api key"`<br>`]}`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
429
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send precompiled letters"`<br>`]}`|`BadRequestError`|This is an invitation-only feature. Contact the GOV.UK Notify team on the [support page](https://www.notifications.service.gov.uk/support) or through the [Slack channel](https://ukgovernmentdigital.slack.com/messages/govuk-notify) for more information|
430
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Letter content is not a valid PDF"`<br>`]}`|`BadRequestError`|PDF file format is required|
431
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Cannot send letters when service is in trial mode - see https://www.notifications.service.gov.uk/trial-mode"`<br>`}]`|`BadRequestError`|Your service cannot send this notification in [trial mode](https://www.notifications.service.gov.uk/features/using-notify#trial-mode)|
432
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "reference is a required property"`<br>`}]`|`BadRequestError`|Add a `reference` argument to the method call|
433
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "postage invalid. It must be either first or second."`<br>`}]`|`BadRequestError`|Change the value of `postage` argument in the method call to either 'first' or 'second'|
434
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Service is not allowed to send precompiled letters"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
435
- |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type live of 10 requests per 20 seconds"`<br>`}]`|`RateLimitError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
436
- |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (50) for today"`<br>`}]`|`RateLimitError`|Refer to [service limits](#service-limits) for the limit number|
429
+ |`400`|`BadRequestError: Cannot send letters with a team api key`|`BadRequestError`|Use the correct type of [API key](#api-keys)|
430
+ |`400`|`BadRequestError: Letter content is not a valid PDF`|`BadRequestError`|PDF file format is required|
431
+ |`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)|
432
+ |`400`|`ValidationError: reference is a required property`|`BadRequestError`|Add a `reference` argument to the method call|
433
+ |`400`|`ValidationError: postage invalid. It must be either first or second.`|`BadRequestError`|Change the value of `postage` argument in the method call to either 'first' or 'second'|
434
+ |`429`|`RateLimitError: Exceeded rate limit for key type live of 10 requests per 20 seconds`|`RateLimitError`|Use the correct API key. Refer to [API keys](#api-keys) for more information|
435
+ |`429`|`TooManyRequestsError: Exceeded send limits (50) for today`|`RateLimitError`|Refer to [service limits](#service-limits) for the limit number|
437
436
 
438
437
  # Get message status
439
438
 
@@ -471,7 +470,7 @@ You can only get the status of messages that are 7 days old or newer.
471
470
  |:---|:---|
472
471
  |Pending virus check|GOV.UK Notify has not completed a virus scan of the precompiled letter file.|
473
472
  |Virus scan failed|GOV.UK Notify found a potential virus in the precompiled letter file.|
474
- |Validation failed|Content in the precompiled letter file is outside the printable area.|
473
+ |Validation failed|Content in the precompiled letter file is outside the printable area. See the [GOV.UK Notify PDF letter specification](https://docs.notifications.service.gov.uk/documentation/images/notify-pdf-letter-spec-v2.3.pdf) for more information.|
475
474
 
476
475
  ## Get the status of one message
477
476
 
@@ -532,10 +531,10 @@ If the request is not successful, the client returns a `Notification::Client::Re
532
531
 
533
532
  |error.code|error.message|class|How to fix|
534
533
  |:---|:---|:---|:---|
535
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|`BadRequestError`|Check the notification ID|
536
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
537
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
538
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
534
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
535
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
536
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
537
+ |`404`|`NoResultFound: No result found`|`NotFoundError`|Check the notification ID. This error occurs if the notification is more than 7 days old.|
539
538
 
540
539
  ## Get the status of multiple messages
541
540
 
@@ -654,10 +653,10 @@ If the request is not successful, the client returns a `Notifications::Client::R
654
653
 
655
654
  |error.code|error.message|class|How to fix|
656
655
  |:---|:---|:---|:---|
657
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "bad status is not one of [created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, accepted, received]"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
658
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Template type is not one of [sms, email, letter]"`<br>`}]`|`BadRequestError`|Contact the GOV.UK Notify team|
659
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
660
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
656
+ |`400`|`ValidationError: bad status is not one of [created, sending, sent, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure, accepted, received]`|`BadRequestError`|Contact the GOV.UK Notify team|
657
+ |`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the GOV.UK Notify team|
658
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
659
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
661
660
 
662
661
  # Get a template
663
662
 
@@ -705,10 +704,10 @@ If the request is not successful, the client returns a `Notifications::Client::R
705
704
 
706
705
  |error.code|error.message|class|How to fix|
707
706
  |:---|:---|:---|:---|
708
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|`BadRequestError`|Check the notification ID|
709
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
710
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
711
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|`NotFoundError`|Check your [template ID](/ruby.html#get-a-template-by-id-arguments-id-required)|
707
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
708
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
709
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
710
+ |`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](/ruby.html#get-a-template-by-id-arguments-id-required)|
712
711
 
713
712
  ## Get a template by ID and version
714
713
 
@@ -756,10 +755,10 @@ If the request is not successful, the client returns a `Notifications::Client::R
756
755
 
757
756
  |error.code|error.message|class|How to fix|
758
757
  |:---|:---|:---|:---|
759
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "id is not a valid UUID"`<br>`}]`|`BadRequestError`|Check the notification ID|
760
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
761
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
762
- |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No Result Found"`<br>`}]`|`NotFoundError`|Check your [template ID](/ruby.html#get-a-template-by-id-and-version-arguments-id-required) and [version](/ruby.html#version-required)|
758
+ |`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
759
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
760
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
761
+ |`404`|`NoResultFound: No Result Found`|`NotFoundError`|Check your [template ID](/ruby.html#get-a-template-by-id-and-version-arguments-id-required) and [version](/ruby.html#version-required)|
763
762
 
764
763
  ## Get all templates
765
764
 
@@ -812,7 +811,7 @@ If the request is not successful, the client returns a `Notifications::Client::R
812
811
 
813
812
  |error.code|error.message|class|How to fix|
814
813
  |:---|:---|:---|:---|
815
- |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Template type is not one of [sms, email, letter]"`<br>`}]`|`BadRequestError`|Contact the Notify team|
814
+ |`400`|`ValidationError: Template type is not one of [sms, email, letter]`|`BadRequestError`|Contact the Notify team|
816
815
 
817
816
  ## Generate a preview template
818
817
 
@@ -870,10 +869,10 @@ If the request is not successful, the client returns a `Notifications::Client::R
870
869
 
871
870
  |error.code|error.message|class|How to fix|
872
871
  |:---|:---|:---|:---|
873
- |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Missing personalisation: [PERSONALISATION FIELD]"`<br>`}]`|`BadRequestError`|Check that the personalisation arguments in the method match the placeholder fields in the template|
874
- |`400`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|`BadRequestError`|Check the [template ID](/ruby.html#generate-a-preview-template-arguments-id-required)|
875
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
876
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
872
+ |`400`|`BadRequestError: Missing personalisation: [PERSONALISATION FIELD]`|`BadRequestError`|Check that the personalisation arguments in the method match the placeholder fields in the template|
873
+ |`400`|`NoResultFound: No result found`|`BadRequestError`|Check the [template ID](/ruby.html#generate-a-preview-template-arguments-id-required)|
874
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
875
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
877
876
 
878
877
  # Get received text messages
879
878
 
@@ -946,5 +945,5 @@ If the request is not successful, the client returns a `Notifications::Client::R
946
945
 
947
946
  |error.code|error.message|class|How to fix|
948
947
  |:---|:---|:---|:---|
949
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Error: Your system clock must be accurate to within 30 seconds"`<br>`}]`|`AuthError`|Check your system clock|
950
- |`403`|`[{`<br>`"error": "AuthError",`<br>`"message": "Invalid token: signature, api token not found"`<br>`}]`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
948
+ |`403`|`AuthError: Error: Your system clock must be accurate to within 30 seconds`|`AuthError`|Check your system clock|
949
+ |`403`|`AuthError: Invalid token: signature, api token not found`|`AuthError`|Use the correct API key. Refer to [API keys](/ruby.html#api-keys) for more information|
@@ -1,22 +1,26 @@
1
1
  module Notifications
2
2
  class Client
3
3
  class RequestError < StandardError
4
- attr_reader :code, :message
4
+ attr_reader :code, :body
5
5
 
6
6
  def initialize(response)
7
7
  @code = response.code
8
- @message = message_from(response.body)
8
+ @body = parse_body(response.body)
9
9
  end
10
10
 
11
- def to_s
12
- "#{code} #{message}"
13
- end
14
-
15
- def message_from(body)
16
- JSON.parse(body).fetch('errors')
11
+ def parse_body(body)
12
+ JSON.parse(body)
17
13
  rescue JSON::ParserError
18
14
  body
19
15
  end
16
+
17
+ def message
18
+ return body if body.is_a?(String)
19
+
20
+ error_messages = body.fetch('errors')
21
+ .map { |e| "#{e.fetch('error')}: #{e.fetch('message')}" }
22
+ error_messages.join(", ")
23
+ end
20
24
  end
21
25
 
22
26
  class ClientError < RequestError; end
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Notifications
11
11
  class Client
12
- VERSION = "3.1.0".freeze
12
+ VERSION = "4.0.0".freeze
13
13
  end
14
14
  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: 3.1.0
4
+ version: 4.0.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: 2019-02-27 00:00:00.000000000 Z
11
+ date: 2019-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt