gds-api-adapters 57.5.0 → 58.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gds_api/email_alert_api.rb +6 -6
- data/lib/gds_api/publishing_api.rb +21 -0
- data/lib/gds_api/test_helpers/email_alert_api.rb +15 -15
- data/lib/gds_api/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: c7d9ecf3ac65ca6371589de670a63f3fae3f0dbc691ca2b6d3cc4672e2ae4f39
|
4
|
+
data.tar.gz: 6461edf825df98fe824566d3c514d861989e3b5dd326348c98f5a51c5c2f0abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c256cab86245efd9c1daf1903f289c08b436fb859fee3725eeb32f48d4583e39a34e9f5ea8af48d3bc7e941ddf3850ade0dbd8c43e23eed2d0a3f3dac2b9085
|
7
|
+
data.tar.gz: a6d1ca1c4f05a2b763ea614bf9dac6b77aebd005e401d6b6cae60a42ab47d4a65db89663709827318889c613d66dfef29065ff3c4fdc78e1b461fc3b7a9c1040
|
@@ -102,18 +102,18 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
102
102
|
# Subscribe
|
103
103
|
#
|
104
104
|
# @return [Hash] subscription_id
|
105
|
-
def subscribe(
|
105
|
+
def subscribe(subscriber_list_id:, address:, frequency: "immediately")
|
106
106
|
post_json(
|
107
107
|
"#{endpoint}/subscriptions",
|
108
|
-
|
108
|
+
subscriber_list_id: subscriber_list_id,
|
109
109
|
address: address,
|
110
110
|
frequency: frequency,
|
111
111
|
)
|
112
112
|
end
|
113
113
|
|
114
|
-
# Get a
|
114
|
+
# Get a Subscriber List
|
115
115
|
#
|
116
|
-
# @return [Hash]
|
116
|
+
# @return [Hash] subscriber_list: {
|
117
117
|
# id
|
118
118
|
# title
|
119
119
|
# gov_delivery_id
|
@@ -126,8 +126,8 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
126
126
|
# government_document_supertype
|
127
127
|
# subscriber_count
|
128
128
|
# }
|
129
|
-
def
|
130
|
-
get_json("#{endpoint}/
|
129
|
+
def get_subscriber_list(slug:)
|
130
|
+
get_json("#{endpoint}/subscriber-lists/#{slug}")
|
131
131
|
end
|
132
132
|
|
133
133
|
# Get a Subscription
|
@@ -2,10 +2,31 @@ require_relative 'base'
|
|
2
2
|
require_relative 'exceptions'
|
3
3
|
|
4
4
|
class GdsApi::PublishingApi < GdsApi::Base
|
5
|
+
# Create a publishing intent for a base_path.
|
6
|
+
#
|
7
|
+
# @param base_path [String]
|
8
|
+
# @param payload [Hash]
|
9
|
+
# @example
|
10
|
+
#
|
11
|
+
# publishing_api.put_intent(
|
12
|
+
# '/some/base_path',
|
13
|
+
# {
|
14
|
+
# publish_time: '2024-03-15T09:00:00.000+00:00',
|
15
|
+
# publishing_app: 'content-publisher',
|
16
|
+
# rendering_app: 'government-frontend',
|
17
|
+
# }
|
18
|
+
#)
|
19
|
+
#
|
20
|
+
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#put-publish-intentbase_path
|
5
21
|
def put_intent(base_path, payload)
|
6
22
|
put_json(intent_url(base_path), payload)
|
7
23
|
end
|
8
24
|
|
25
|
+
# Delete a publishing intent for a base_path.
|
26
|
+
#
|
27
|
+
# @param base_path [String]
|
28
|
+
#
|
29
|
+
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#delete-publish-intentbase_path
|
9
30
|
def destroy_intent(base_path)
|
10
31
|
delete_json(intent_url(base_path))
|
11
32
|
rescue GdsApi::HTTPNotFound => e
|
@@ -161,24 +161,24 @@ module GdsApi
|
|
161
161
|
.to_return(status: 404)
|
162
162
|
end
|
163
163
|
|
164
|
-
def stub_email_alert_api_creates_a_subscription(
|
164
|
+
def stub_email_alert_api_creates_a_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
|
165
165
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
166
166
|
.with(
|
167
|
-
body: {
|
167
|
+
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json
|
168
168
|
).to_return(status: 201, body: { subscription_id: returned_subscription_id }.to_json)
|
169
169
|
end
|
170
170
|
|
171
|
-
def stub_email_alert_api_creates_an_existing_subscription(
|
171
|
+
def stub_email_alert_api_creates_an_existing_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
|
172
172
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
173
173
|
.with(
|
174
|
-
body: {
|
174
|
+
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json
|
175
175
|
).to_return(status: 200, body: { subscription_id: returned_subscription_id }.to_json)
|
176
176
|
end
|
177
177
|
|
178
|
-
def stub_email_alert_api_refuses_to_create_subscription(
|
178
|
+
def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, address, frequency)
|
179
179
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
180
180
|
.with(
|
181
|
-
body: {
|
181
|
+
body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json
|
182
182
|
).to_return(status: 422)
|
183
183
|
end
|
184
184
|
|
@@ -194,28 +194,28 @@ module GdsApi
|
|
194
194
|
assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/unsubscribe/#{uuid}", times: 1)
|
195
195
|
end
|
196
196
|
|
197
|
-
def assert_subscribed(
|
197
|
+
def assert_subscribed(subscriber_list_id, address, frequency = "immediately")
|
198
198
|
assert_requested(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions") do |req|
|
199
199
|
JSON.parse(req.body).symbolize_keys == {
|
200
|
-
|
200
|
+
subscriber_list_id: subscriber_list_id,
|
201
201
|
address: address,
|
202
202
|
frequency: frequency
|
203
203
|
}
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
def
|
208
|
-
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/
|
207
|
+
def stub_email_alert_api_has_subscriber_list_by_slug(slug:, returned_attributes:)
|
208
|
+
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
|
209
209
|
.to_return(
|
210
210
|
status: 200,
|
211
211
|
body: {
|
212
|
-
|
212
|
+
subscriber_list: returned_attributes
|
213
213
|
}.to_json
|
214
214
|
)
|
215
215
|
end
|
216
216
|
|
217
|
-
def
|
218
|
-
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/
|
217
|
+
def stub_email_alert_api_does_not_have_subscriber_list_by_slug(slug:)
|
218
|
+
stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriber-lists/#{slug}")
|
219
219
|
.to_return(status: 404)
|
220
220
|
end
|
221
221
|
|
@@ -243,8 +243,8 @@ module GdsApi
|
|
243
243
|
alias_method :email_alert_api_creates_an_existing_subscription, :stub_email_alert_api_creates_an_existing_subscription
|
244
244
|
alias_method :email_alert_api_refuses_to_create_subscription, :stub_email_alert_api_refuses_to_create_subscription
|
245
245
|
alias_method :email_alert_api_creates_an_auth_token, :stub_email_alert_api_creates_an_auth_token
|
246
|
-
alias_method :
|
247
|
-
alias_method :
|
246
|
+
alias_method :email_alert_api_has_subscriber_list_by_slug, :stub_email_alert_api_has_subscriber_list_by_slug
|
247
|
+
alias_method :email_alert_api_does_not_have_subscriber_list_by_slug, :stub_email_alert_api_does_not_have_subscriber_list_by_slug
|
248
248
|
|
249
249
|
private
|
250
250
|
|
data/lib/gds_api/version.rb
CHANGED
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:
|
4
|
+
version: 58.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-03-
|
11
|
+
date: 2019-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|