notifications-ruby-client 2.2.0 → 2.3.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: 1cacbc8bf726eac5dfde61a8b0f9bad26ece23e6
4
- data.tar.gz: 62f6050ebcab00e662124c17bb5f5b32c7b25505
3
+ metadata.gz: ef674bdb3a2528e839be78d8b0cbd00ee6282e24
4
+ data.tar.gz: b0eebc96892290238c4630571e6486c1698683a3
5
5
  SHA512:
6
- metadata.gz: 01ccf7949dc273065b7a5324f72b0080879d89c7136e5d10fdd13e4e51c92a88e4346378527216e1c7a624666853df1f745895b1d7db3ed03d1c0d3e59c73f3a
7
- data.tar.gz: 449bcdb891547ec90f0f026036ad801b213e60288c22ef8a65ab53f76721a2403a3f35dc83a6a1b4c73bd2a401ac7d3bf4dc3aed395dd199b1b7754d4565868c
6
+ metadata.gz: 77bf1e4c948f19d5acc96acdfdff7c7b73fdb95b7fb235aa940ec5f6882579915c550d2a5fcdad8a3048e104707a7ea6dfec52bbb17a684411c3324376a69a92
7
+ data.tar.gz: 1c4cd55f314823d2c974f91fd0b9d1cb731cc19665f2ec7d0415476fb6bea2016e1fe76d4c7026f743f2f88e274ab1f7250356a057080fe6ee628de0377c248e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 2.3.0
2
+
3
+ ### Changed
4
+ * It is now possible to have multiple email to reply to addresses. Added the option to specify an `email_reply_to_id`
5
+ when using the `send_email` method. If no `email_reply_to_id` is specified, the default email reply to address will be
6
+ used.
7
+ * Upgraded all dependencies
8
+ * Minor code style changes and fixes for the tests
9
+
1
10
  ## 2.2.0
2
11
 
3
12
  ### Changed
data/README.md CHANGED
@@ -137,6 +137,7 @@ email = client.send_email(
137
137
  year: "2016"
138
138
  },
139
139
  reference: "your_reference_string"
140
+ email_reply_to_id: email_reply_to_id
140
141
  ) # => Notifications::Client::ResponseNotification
141
142
  ```
142
143
 
@@ -387,6 +388,12 @@ personalisation: {
387
388
 
388
389
  The fields `address_line_1`, `address_line_2` and `postcode` are required.
389
390
 
391
+ #### `email_reply_to_id`
392
+
393
+ 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'.
394
+
395
+ If you omit this argument your default email reply-to address will be set for the notification.
396
+
390
397
  ### Get the status of one message
391
398
 
392
399
  ```ruby
@@ -727,7 +734,7 @@ You can omit this argument to ignore this filter.
727
734
  ## Generate a preview template
728
735
  This will return the contents of a template with the placeholders replaced with the given personalisation.
729
736
  ```ruby
730
- templatePreview = client.generate_template_preview(template_id: template_id,
737
+ templatePreview = client.generate_template_preview(template_id,
731
738
  personalisation: {
732
739
  name: "name",
733
740
  year: "2016",
@@ -18,6 +18,7 @@ env_vars=(
18
18
  EMAIL_TEMPLATE_ID
19
19
  SMS_TEMPLATE_ID
20
20
  LETTER_TEMPLATE_ID
21
+ EMAIL_REPLY_TO_ID
21
22
  )
22
23
 
23
24
  for env_var in "${env_vars[@]}"; do
data/bin/test_client.rb CHANGED
@@ -1,10 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'notifications/client'
3
- require 'notifications/client/notification'
4
- require 'notifications/client/response_notification'
5
- require 'notifications/client/notification'
6
- require 'notifications/client/response_template'
7
- require 'notifications/client/template_collection'
2
+ require './lib/notifications/client'
8
3
 
9
4
  def main
10
5
  client = Notifications::Client.new(ENV['API_KEY'], ENV['NOTIFY_API_URL'])
@@ -35,7 +30,7 @@ def test_get_template_version(client, id, version)
35
30
  end
36
31
 
37
32
  def test_get_all_templates(client)
38
- response = client.get_all_templates()
33
+ response = client.get_all_templates
39
34
  unless response.is_a?(Notifications::Client::TemplateCollection)
40
35
  p 'failed test_get_all_templates response is not a Notifications::Client::TemplateCollection'
41
36
  exit 1
@@ -50,7 +45,7 @@ def test_get_all_templates(client)
50
45
  end
51
46
 
52
47
  def test_get_all_templates_filter_by_type(client)
53
- response = client.get_all_templates({'type' => 'sms'})
48
+ response = client.get_all_templates('type' => 'sms')
54
49
  unless response.is_a?(Notifications::Client::TemplateCollection)
55
50
  p 'failed test_get_all_templates response is not a Notifications::Client::TemplateCollection'
56
51
  exit 1
@@ -63,8 +58,7 @@ def test_get_all_templates_filter_by_type(client)
63
58
  end
64
59
 
65
60
  def test_generate_template_preview(client, id)
66
-
67
- response = client.generate_template_preview(id, personalisation:Hash["name", "some name"])
61
+ response = client.generate_template_preview(id, personalisation: { "name" => "some name" })
68
62
  test_template_preview(response)
69
63
  end
70
64
 
@@ -93,16 +87,18 @@ def test_template_preview(response)
93
87
  end
94
88
 
95
89
  def test_send_email_endpoint(client)
96
- email_resp = client.send_email(email_address: ENV['FUNCTIONAL_TEST_EMAIL'], template_id: ENV['EMAIL_TEMPLATE_ID'],
97
- personalisation:Hash["name", "some name"],
98
- reference: "some reference")
90
+ email_resp = client.send_email(email_address: ENV['FUNCTIONAL_TEST_EMAIL'],
91
+ template_id: ENV['EMAIL_TEMPLATE_ID'],
92
+ personalisation: { "name" => "some name" },
93
+ reference: "some reference",
94
+ email_reply_to_id: ENV['EMAIL_REPLY_TO_ID'])
99
95
  test_notification_response_data_type(email_resp, 'email')
100
96
  email_resp
101
97
  end
102
98
 
103
99
  def test_send_sms_endpoint(client)
104
100
  sms_resp = client.send_sms(phone_number: ENV['FUNCTIONAL_TEST_NUMBER'], template_id: ENV['SMS_TEMPLATE_ID'],
105
- personalisation:Hash["name", "some name"],
101
+ personalisation: { "name" => "some name" },
106
102
  reference: "some reference")
107
103
  test_notification_response_data_type(sms_resp, 'sms')
108
104
  sms_resp
@@ -124,22 +120,22 @@ end
124
120
 
125
121
  def test_notification_response_data_type(notification, message_type)
126
122
  unless notification.is_a?(Notifications::Client::ResponseNotification)
127
- p 'failed ' + message_type +' response is not a Notifications::Client::ResponseNotification'
123
+ p 'failed ' + message_type + ' response is not a Notifications::Client::ResponseNotification'
128
124
  exit 1
129
125
  end
130
126
  unless notification.id.is_a?(String)
131
- p 'failed '+ message_type + 'id is not a String'
127
+ p 'failed ' + message_type + 'id is not a String'
132
128
  exit 1
133
129
  end
134
- field_should_not_be_nil(expected_fields_in_notification_response, notification, 'send_'+message_type)
135
- hash_key_should_not_be_nil(expected_fields_in_template, notification.send('template'), 'send_'+message_type+'.template')
130
+ field_should_not_be_nil(expected_fields_in_notification_response, notification, 'send_' + message_type)
131
+ hash_key_should_not_be_nil(expected_fields_in_template, notification.send('template'), 'send_' + message_type + '.template')
136
132
 
137
133
  if message_type == 'email'
138
- hash_key_should_not_be_nil(expected_fields_in_email_content, notification.send('content'), 'send_'+message_type+'.content')
134
+ hash_key_should_not_be_nil(expected_fields_in_email_content, notification.send('content'), 'send_' + message_type + '.content')
139
135
  elsif message_type == 'sms'
140
- hash_key_should_not_be_nil(expected_fields_in_sms_content, notification.send('content'),'send_'+message_type+'.content')
136
+ hash_key_should_not_be_nil(expected_fields_in_sms_content, notification.send('content'), 'send_' + message_type + '.content')
141
137
  elsif message_type == 'letter'
142
- hash_key_should_not_be_nil(expected_fields_in_letter_content, notification.send('content'),'send_'+message_type+'.content')
138
+ hash_key_should_not_be_nil(expected_fields_in_letter_content, notification.send('content'), 'send_' + message_type + '.content')
143
139
  end
144
140
  end
145
141
 
@@ -199,16 +195,14 @@ def expected_fields_in_template_response
199
195
  created_at
200
196
  created_by
201
197
  body
202
- version
203
- )
198
+ version)
204
199
  end
205
200
 
206
201
  def expected_fields_in_template_preview
207
202
  %w(id
208
203
  body
209
204
  version
210
- type
211
- )
205
+ type)
212
206
  end
213
207
 
214
208
  def expected_fields_in_notification_response
@@ -216,20 +210,17 @@ def expected_fields_in_notification_response
216
210
  reference
217
211
  content
218
212
  template
219
- uri
220
- )
213
+ uri)
221
214
  end
222
215
 
223
216
  def expected_fields_in_email_content
224
217
  %w(from_email
225
218
  body
226
- subject
227
- )
219
+ subject)
228
220
  end
229
221
 
230
222
  def expected_fields_in_sms_content
231
- %w(body
232
- )
223
+ %w(body)
233
224
  end
234
225
 
235
226
  def expected_fields_in_letter_content
@@ -247,8 +238,7 @@ def expected_fields_in_email_notification
247
238
  template
248
239
  body
249
240
  subject
250
- created_at
251
- )
241
+ created_at)
252
242
  end
253
243
 
254
244
  def expected_fields_in_email_notification_that_are_nil
@@ -260,8 +250,7 @@ def expected_fields_in_email_notification_that_are_nil
260
250
  line_5
261
251
  line_5
262
252
  line_6
263
- postcode
264
- )
253
+ postcode)
265
254
  end
266
255
 
267
256
  def expected_fields_in_sms_notification
@@ -271,8 +260,7 @@ def expected_fields_in_sms_notification
271
260
  status
272
261
  template
273
262
  body
274
- created_at
275
- )
263
+ created_at)
276
264
  end
277
265
 
278
266
  def expected_fields_in_sms_notification_that_are_nil
@@ -322,7 +310,7 @@ def expected_fields_in_template
322
310
  end
323
311
 
324
312
  def test_get_all_notifications(client)
325
- notifications = client.get_notifications()
313
+ notifications = client.get_notifications
326
314
  unless notifications.is_a?(Notifications::Client::NotificationsCollection)
327
315
  p 'get all notifications is not Notifications::Client::NotificationsCollection'
328
316
  exit 1
@@ -332,8 +320,7 @@ end
332
320
 
333
321
  def expected_fields_for_get_all_notifications
334
322
  %W(links
335
- collection
336
- )
323
+ collection)
337
324
  end
338
325
 
339
326
  if __FILE__ == $PROGRAM_NAME
@@ -1,7 +1,7 @@
1
1
  require "net/https"
2
2
  require "uri"
3
3
  require "jwt"
4
- require "notifications/client/request_error"
4
+ require_relative "request_error"
5
5
 
6
6
  module Notifications
7
7
  class Client
@@ -38,6 +38,8 @@ module Notifications
38
38
  # A reference specified by the service for the notification. Get all notifications can be filtered by this reference.
39
39
  # This reference can be unique or used used to refer to a batch of notifications.
40
40
  # Can be an empty string or nil, when you do not require a reference for the notifications.
41
+ # @option form_data [String] :email_reply_to_id
42
+ # id of the email address that replies to email notifications will be sent to
41
43
  # @see #perform_request!
42
44
  def post(kind, form_data)
43
45
  request = Net::HTTP::Post.new(
@@ -1,5 +1,5 @@
1
1
  module Notifications
2
2
  class Client
3
- VERSION = "2.2.0".freeze
3
+ VERSION = "2.3.0".freeze
4
4
  end
5
5
  end
@@ -1,11 +1,11 @@
1
- require "notifications/client/version"
2
- require "notifications/client/speaker"
3
- require "notifications/client/notification"
4
- require "notifications/client/response_notification"
5
- require "notifications/client/notifications_collection"
6
- require "notifications/client/response_template"
7
- require "notifications/client/template_collection"
8
- require "notifications/client/template_preview"
1
+ require_relative "client/version"
2
+ require_relative "client/speaker"
3
+ require_relative "client/notification"
4
+ require_relative "client/response_notification"
5
+ require_relative "client/notifications_collection"
6
+ require_relative "client/response_template"
7
+ require_relative "client/template_collection"
8
+ require_relative "client/template_preview"
9
9
  require "forwardable"
10
10
 
11
11
  module Notifications
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_runtime_dependency "jwt", "~> 1.5"
23
+ spec.add_runtime_dependency "jwt", "~> 2.1"
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.7"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
28
- spec.add_development_dependency "webmock", "~> 2.0"
29
- spec.add_development_dependency "factory_girl", "~> 4.7"
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 12.1"
27
+ spec.add_development_dependency "rspec", "~> 3.6"
28
+ spec.add_development_dependency "webmock", "~> 3.1"
29
+ spec.add_development_dependency "factory_girl", "~> 4.8"
30
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: 2.2.0
4
+ version: 2.3.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: 2017-08-24 00:00:00.000000000 Z
11
+ date: 2017-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -16,84 +16,84 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: '2.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '1.13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
40
+ version: '1.13'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '12.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '12.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '3.6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '3.6'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.0'
75
+ version: '3.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.0'
82
+ version: '3.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: factory_girl
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '4.7'
89
+ version: '4.8'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '4.7'
96
+ version: '4.8'
97
97
  description:
98
98
  email:
99
99
  - notify@digital.cabinet-office.gov.uk
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.5.1
148
+ rubygems_version: 2.6.13
149
149
  signing_key:
150
150
  specification_version: 4
151
151
  summary: Ruby client for GOV.UK Notifications API