gds-api-adapters 59.6.0 → 60.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: 5ee539922420b2b26ca6738b21e158700b47bd3d0203dde7d931bccfa7fbc845
4
- data.tar.gz: 66b6dd8c2c697640ee73e76b0549e0f1e536c69260ec030bd6bbf069effec729
3
+ metadata.gz: 1a761a4156a0af6763014d9994f5543a23c6c33ea6ff2745ba5bddb28eb1965c
4
+ data.tar.gz: 5a3946e67f7de853cc33d204050263b3127890baf511585579b23acdec5a8e0e
5
5
  SHA512:
6
- metadata.gz: aa9616db55840aa7c9b2896c7c17c8513e04a4f6cf30c03842d42f20db3878ad47a42a897639b7bf0abc81b213ef4c2bf6d82572801e31da683b05dc441e8810
7
- data.tar.gz: e651bc81c1ef9881fc905fd540e64f21741bc99516f8ab0c608ab473ef69097814bbd8c5675162505d50becfd77aad526477976a99f387b508222d33cfbc55d8
6
+ metadata.gz: cfb3c6776af3f5a8da321b023b0019d44cba7a5a62d22411430c805fae76fc13ab015b5293fbe72f6e4a73f0b20905b4d06398d9fcd4a016ac8f4c87cc208131
7
+ data.tar.gz: eb4891111d7024a646b57ea991ec8f46445ca4859a16853492a0887ef6e1eb881723c98abf724831fd61777061363e5e0dba8c698c77cc5079218ab1396bc66f
@@ -52,11 +52,25 @@ class GdsApi::EmailAlertApi < GdsApi::Base
52
52
  post_json("#{endpoint}/subscriber-lists", attributes)
53
53
  end
54
54
 
55
- # Post notification
55
+ # Post a content change
56
56
  #
57
- # @param publication [Hash] Valid publication attributes
58
- def send_alert(publication, headers = {})
59
- post_json("#{endpoint}/notifications", publication, headers)
57
+ # @param content_change [Hash] Valid content change attributes
58
+ def create_content_change(content_change, headers = {})
59
+ post_json("#{endpoint}/content-changes", content_change, headers)
60
+ end
61
+
62
+ # Post a message
63
+ #
64
+ # @param message [Hash] Valid message attributes
65
+ def create_message(message, headers = {})
66
+ post_json("#{endpoint}/messages", message, headers)
67
+ end
68
+
69
+ # Send email
70
+ #
71
+ # @param email_params [Hash] address, subject, body
72
+ def create_email(email_params)
73
+ post_json("#{endpoint}/emails", email_params)
60
74
  end
61
75
 
62
76
  # Unpublishing alert
@@ -148,8 +148,18 @@ module GdsApi
148
148
  .to_return(status: 202, body: {}.to_json)
149
149
  end
150
150
 
151
- def stub_email_alert_api_accepts_alert
152
- stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/notifications")
151
+ def stub_email_alert_api_accepts_content_change
152
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/content-changes")
153
+ .to_return(status: 202, body: {}.to_json)
154
+ end
155
+
156
+ def stub_email_alert_api_accepts_message
157
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/messages")
158
+ .to_return(status: 202, body: {}.to_json)
159
+ end
160
+
161
+ def stub_email_alert_api_accepts_email
162
+ stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/emails")
153
163
  .to_return(status: 202, body: {}.to_json)
154
164
  end
155
165
 
@@ -157,7 +167,7 @@ module GdsApi
157
167
  stub_request(:any, %r{\A#{EMAIL_ALERT_API_ENDPOINT}})
158
168
  end
159
169
 
160
- def assert_email_alert_sent(attributes = nil)
170
+ def assert_email_alert_api_content_change_created(attributes = nil)
161
171
  if attributes
162
172
  matcher = ->(request) do
163
173
  payload = JSON.parse(request.body)
@@ -165,28 +175,18 @@ module GdsApi
165
175
  end
166
176
  end
167
177
 
168
- assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/notifications", times: 1, &matcher)
178
+ assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/content-changes", times: 1, &matcher)
169
179
  end
170
180
 
171
- def stub_email_alert_api_has_notifications(notifications, start_at = nil)
172
- url = "#{EMAIL_ALERT_API_ENDPOINT}/notifications"
173
- url += "?start_at=#{start_at}" if start_at
174
- url_regexp = Regexp.new("^#{Regexp.escape(url)}$")
175
-
176
- stub_request(:get, url_regexp)
177
- .to_return(
178
- status: 200,
179
- body: notifications.to_json
180
- )
181
- end
182
-
183
- def stub_email_alert_api_has_notification(notification)
184
- url = "#{EMAIL_ALERT_API_ENDPOINT}/notifications/#{notification['web_service_bulletin']['to_param']}"
181
+ def assert_email_alert_api_message_created(attributes = nil)
182
+ if attributes
183
+ matcher = ->(request) do
184
+ payload = JSON.parse(request.body)
185
+ payload.select { |k, _| attributes.key?(k) } == attributes
186
+ end
187
+ end
185
188
 
186
- stub_request(:get, url).to_return(
187
- status: 200,
188
- body: notification.to_json
189
- )
189
+ assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/messages", times: 1, &matcher)
190
190
  end
191
191
 
192
192
  def stub_email_alert_api_unsubscribes_a_subscription(uuid)
@@ -283,9 +283,6 @@ module GdsApi
283
283
  alias_method :email_alert_api_creates_subscriber_list, :stub_email_alert_api_creates_subscriber_list
284
284
  alias_method :email_alert_api_refuses_to_create_subscriber_list, :stub_email_alert_api_refuses_to_create_subscriber_list
285
285
  alias_method :email_alert_api_accepts_unpublishing_message, :stub_email_alert_api_accepts_unpublishing_message
286
- alias_method :email_alert_api_accepts_alert, :stub_email_alert_api_accepts_alert
287
- alias_method :email_alert_api_has_notifications, :stub_email_alert_api_has_notifications
288
- alias_method :email_alert_api_has_notification, :stub_email_alert_api_has_notification
289
286
  alias_method :email_alert_api_unsubscribes_a_subscription, :stub_email_alert_api_unsubscribes_a_subscription
290
287
  alias_method :email_alert_api_has_no_subscription_for_uuid, :stub_email_alert_api_has_no_subscription_for_uuid
291
288
  alias_method :email_alert_api_unsubscribes_a_subscriber, :stub_email_alert_api_unsubscribes_a_subscriber
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '59.6.0'.freeze
2
+ VERSION = '60.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 59.6.0
4
+ version: 60.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable