notifications-ruby-client 5.1.0 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -4
- data/CHANGELOG.md +4 -0
- data/CONTRIBUTING.md +5 -0
- data/DOCUMENTATION.md +53 -29
- data/Makefile +11 -1
- data/lib/notifications/client/request_error.rb +4 -1
- data/lib/notifications/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd1f49567263efcb02c79c9e90315b809db7a4e6add2c3928eea48ac9ae32c49
|
4
|
+
data.tar.gz: ef90da03ad2255fc6a656462a5312c979a11e5d912178bb4d1342f93b1979567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3657fba6b6ad47e5b7714289810c3db3d2e22842d8df5bec0faf78e0fc0fc96827b326b17fa8f41e68e471b360a6339e5aa38086b4fd18ab2b23d307b0f5d46
|
7
|
+
data.tar.gz: c5af4c7372bc945697d773da8f573c6deccde0bf0efb2fda7c2f500551c5db68c0e762a5a59d4c89e4a44df27ec23016b5d2b30c05f5365d7f285f581cd01920
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -37,3 +37,8 @@ To run the integration tests:
|
|
37
37
|
```
|
38
38
|
make integration-test
|
39
39
|
```
|
40
|
+
|
41
|
+
|
42
|
+
## Releasing (for notify developers only)
|
43
|
+
|
44
|
+
To release manually, run `make publish-to-rubygems`. You will need to set the environment variable `GEM_HOST_API_KEY`, which can be found in the credentials repo under `credentials/rubygems/api_key`.
|
data/DOCUMENTATION.md
CHANGED
@@ -23,7 +23,7 @@ require 'notifications/client'
|
|
23
23
|
client = Notifications::Client.new(api_key)
|
24
24
|
```
|
25
25
|
|
26
|
-
To get an API key, [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/) and go to the __API integration__ page. You can find more information in the [API keys](#api-keys) section of this documentation.
|
26
|
+
To get an API key, [sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in) and go to the __API integration__ page. You can find more information in the [API keys](#api-keys) section of this documentation.
|
27
27
|
|
28
28
|
# Send a message
|
29
29
|
|
@@ -52,7 +52,13 @@ phone_number:"+447900900123"
|
|
52
52
|
|
53
53
|
#### template_id (required)
|
54
54
|
|
55
|
-
|
55
|
+
To find the template ID:
|
56
|
+
|
57
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
58
|
+
1. Go to the __Templates__ page and select the relevant template.
|
59
|
+
1. Select __Copy template ID to clipboard__.
|
60
|
+
|
61
|
+
For example:
|
56
62
|
|
57
63
|
```ruby
|
58
64
|
template_id:"f33517ff-2a88-4f6e-b855-c550268ce08a"
|
@@ -83,12 +89,13 @@ You can leave out this argument if you do not have a reference.
|
|
83
89
|
|
84
90
|
#### sms_sender_id (optional)
|
85
91
|
|
86
|
-
A unique identifier of the sender of the text message notification.
|
92
|
+
A unique identifier of the sender of the text message notification.
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
1.
|
91
|
-
1. Go to the
|
94
|
+
To find the text message sender:
|
95
|
+
|
96
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
97
|
+
1. Go to the __Settings__ page.
|
98
|
+
1. In the __Text Messages__ section, select __Manage__ on the __Text Message sender__ row.
|
92
99
|
|
93
100
|
You can then either:
|
94
101
|
|
@@ -159,7 +166,13 @@ email_address: "sender@something.com"
|
|
159
166
|
|
160
167
|
#### template_id (required)
|
161
168
|
|
162
|
-
|
169
|
+
To find the template ID:
|
170
|
+
|
171
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
172
|
+
1. Go to the __Templates__ page and select the relevant template.
|
173
|
+
1. Select __Copy template ID to clipboard__.
|
174
|
+
|
175
|
+
For example:
|
163
176
|
|
164
177
|
```ruby
|
165
178
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
@@ -190,14 +203,15 @@ You can leave out this argument if you do not have a reference.
|
|
190
203
|
|
191
204
|
#### email_reply_to_id (optional)
|
192
205
|
|
193
|
-
This is an email
|
206
|
+
This is an email address specified by you to receive replies from your users. You must add at least one reply-to email address before your service can go live.
|
194
207
|
|
195
|
-
|
196
|
-
1. Go to __Settings__.
|
197
|
-
1. If you need to change to another service, select __Switch service__ in the top right corner of the screen and select the correct one.
|
198
|
-
1. Go to the __Email__ section and select __Manage__ on the __Email reply-to addresses__ row.
|
199
|
-
1. Select __Change__ to specify the email address to receive replies, and select __Save__.
|
208
|
+
To add a reply-to email address:
|
200
209
|
|
210
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
211
|
+
1. Go to the __Settings__ page.
|
212
|
+
1. In the __Email__ section, select __Manage__ on the __Reply-to email addresses__ row.
|
213
|
+
1. Select __Add reply-to address__.
|
214
|
+
1. Enter the email address you want to use, and select __Add__.
|
201
215
|
|
202
216
|
For example:
|
203
217
|
|
@@ -219,15 +233,16 @@ The links are unique and unguessable. GOV.UK Notify cannot access or decrypt you
|
|
219
233
|
|
220
234
|
### Add a placeholder field to the template
|
221
235
|
|
222
|
-
1. Sign in to
|
236
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
223
237
|
1. Go to the __Templates__ page and select the relevant email template.
|
238
|
+
1. Select __Edit__.
|
224
239
|
1. Add a placeholder field to the email template using double brackets. For example:
|
225
240
|
|
226
241
|
"Download your file at: ((link_to_document))"
|
227
242
|
|
228
243
|
### Upload your file
|
229
244
|
|
230
|
-
The file you upload must be a PDF file smaller than 2MB.
|
245
|
+
The file you upload must be a PDF or CSV file smaller than 2MB. [Contact the GOV.UK Notify team](https://www.notifications.service.gov.uk/support/ask-question-give-feedback) if you need to send other file types.
|
231
246
|
|
232
247
|
1. Pass the file object as an argument to the `Notifications.prepare_upload` helper method.
|
233
248
|
1. Pass the result into the personalisation argument.
|
@@ -279,11 +294,13 @@ If the request is not successful, the client returns a `Notifications::Client::R
|
|
279
294
|
|
280
295
|
## Send a letter
|
281
296
|
|
282
|
-
When
|
297
|
+
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.
|
298
|
+
|
299
|
+
To send Notify a request to go live:
|
283
300
|
|
284
|
-
1. Sign in to
|
285
|
-
1.
|
286
|
-
1.
|
301
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
302
|
+
1. Go to the __Settings__ page.
|
303
|
+
1. In the __Your service is in trial mode__ section, select __request to go live__.
|
287
304
|
|
288
305
|
### Method
|
289
306
|
|
@@ -302,7 +319,13 @@ letterresponse = client.send_letter(
|
|
302
319
|
|
303
320
|
#### template_id (required)
|
304
321
|
|
305
|
-
|
322
|
+
To find the template ID:
|
323
|
+
|
324
|
+
1. [Sign in to GOV.UK Notify](https://www.notifications.service.gov.uk/sign-in).
|
325
|
+
1. Go to the __Templates__ page and select the relevant template.
|
326
|
+
1. Select __Copy template ID to clipboard__.
|
327
|
+
|
328
|
+
For example:
|
306
329
|
|
307
330
|
```ruby
|
308
331
|
template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
@@ -310,7 +333,7 @@ template_id: "f33517ff-2a88-4f6e-b855-c550268ce08a"
|
|
310
333
|
|
311
334
|
#### personalisation (required)
|
312
335
|
|
313
|
-
The personalisation argument always contains the following parameters for the letter recipient
|
336
|
+
The personalisation argument always contains the following parameters for the letter recipient’s address:
|
314
337
|
|
315
338
|
- `address_line_1`
|
316
339
|
- `address_line_2`
|
@@ -331,7 +354,7 @@ personalisation: {
|
|
331
354
|
|
332
355
|
#### personalisation (optional)
|
333
356
|
|
334
|
-
The following parameters in the letter recipient
|
357
|
+
The following parameters in the letter recipient’s address are optional:
|
335
358
|
|
336
359
|
```ruby
|
337
360
|
personalisation: {
|
@@ -488,7 +511,7 @@ response = client.get_notification(id)
|
|
488
511
|
|
489
512
|
The ID of the notification. You can find the notification ID in the response to the [original notification method call](#response).
|
490
513
|
|
491
|
-
You can also find it by signing in to
|
514
|
+
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.
|
492
515
|
|
493
516
|
### Response
|
494
517
|
|
@@ -671,7 +694,7 @@ pdf_file = client.get_pdf_for_letter(
|
|
671
694
|
|
672
695
|
The ID of the notification. You can find the notification ID in the response to the [original notification method call](#get-the-status-of-one-message-response).
|
673
696
|
|
674
|
-
You can also find it by signing in to
|
697
|
+
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.
|
675
698
|
|
676
699
|
### Response
|
677
700
|
|
@@ -680,6 +703,7 @@ If the request to the client is successful, the client will return a `string` co
|
|
680
703
|
### Error codes
|
681
704
|
|
682
705
|
If the request is not successful, the client throws a `Notifications::Client::RequestError` and an error code.
|
706
|
+
|
683
707
|
|error.code|error.message|class|How to fix|
|
684
708
|
|:---|:---|:---|:---|
|
685
709
|
|`400`|`ValidationError: id is not a valid UUID`|`BadRequestError`|Check the notification ID|
|
@@ -708,7 +732,7 @@ response = client.get_template_by_id(id)
|
|
708
732
|
|
709
733
|
#### id (required)
|
710
734
|
|
711
|
-
The ID of the template. Sign
|
735
|
+
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:
|
712
736
|
|
713
737
|
```
|
714
738
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
@@ -755,7 +779,7 @@ response = client.get_template_version(id, version)
|
|
755
779
|
|
756
780
|
#### id (required)
|
757
781
|
|
758
|
-
The ID of the template. Sign in to GOV.UK Notify and go to the __Templates__ page to find
|
782
|
+
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:
|
759
783
|
|
760
784
|
```ruby
|
761
785
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
@@ -863,7 +887,7 @@ The parameters in the personalisation argument must match the placeholder fields
|
|
863
887
|
|
864
888
|
#### id (required)
|
865
889
|
|
866
|
-
The ID of the template. Sign
|
890
|
+
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:
|
867
891
|
|
868
892
|
```ruby
|
869
893
|
'f33517ff-2a88-4f6e-b855-c550268ce08a'
|
@@ -918,7 +942,7 @@ You can also set up [callbacks](#callbacks) for received text messages.
|
|
918
942
|
|
919
943
|
## Enable received text messages
|
920
944
|
|
921
|
-
Contact the GOV.UK Notify team
|
945
|
+
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.
|
922
946
|
|
923
947
|
## Get a page of received text messages
|
924
948
|
|
data/Makefile
CHANGED
@@ -75,13 +75,23 @@ integration-test-with-docker: prepare-docker-runner-image generate-env-file ## R
|
|
75
75
|
${DOCKER_BUILDER_IMAGE_NAME} \
|
76
76
|
make integration-test
|
77
77
|
|
78
|
+
.PHONY: get-client-version
|
79
|
+
get-client-version: ## Retrieve client version number from source code
|
80
|
+
@ruby -e "require './lib/notifications/client/version'; puts Notifications::Client::VERSION"
|
81
|
+
|
82
|
+
.PHONY: publish-to-rubygems
|
83
|
+
publish-to-rubygems: ## Create gemspec file and publish to rubygems
|
84
|
+
$(if ${GEM_HOST_API_KEY},,$(error Must specify GEM_HOST_API_KEY))
|
85
|
+
gem build notifications-ruby-client.gemspec --output=release.gem
|
86
|
+
gem push release.gem
|
87
|
+
|
78
88
|
.PHONY: clean-docker-containers
|
79
89
|
clean-docker-containers: ## Clean up any remaining docker containers
|
80
90
|
docker rm -f $(shell docker ps -q -f "name=${DOCKER_CONTAINER_PREFIX}") 2> /dev/null || true
|
81
91
|
|
82
92
|
.PHONY: run-govuk-lint
|
83
93
|
run-govuk-lint: ## Runs GOVUK-lint for Ruby
|
84
|
-
bundle exec govuk-lint-ruby lib spec bin/test_client
|
94
|
+
bundle exec govuk-lint-ruby lib spec bin/test_client
|
85
95
|
|
86
96
|
clean:
|
87
97
|
rm -rf vendor
|
@@ -6,15 +6,18 @@ module Notifications
|
|
6
6
|
def initialize(response)
|
7
7
|
@code = response.code
|
8
8
|
@body = parse_body(response.body)
|
9
|
+
super(build_message)
|
9
10
|
end
|
10
11
|
|
12
|
+
private
|
13
|
+
|
11
14
|
def parse_body(body)
|
12
15
|
JSON.parse(body)
|
13
16
|
rescue JSON::ParserError
|
14
17
|
body
|
15
18
|
end
|
16
19
|
|
17
|
-
def
|
20
|
+
def build_message
|
18
21
|
return body if body.is_a?(String)
|
19
22
|
|
20
23
|
error_messages = body.fetch('errors')
|
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.
|
4
|
+
version: 5.1.1
|
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:
|
11
|
+
date: 2020-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|