notifications-ruby-client 2.4.0 → 2.5.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
  SHA1:
3
- metadata.gz: db2242bb9327b4033e27f251959d593c4983d654
4
- data.tar.gz: ddde90e6a3f27e5cecaf00da9feffc7ec99ade63
3
+ metadata.gz: 695b5825776a8ed48f2141c17f07a8b67d209528
4
+ data.tar.gz: e6658d6df53b0abca1c46d770825007838a94277
5
5
  SHA512:
6
- metadata.gz: 7628eebc40595c53bb559420b75cb3e0e0aa9a31bd1198d628e9006c1fb902edd871fe250e516bfbff1c7bdc642d1ff8a6967c22bb807bfafae9804144c62ed2
7
- data.tar.gz: 74661018d45151f1375f0af65ab3659be25672808474831fb7f31641eb2533a84578541e05d5db65323929e97b5492c1daa9c2dda1600afdec5123b48f93583f
6
+ metadata.gz: bf5e68a089416a29f6d4d19934f733cb626828f2cccf33f53213ebcdf75aed7399d29e432f2ccaf199b2164d800bb2a030f48f7d2701710d8c5e98484735fe6a
7
+ data.tar.gz: 38fbd8ff4512cab8f364377f638f0f8efb1373123243274b1895f6c33e4173ceb52c1016de867b4dc6d7684e323eb04d1f9f668d927a5ffb2f89e0dd85214e7f
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 2.5.0
2
+
3
+ ### Changed
4
+ * Added a new `get_received_texts` method.
5
+ * an optional `older_than` argument can be specified to retrieve the next 250 received text messages older than the given received text id. If omitted 250 of the most recent received text messages are returned.
6
+
7
+
1
8
  ## 2.4.0
2
9
 
3
10
  ### Changed
data/Makefile CHANGED
@@ -79,5 +79,9 @@ integration-test-with-docker: prepare-docker-runner-image generate-env-file ## R
79
79
  clean-docker-containers: ## Clean up any remaining docker containers
80
80
  docker rm -f $(shell docker ps -q -f "name=${DOCKER_CONTAINER_PREFIX}") 2> /dev/null || true
81
81
 
82
+ .PHONY: run-govuk-lint
83
+ run-govuk-lint: ## Runs GOVUK-lint for Ruby
84
+ bundle exec govuk-lint-ruby lib spec bin/test_client
85
+
82
86
  clean:
83
87
  rm -rf vendor
data/README.md CHANGED
@@ -1,9 +1,22 @@
1
1
  # GOV.UK Notify Ruby client
2
2
 
3
- API client for GOV.UK Notify written in Ruby.
3
+ This documentation is for developers interested in using this Ruby client to integrate their government service with GOV.UK Notify.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/notifications-ruby-client.svg)](https://badge.fury.io/rb/notifications-ruby-client)
6
6
 
7
+ ## Table of Contents
8
+
9
+ * [Installation](#installation)
10
+ * [Getting started](#getting-started)
11
+ * [Send messages](#send-messages)
12
+ * [Get the status of one message](#get-the-status-of-one-message)
13
+ * [Get the status of all messages](#get-the-status-of-all-messages)
14
+ * [Get a template by ID](#get-a-template-by-id)
15
+ * [Get a template by ID and version](#get-a-template-by-id-and-version)
16
+ * [Get all templates](#get-all-templates)
17
+ * [Generate a preview template](#generate-a-preview-template)
18
+ * [Get received texts](#get-received-texts)
19
+
7
20
  ## Installation
8
21
 
9
22
  Prior to usage an account must be created through the Notify admin console. This will allow access to the API credentials you application.
@@ -23,9 +36,16 @@ client = Notifications::Client.new(api_key)
23
36
 
24
37
  Generate an API key by logging in to GOV.UK Notify [GOV.UK Notify](https://www.notifications.service.gov.uk) and going to the **API integration** page.
25
38
 
26
- ### Send a message
39
+ ## Send messages
40
+
41
+ ### Text message
27
42
 
28
- Text message:
43
+ #### Method
44
+
45
+ <details>
46
+ <summary>
47
+ Click here to expand for more information.
48
+ </summary>
29
49
 
30
50
  ```ruby
31
51
  sms = client.send_sms(
@@ -33,20 +53,23 @@ sms = client.send_sms(
33
53
  template_id: template_id,
34
54
  personalisation: {
35
55
  name: "name",
36
- year: "2016",
56
+ year: "2016",
37
57
  },
38
58
  reference: "your_reference_string",
39
59
  sms_sender_id: sms_sender_id
40
60
  ) # => Notifications::Client::ResponseNotification
41
61
  ```
42
62
 
63
+ </details>
64
+
65
+ #### Response
66
+
67
+ If the request is successful, a `Notifications::Client:ResponseNotification` is returned.
43
68
  <details>
44
69
  <summary>
45
- Response
70
+ Click here to expand for more information.
46
71
  </summary>
47
72
 
48
- If the request is successful, a `Notifications::Client:ResponseNotification` is returned
49
-
50
73
  ```ruby
51
74
  sms => Notifications::Client::ResponseNotification
52
75
 
@@ -60,74 +83,66 @@ sms.template # => Hash containing id => id of the template
60
83
  sms.uri # => URL of the notification
61
84
  ```
62
85
 
86
+
63
87
  Otherwise the client will raise a `Notifications::Client::RequestError`:
64
- <table>
65
- <thead>
66
- <tr>
67
- <th>error.code</th>
68
- <th>error.message</th>
69
- </tr>
70
- </thead>
71
- <tbody>
72
- <tr>
73
- <td>
74
- <pre>429</pre>
75
- </td>
76
- <td>
77
- <pre>
78
- [{
79
- "error": "RateLimitError",
80
- "message": "Exceeded rate limit for key type TEAM of 10 requests per 10 seconds"
81
- }]
82
- </pre>
83
- </td>
84
- </tr>
85
- <tr>
86
- <td>
87
- <pre>429</pre>
88
- </td>
89
- <td>
90
- <pre>
91
- [{
92
- "error": "TooManyRequestsError",
93
- "message": "Exceeded send limits (50) for today"
94
- }]
95
- </pre>
96
- </td>
97
- </tr>
98
- <tr>
99
- <td>
100
- <pre>400</pre>
101
- </td>
102
- <td>
103
- <pre>
104
- [{
105
- "error": "BadRequestError",
106
- "message": "Can"t send to this recipient using a team-only API key"
107
- ]}
108
- </pre>
109
- </td>
110
- </tr>
111
- <tr>
112
- <td>
113
- <pre>400</pre>
114
- </td>
115
- <td>
116
- <pre>
117
- [{
118
- "error": "BadRequestError",
119
- "message": "Can"t send to this recipient when service is in trial mode
120
- - see https://www.notifications.service.gov.uk/trial-mode"
121
- }]
122
- </pre>
123
- </td>
124
- </tr>
125
- </tbody>
126
- </table>
127
- </details>
128
-
129
-
130
- Email:
88
+
89
+ |`error.code`|`error.message`|
90
+ |:---|:---|
91
+ |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM of 10 requests per 10 seconds"`<br>`}]`|
92
+ |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (50) for today"`<br>`}]`|
93
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can"t send to this recipient using a team-only API key"`<br>`]}`|
94
+ |`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>`}]`|
95
+
96
+ </details>
97
+
98
+ #### Arguments
99
+
100
+ <details>
101
+ <summary>
102
+ Click here to expand for more information.
103
+ </summary>
104
+
105
+ ##### `phone_number`
106
+
107
+ The phone number of the recipient, only required for sms notifications.
108
+
109
+ ##### `template_id`
110
+
111
+ Find by clicking **API info** for the template you want to send.
112
+
113
+ ##### `reference`
114
+
115
+ An optional identifier you generate. The `reference` can be used as a unique reference for the notification. Because Notify does not require this reference to be unique you could also use this reference to identify a batch or group of notifications.
116
+
117
+ You can omit this argument if you do not require a reference for the notification.
118
+
119
+ ##### `personalisation`
120
+
121
+ If a template has placeholders, you need to provide their values, for example:
122
+
123
+ ```python
124
+ personalisation={
125
+ 'first_name': 'Amala',
126
+ 'reference_number': '300241',
127
+ }
128
+ ```
129
+ ##### `sms_sender_id`
130
+
131
+ Optional. Specifies the identifier of the sms sender to set for the notification. The identifiers are found in your service Settings, when you 'Manage' your 'Text message sender'.
132
+
133
+ If you omit this argument your default sms sender will be set for the notification.
134
+
135
+ </details>
136
+
137
+
138
+ ### Email
139
+
140
+ #### Method
141
+
142
+ <details>
143
+ <summary>
144
+ Click here to expand for more information.
145
+ </summary>
131
146
 
132
147
  ```ruby
133
148
  email = client.send_email(
@@ -142,13 +157,18 @@ email = client.send_email(
142
157
  ) # => Notifications::Client::ResponseNotification
143
158
  ```
144
159
 
160
+ </details>
161
+
162
+
163
+ #### Response
164
+
165
+ If the request is successful, a `Notifications::Client:ResponseNotification` is returned.
166
+
145
167
  <details>
146
168
  <summary>
147
- Response
169
+ Click here to expand for more information.
148
170
  </summary>
149
171
 
150
- If the request is successful, a `Notifications::Client:ResponseNotification` is returned
151
-
152
172
  ```ruby
153
173
  email => Notifications::Client::ResponseNotification
154
174
 
@@ -164,72 +184,65 @@ email.uri # => URL of the notification
164
184
  ```
165
185
 
166
186
  Otherwise the client will raise a `Notifications::Client::RequestError`:
167
- <table>
168
- <thead>
169
- <tr>
170
- <th>error.code</th>
171
- <th>error.message</th>
172
- </tr>
173
- </thead>
174
- <tbody>
175
- <tr>
176
- <td>
177
- <pre>429</pre>
178
- </td>
179
- <td>
180
- <pre>
181
- [{
182
- "error": "RateLimitError",
183
- "message": "Exceeded rate limit for key type TEAM of 10 requests per 10 seconds"
184
- }]
185
- </pre>
186
- </td>
187
- </tr>
188
- <tr>
189
- <td>
190
- <pre>429</pre>
191
- </td>
192
- <td>
193
- <pre>
194
- [{
195
- "error": "TooManyRequestsError",
196
- "message": "Exceeded send limits (50) for today"
197
- }]
198
- </pre>
199
- </td>
200
- </tr>
201
- <tr>
202
- <td>
203
- <pre>400</pre>
204
- </td>
205
- <td>
206
- <pre>
207
- [{
208
- "error": "BadRequestError",
209
- "message": "Can"t send to this recipient using a team-only API key"
210
- ]}
211
- </pre>
212
- </td>
213
- </tr>
214
- <tr>
215
- <td>
216
- <pre>400</pre>
217
- </td>
218
- <td>
219
- <pre>
220
- [{
221
- "error": "BadRequestError",
222
- "message": "Can"t send to this recipient when service is in trial mode
223
- - see https://www.notifications.service.gov.uk/trial-mode"
224
- }]
225
- </pre>
226
- </td>
227
- </tr>
228
- </tbody>
229
- </table>
187
+
188
+ |`error.code`|`error.message`|
189
+ |:---|:---|
190
+ |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM of 10 requests per 10 seconds"`<br>`}]`|
191
+ |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (50) for today"`<br>`}]`|
192
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can"t send to this recipient using a team-only API key"`<br>`]}`|
193
+ |`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>`}]`|
194
+
230
195
  </details>
231
196
 
232
- Letter:
197
+
198
+ #### Arguments
199
+
200
+ <details>
201
+ <summary>
202
+ Click here to expand for more information.
203
+ </summary>
204
+
205
+ ##### `email_address`
206
+ The email address of the recipient, only required for email notifications.
207
+
208
+ ##### `template_id`
209
+
210
+ Find by clicking **API info** for the template you want to send.
211
+
212
+ ##### `reference`
213
+
214
+ An optional identifier you generate. The `reference` can be used as a unique reference for the notification. Because Notify does not require this reference to be unique you could also use this reference to identify a batch or group of notifications.
215
+
216
+ You can omit this argument if you do not require a reference for the notification.
217
+
218
+ ##### `email_reply_to_id`
219
+
220
+ Optional. Specifies the identifier of the email reply-to address to set for the notification. The identifiers are found in your service Settings, when you 'Manage' your 'Email reply to addresses'.
221
+
222
+ If you omit this argument your default email reply-to address will be set for the notification.
223
+
224
+ ##### `personalisation`
225
+
226
+ If a template has placeholders, you need to provide their values, for example:
227
+
228
+ ```python
229
+ personalisation={
230
+ 'first_name': 'Amala',
231
+ 'application_number': '300241',
232
+ }
233
+ ```
234
+
235
+ </details>
236
+
237
+
238
+ ### Letter
239
+
240
+ #### Method
241
+
242
+ <details>
243
+ <summary>
244
+ Click here to expand for more information.
245
+ </summary>
233
246
 
234
247
  ```ruby
235
248
  letter = client.send_letter(
@@ -246,13 +259,18 @@ letter = client.send_letter(
246
259
  ) # => Notifications::Client::ResponseNotification
247
260
  ```
248
261
 
262
+ </details>
263
+
264
+
265
+ #### Response
266
+
267
+ If the request is successful, a `Notifications::Client:ResponseNotification` is returned.
268
+
249
269
  <details>
250
270
  <summary>
251
- Response
271
+ Click here to expand for more information.
252
272
  </summary>
253
273
 
254
- If the request is successful, a `Notifications::Client:ResponseNotification` is returned
255
-
256
274
  ```ruby
257
275
  letter => Notifications::Client::ResponseNotification
258
276
 
@@ -266,91 +284,23 @@ letter.template # => Hash containing id => id of the template
266
284
  letter.uri # => URL of the notification
267
285
  ```
268
286
 
269
- Otherwise the client will raise a `Notifications::Client::RequestError`:
270
- <table>
271
- <thead>
272
- <tr>
273
- <th>error.code</th>
274
- <th>error.message</th>
275
- </tr>
276
- </thead>
277
- <tbody>
278
- <tr>
279
- <td>
280
- <pre>429</pre>
281
- </td>
282
- <td>
283
- <pre>
284
- [{
285
- "error": "RateLimitError",
286
- "message": "Exceeded rate limit for key type TEAM of 10 requests per 10 seconds"
287
- }]
288
- </pre>
289
- </td>
290
- </tr>
291
- <tr>
292
- <td>
293
- <pre>429</pre>
294
- </td>
295
- <td>
296
- <pre>
297
- [{
298
- "error": "TooManyRequestsError",
299
- "message": "Exceeded send limits (50) for today"
300
- }]
301
- </pre>
302
- </td>
303
- </tr>
304
- <tr>
305
- <td>
306
- <pre>400</pre>
307
- </td>
308
- <td>
309
- <pre>
310
- [{
311
- "error": "BadRequestError",
312
- "message": "Can"t send to this recipient using a team-only API key"
313
- ]}
314
- </pre>
315
- </td>
316
- </tr>
317
- <tr>
318
- <td>
319
- <pre>400</pre>
320
- </td>
321
- <td>
322
- <pre>
323
- [{
324
- "error": "BadRequestError",
325
- "message": "Can"t send to this recipient when service is in trial mode
326
- - see https://www.notifications.service.gov.uk/trial-mode"
327
- }]
328
- </pre>
329
- </td>
330
- </tr>
331
- <tr>
332
- <td>
333
- <pre>400</pre>
334
- </td>
335
- <td>
336
- <pre>
337
- [{
338
- "error": "ValidationError",
339
- "message": "personalisation address_line_1 is a required property"
340
- }]
341
- </pre>
342
- </td>
343
- </tr>
344
- </tbody>
345
- </table>
287
+ |`error.code`|`error.message`|
288
+ |:---|:---|
289
+ |`429`|`[{`<br>`"error": "RateLimitError",`<br>`"message": "Exceeded rate limit for key type TEAM of 10 requests per 10 seconds"`<br>`}]`|
290
+ |`429`|`[{`<br>`"error": "TooManyRequestsError",`<br>`"message": "Exceeded send limits (50) for today"`<br>`}]`|
291
+ |`400`|`[{`<br>`"error": "BadRequestError",`<br>`"message": "Can"t send to this recipient using a team-only API key"`<br>`]}`|
292
+ |`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>`}]`|
293
+ |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "personalisation address_line_1 is a required property"`<br>`}]`|
294
+
346
295
  </details>
347
296
 
348
- ### Arguments
349
- #### `phone_number`
350
- The phone number of the recipient, only required when using `client.send_sms`.
351
297
 
352
- #### `email_address`
353
- The email address of the recipient, only required when using `client.send_email`.
298
+ #### Arguments
299
+
300
+ <details>
301
+ <summary>
302
+ Click here to expand for more information.
303
+ </summary>
354
304
 
355
305
  #### `template_id`
356
306
  Find by clicking **API info** for the template you want to send.
@@ -360,11 +310,6 @@ An optional identifier you generate. The `reference` can be used as a unique ref
360
310
 
361
311
  You can omit this argument if you do not require a reference for the notification.
362
312
 
363
- #### `sms_sender_id`
364
- Optional. Specifies the identifier of the sms sender to set for the notification. The identifiers are found in your service Settings, when you 'Manage' your 'Text message sender'.
365
-
366
- If you omit this argument your default sms sender will be set for the notification.
367
-
368
313
  #### `personalisation`
369
314
  If the template has placeholders you need to provide their values as a Hash, for example:
370
315
 
@@ -394,23 +339,33 @@ personalisation: {
394
339
 
395
340
  The fields `address_line_1`, `address_line_2` and `postcode` are required.
396
341
 
397
- #### `email_reply_to_id`
342
+ </details>
398
343
 
399
- Optional. Specifies the identifier of the email reply-to address to set for the notification. The identifiers are found in your service Settings, when you 'Manage' your 'Email reply to addresses'.
400
344
 
401
- If you omit this argument your default email reply-to address will be set for the notification.
345
+ ## Get the status of one message
402
346
 
403
- ### Get the status of one message
347
+ #### Method
348
+
349
+ <details>
350
+ <summary>
351
+ Click here to expand for more information.
352
+ </summary>
404
353
 
405
354
  ```ruby
406
355
  notification = client.get_notification(id) # => Notifications::Client::Notification
407
356
  ```
408
357
 
358
+ </details>
359
+
360
+
361
+ #### Response
362
+
363
+ If successful a `Notifications::Client::Notification` is returned.
364
+
409
365
  <details>
410
366
  <summary>
411
- Response
367
+ Click here to expand for more information.
412
368
  </summary>
413
- If successful a `Notifications::Client::Notification is returned.
414
369
 
415
370
  ```ruby
416
371
  notification.id # => uuid for the notification
@@ -433,114 +388,93 @@ notification.updated_at # => Date time that the notification was last updated
433
388
  ```
434
389
  Otherwise a `Notification::Client::RequestError` is raised
435
390
 
436
- <table>
437
- <thead>
438
- <tr>
439
- <th>`error.code`</th>
440
- <th>`error.message`</th>
441
- </tr>
442
- </thead>
443
- <tbody>
444
- <tr>
445
- <td>
446
- <pre>404</pre>
447
- </td>
448
- <td>
449
- <pre>
450
- [{
451
- "error": "NoResultFound",
452
- "message": "No result found"
453
- }]
454
- </pre>
455
- </td>
456
- </tr>
457
- <tr>
458
- <td>
459
- <pre>400</pre>
460
- </td>
461
- <td>
462
- <pre>
463
- [{
464
- "error": "ValidationError",
465
- "message": "id is not a valid UUID"
466
- }]
467
- </pre>
468
- </td>
469
- </tr>
470
- </tbody>
471
- </table>
391
+ |`error.code`|`error.message`|
392
+ |:---|:---|
393
+ |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|
394
+ |`404`|`[{`<br>`"error": "ValidationError",`<br>`"message": "is not a valid UUID"`<br>`}]`|
395
+
472
396
  </details>
473
397
 
398
+ #### Arguments
399
+
400
+ <details>
401
+ <summary>
402
+ Click here to expand for more information.
403
+ </summary>
404
+
405
+ ##### `id`
406
+
407
+ The ID of the notification.
408
+
474
409
  </details>
475
410
 
476
- ### Get the status of all messages
411
+ ## Get the status of the all messages
412
+
413
+ #### Method
414
+
415
+ <details>
416
+ <summary>
417
+ Click here to expand for more information.
418
+ </summary>
477
419
 
478
420
  ```ruby
479
421
  # See section below for a description of the arguments.
422
+ # This will return 250 of the most recent messages if `older_than` is omitted, the following 250 messages can be accessed through the hash `notifications.links["next"]`
480
423
  args = {
481
424
  'template_type' => 'sms',
482
425
  'status' => 'failed',
483
426
  'reference' => 'your reference string'
484
- 'olderThanId' => 'e194efd1-c34d-49c9-9915-e4267e01e92e' # => Notifications::Client::Notification
427
+ 'older_than' => 'e194efd1-c34d-49c9-9915-e4267e01e92e' # => Notifications::Client::Notification
485
428
  }
486
429
  notifications = client.get_notifications(args)
487
430
  ```
431
+
432
+ </details>
433
+
434
+
435
+ #### Response
436
+
437
+ If the request is successful a `Notifications::Client::NotificationsCollection` is returned.
438
+
488
439
  <details>
489
440
  <summary>
490
- Response
441
+ Click here to expand for more information.
491
442
  </summary>
492
- If the request is successful a `Notifications::Client::NotificationsCollection` is returned.
493
443
 
494
444
  ```ruby
495
445
  notifications.links # => Hash containing current => "/notifications?template_type=sms&status=delivered"
496
- # next => "/notifications?other_than=last_id_in_list&template_type=sms&status=delivered"
446
+ # next => "/notifications?older_than=last_id_in_list&template_type=sms&status=delivered"
497
447
  notifications.collection # => [] (array of notification objects)
498
448
  ```
499
449
 
500
450
  Otherwise the client will raise a `Notifications::Client::RequestError`:
501
- <table>
502
- <thead>
503
- <tr>
504
- <th>error.status_code</th>
505
- <th>error.message</th>
506
- </tr>
507
- </thead>
508
- <tbody>
509
- <tr>
510
- <td>
511
- <pre>400</pre>
512
- </td>
513
- <td>
514
- <pre>
515
- [{
516
- 'error': 'ValidationError',
517
- 'message': 'bad status is not one of [created, sending, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure]'
518
- }]
519
- </pre>
520
- </td>
521
- </tr>
522
- <tr>
523
- <td>
524
- <pre>400</pre>
525
- </td>
526
- <td>
527
- <pre>
528
- [{
529
- "error": "ValidationError",
530
- "message": "Apple is not one of [sms, email, letter]"
531
- }]
532
- </pre>
533
- </td>
534
- </tr>
535
- </tbody>
536
- </table>
451
+
452
+ |`error.status_code`|`error.message`|
453
+ |:---|:---|
454
+ |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "bad status is not one of [created, sending, delivered, pending, failed, technical-failure, temporary-failure, permanent-failure]"`<br>`}]`|
455
+ |`400`|`[{`<br>`"error": "ValidationError",`<br>`"message": "Apple is not one of [sms, email, letter]"`<br>`}]`|
456
+
537
457
  </details>
538
458
 
539
- ### Arguments
459
+ #### Arguments
460
+
540
461
  Omit the argument Hash if you do not want to filter the results.
541
- #### `template_type`
542
462
 
543
- You can filter by:
463
+ <details>
464
+ <summary>
465
+ Click here to expand for more information.
466
+ </summary>
467
+
468
+ ##### `template_type`
469
+
470
+ <details>
471
+ <summary>
472
+ Click here to expand for more information.
473
+ </summary>
474
+
475
+ ##### `template_type`
476
+
477
+ If omitted all messages are returned. Otherwise you can filter by:
544
478
 
545
479
  * `email`
546
480
  * `sms`
@@ -548,7 +482,7 @@ You can filter by:
548
482
 
549
483
  You can omit this argument to ignore the filter.
550
484
 
551
- #### `status`
485
+ ##### `status`
552
486
 
553
487
  You can filter by:
554
488
 
@@ -561,28 +495,44 @@ You can filter by:
561
495
 
562
496
  You can omit this argument to ignore the filter.
563
497
 
564
- ### `reference`
498
+ ##### `reference`
565
499
 
566
500
  This is the `reference` you gave at the time of sending the notification. The `reference` can be a unique identifier for the notification or an identifier for a batch of notifications.
567
501
 
568
502
  You can omit this argument to ignore the filter.
569
503
 
570
504
 
571
- #### `olderThanId`
505
+ ##### `older_than`
572
506
  You can get the notifications older than a given `Notification.id`.
573
507
  You can omit this argument to ignore this filter.
574
508
 
509
+ </details>
510
+
511
+
575
512
 
576
513
  ## Get a template by ID
514
+
515
+ #### Method
516
+
577
517
  This will return the latest version of the template. Use [getTemplateVersion](#get-a-template-by-id-and-version) to retrieve a specific template version.
578
518
 
519
+ <details>
520
+ <summary>
521
+ Click here to expand for more information.
522
+ </summary>
523
+
579
524
  ```ruby
580
- template = client.get_template_by_id(template_id)
525
+ template = client.get_template_by_id(id)
581
526
  ```
582
527
 
528
+ </details>
529
+
530
+
531
+ #### Response
532
+
583
533
  <details>
584
534
  <summary>
585
- Response
535
+ Click here to expand for more information.
586
536
  </summary>
587
537
 
588
538
  ```Ruby
@@ -598,55 +548,52 @@ template.subject # => subject for email templates, will be empty for other te
598
548
 
599
549
  Otherwise the client will raise a `Notifications::Client::RequestError`.
600
550
 
601
- <table>
602
- <thead>
603
- <tr>
604
- <th>message</th>
605
- </tr>
606
- </thead>
607
- <tbody>
608
- <tr>
609
- <td>
610
- <pre>
611
- Status code: 404 {
612
- "errors":
613
- [{
614
- "error": "NoResultFound",
615
- "message": "No result found"
616
- }]
617
- }
618
- </pre>
619
- <pre>
620
- Status code: 400 {
621
- "errors":
622
- [{
623
- "error": "ValidationError",
624
- "message": "id is not a valid UUID"
625
- }]
626
- }
627
- </pre>
628
- </tbody>
629
- </table>
630
551
  </details>
631
552
 
632
- ### Arguments
633
553
 
634
- #### `templateId`
554
+ #### Arguments
555
+
556
+ <details>
557
+ <summary>
558
+ Click here to expand for more information.
559
+ </summary>
560
+
561
+ |`error.code`|`error.message`|
562
+ |:---|:---|
563
+ |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|
564
+ |`404`|`[{`<br>`"error": "ValidationError",`<br>`"message": "is is not a valid UUID"`<br>`}]`|
565
+
566
+ ##### `id`
635
567
  The template id is visible on the template page in the application.
636
568
 
569
+ </details>
570
+
637
571
 
638
572
  ## Get a template by ID and version
573
+
574
+ #### Method
575
+
639
576
  This will return the template for the given id and version.
577
+ <details>
578
+ <summary>
579
+ Click here to expand for more information.
580
+ </summary>
640
581
 
641
582
  ```ruby
642
- Template template = client.get_template_version(template_id template_id, version)
583
+ Template template = client.get_template_version(id, version)
643
584
  ```
644
585
 
586
+ </details>
587
+
588
+
589
+ #### Response
590
+
645
591
  <details>
646
592
  <summary>
647
- Response
593
+ Click here to expand for more information.
648
594
  </summary>
649
595
 
596
+
650
597
  ```Ruby
651
598
  template.id # => uuid for the template
652
599
  template.type # => type of template one of email|sms|letter
@@ -660,48 +607,41 @@ template.subject # => subject for email templates, will be empty for other te
660
607
 
661
608
  Otherwise the client will raise a `Notifications::Client::RequestError`.
662
609
 
663
- <table>
664
- <thead>
665
- <tr>
666
- <th>message</th>
667
- </tr>
668
- </thead>
669
- <tbody>
670
- <tr>
671
- <td>
672
- <pre>
673
- Status code: 404 {
674
- "errors":
675
- [{
676
- "error": "NoResultFound",
677
- "message": "No result found"
678
- }]
679
- }
680
- </pre>
681
- <pre>
682
- Status code: 400 {
683
- "errors":
684
- [{
685
- "error": "ValidationError",
686
- "message": "id is not a valid UUID"
687
- }]
688
- }
689
- </pre>
690
- </tbody>
691
- </table>
610
+ |`error.code`|`error.message`|
611
+ |:---|:---|
612
+ |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|
613
+ |`404`|`[{`<br>`"error": "ValidationError",`<br>`"message": "is is not a valid UUID"`<br>`}]`|
614
+
692
615
  </details>
693
616
 
694
- ### Arguments
695
617
 
696
- #### `templateId`
618
+ #### Arguments
619
+
620
+ <details>
621
+ <summary>
622
+ Click here to expand for more information.
623
+ </summary>
624
+
625
+ #### `id`
697
626
  The template id is visible on the template page in the application.
698
627
 
699
628
  #### `version`
700
629
  A history of the template is kept. There is a link to `See previous versions` on the template page in the application.
701
630
 
631
+ </details>
632
+
633
+
702
634
  ## Get all templates
635
+
636
+ #### Method
637
+
703
638
  This will return the latest version of each template for your service.
704
639
 
640
+ <details>
641
+ <summary>
642
+ Click here to expand for more information.
643
+ </summary>
644
+
705
645
  ```ruby
706
646
  args = {
707
647
  'template_type' => 'sms'
@@ -709,9 +649,15 @@ args = {
709
649
  templates = client.get_all_templates(args)
710
650
  ```
711
651
 
652
+
653
+ </details>
654
+
655
+
656
+ #### Response
657
+
712
658
  <details>
713
659
  <summary>
714
- Response
660
+ Click here to expand for more information.
715
661
  </summary>
716
662
 
717
663
  ```ruby
@@ -723,81 +669,153 @@ If no templates exist for a template type or there no templates for a service, t
723
669
 
724
670
  Otherwise the client will raise a `Notifications::Client::RequestError`.
725
671
 
726
-
727
672
  </details>
728
673
 
729
- ### Arguments
730
674
 
731
- #### `templateType`
732
- You can filter the templates by the following options:
675
+ #### Arguments
676
+
677
+ <details>
678
+ <summary>
679
+ Click here to expand for more information.
680
+ </summary>
681
+
682
+ ##### `template_type`
683
+ If omitted all templates are returned. Otherwise you can filter by:
733
684
 
734
685
  * `email`
735
686
  * `sms`
736
687
  * `letter`
737
- You can omit this argument to ignore this filter.
688
+
689
+
690
+ </details>
691
+
692
+
693
+ </details>
738
694
 
739
695
 
740
696
  ## Generate a preview template
697
+
698
+ #### Method
699
+
741
700
  This will return the contents of a template with the placeholders replaced with the given personalisation.
701
+
702
+ <details>
703
+ <summary>
704
+ Click here to expand for more information.
705
+ </summary>
706
+
707
+
742
708
  ```ruby
743
- templatePreview = client.generate_template_preview(template_id,
709
+ templatePreview = client.generate_template_preview(id,
744
710
  personalisation: {
745
711
  name: "name",
746
712
  year: "2016",
747
713
  })
748
714
  ```
749
715
 
716
+ </details>
717
+
718
+
719
+ #### Response
720
+
750
721
  <details>
751
722
  <summary>
752
- Response
723
+ Click here to expand for more information.
753
724
  </summary>
754
725
 
755
-
756
726
  ```Ruby
757
727
  template.id # => uuid for the template
758
728
  template.version # => version of the template
759
729
  template.body # => content of the template
760
730
  template.subject # => subject for email templates, will be empty for other template types
761
731
  ```
762
-
763
-
764
732
  Otherwise a `Notifications::Client::RequestError` is thrown.
765
- <table>
766
- <thead>
767
- <tr>
768
- <th>message</th>
769
- </tr>
770
- </thead>
771
- <tbody>
772
- <tr>
773
- <td>
774
- <pre>
775
- Status code: 404 {
776
- "errors":
777
- [{
778
- "error": "NoResultFound",
779
- "message": "No result found"
780
- }]
781
- }
782
- </pre>
783
- <pre>
784
- Status code: 400 {
785
- "errors":
786
- [{
787
- "error": "ValidationError",
788
- "message": "id is not a valid UUID"
789
- }]
790
- }
791
- </pre>
792
- </tbody>
793
- </table>
733
+
734
+ |`error.code`|`error.message`|
735
+ |:---|:---|
736
+ |`404`|`[{`<br>`"error": "NoResultFound",`<br>`"message": "No result found"`<br>`}]`|
737
+ |`404`|`[{`<br>`"error": "ValidationError",`<br>`"message": "is is not a valid UUID"`<br>`}]`|
794
738
 
795
739
  </details>
796
740
 
797
- ### Arguments
798
741
 
799
- #### `templateId`
742
+ #### Arguments
743
+
744
+ <details>
745
+ <summary>
746
+ Click here to expand for more information.
747
+ </summary>
748
+
749
+ ##### `id`
800
750
  The template id is visible on the template page in the application.
801
751
 
802
- #### `personalisation`
752
+ ##### `personalisation`
803
753
  If a template has placeholders, you need to provide their values. `personalisation` can be an empty or null in which case no placeholders are provided for the notification.
754
+
755
+ </details>
756
+
757
+ ## Get received texts
758
+ #### Method
759
+
760
+ <details>
761
+ <summary>
762
+ Click here to expand for more information.
763
+ </summary>
764
+
765
+ ```ruby
766
+ # See section below for a description of the arguments.
767
+ # This will return 250 of the most recent messages if `older_than` is omitted, the following 250 messages can be accessed through the hash `received_texts.links["next"]`
768
+ args = {
769
+ 'older_than' => 'e194efd1-c34d-49c9-9915-e4267e01e92e' # => Notifications::Client::ReceivedText
770
+ }
771
+ received_texts = client.get_received_texts(args)
772
+ ```
773
+
774
+ </details>
775
+
776
+
777
+ #### Response
778
+
779
+ If the request is successful a `Notifications::Client::ReceivedTextCollection` is returned.
780
+
781
+ <details>
782
+ <summary>
783
+ Click here to expand for more information.
784
+ </summary>
785
+
786
+ `ReceivedTextCollection` -
787
+
788
+ ```ruby
789
+ received_texts.links # => Hash containing current => "/v2/received-text-messages"
790
+ # next => "/v2/received-text-messages?older_than=last_id_in_list"
791
+ received_texts.collection # => [] (array of ReceivedText objects)
792
+ ```
793
+
794
+ `ReceivedText` -
795
+
796
+ ```ruby
797
+ received_text.id # => uuid for the received text
798
+ received_text.created_at # => created_at of the received text
799
+ received_text.content # => content of the received text
800
+ received_text.notify_number # => number received text was sent to
801
+ received_text.service_id # => service id of the received text
802
+ received_text.user_number # => number received text was sent from
803
+
804
+ ```
805
+
806
+ </details>
807
+
808
+ #### Arguments
809
+
810
+ Omit the argument Hash if you do not want to filter the results.
811
+
812
+ <details>
813
+ <summary>
814
+ Click here to expand for more information.
815
+ </summary>
816
+
817
+ ##### `older_than`
818
+ You can get the notifications older than a given `received_text.id`.
819
+ You can omit this argument to ignore this filter.
820
+
821
+ </details>