gds-api-adapters 67.1.0 → 68.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef6c438b86f67140c5ae9eac92199cdc2b27075f1254a5d79e9a5194b5e9635b
|
4
|
+
data.tar.gz: fe7ce293b7cb055a2e8fcd4c3329b8ebad0603c8abf6e2a069360e135472fdcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 771aed019f50cfbc823162f4bb1e01ff1e4467e5e4e82ee83279d786b38abb08609f398043a7c256ce99f733eda0f9ee5dbbeefbc9f2ef1049940ff947edc61b
|
7
|
+
data.tar.gz: '08196c965b433108c59b16cb462e75ab9f4f94911eb4f618dff94354c8fab5ac095c64e7a5d3fba50f9383fe5a02494b180446356e5d6f59afe7ddfba54c5d54'
|
@@ -24,7 +24,6 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
24
24
|
document_type = attributes["document_type"]
|
25
25
|
email_document_supertype = attributes["email_document_supertype"]
|
26
26
|
government_document_supertype = attributes["government_document_supertype"]
|
27
|
-
gov_delivery_id = attributes["gov_delivery_id"]
|
28
27
|
combine_mode = attributes["combine_mode"]
|
29
28
|
|
30
29
|
if tags && links
|
@@ -38,7 +37,6 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
38
37
|
params[:document_type] = document_type if document_type
|
39
38
|
params[:email_document_supertype] = email_document_supertype if email_document_supertype
|
40
39
|
params[:government_document_supertype] = government_document_supertype if government_document_supertype
|
41
|
-
params[:gov_delivery_id] = gov_delivery_id if gov_delivery_id
|
42
40
|
params[:combine_mode] = combine_mode if combine_mode
|
43
41
|
|
44
42
|
query_string = nested_query_string(params)
|
@@ -66,13 +64,6 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
66
64
|
post_json("#{endpoint}/messages", message, headers)
|
67
65
|
end
|
68
66
|
|
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)
|
74
|
-
end
|
75
|
-
|
76
67
|
# Unpublishing alert
|
77
68
|
#
|
78
69
|
# @param message [Hash] content_id
|
@@ -116,12 +107,13 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
116
107
|
# Subscribe
|
117
108
|
#
|
118
109
|
# @return [Hash] subscription_id
|
119
|
-
def subscribe(subscriber_list_id:, address:, frequency: "immediately")
|
110
|
+
def subscribe(subscriber_list_id:, address:, frequency: "immediately", skip_confirmation_email: false)
|
120
111
|
post_json(
|
121
112
|
"#{endpoint}/subscriptions",
|
122
113
|
subscriber_list_id: subscriber_list_id,
|
123
114
|
address: address,
|
124
115
|
frequency: frequency,
|
116
|
+
skip_confirmation_email: skip_confirmation_email,
|
125
117
|
)
|
126
118
|
end
|
127
119
|
|
@@ -130,7 +122,6 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
130
122
|
# @return [Hash] subscriber_list: {
|
131
123
|
# id
|
132
124
|
# title
|
133
|
-
# gov_delivery_id
|
134
125
|
# created_at
|
135
126
|
# updated_at
|
136
127
|
# document_type
|
data/lib/gds_api/exceptions.rb
CHANGED
@@ -40,6 +40,7 @@ module GdsApi
|
|
40
40
|
class HTTPForbidden < HTTPClientError; end
|
41
41
|
class HTTPConflict < HTTPClientError; end
|
42
42
|
class HTTPUnprocessableEntity < HTTPClientError; end
|
43
|
+
class HTTPBadRequest < HTTPClientError; end
|
43
44
|
class HTTPTooManyRequests < HTTPIntermittentClientError; end
|
44
45
|
|
45
46
|
# Superclass & fallback for all 5XX errors
|
@@ -60,6 +61,8 @@ module GdsApi
|
|
60
61
|
|
61
62
|
def error_class_for_code(code)
|
62
63
|
case code
|
64
|
+
when 400
|
65
|
+
GdsApi::HTTPBadRequest
|
63
66
|
when 401
|
64
67
|
GdsApi::HTTPUnauthorized
|
65
68
|
when 403
|
@@ -12,6 +12,9 @@ module GdsApi
|
|
12
12
|
def publish(options)
|
13
13
|
logger.info("Publishing #{options.fetch(:type)} route #{options.fetch(:base_path)}, routing to #{options.fetch(:rendering_app)}")
|
14
14
|
|
15
|
+
update_type = options.fetch(:update_type, "major")
|
16
|
+
locale = options.fetch(:locale, "en")
|
17
|
+
|
15
18
|
put_content_response = publishing_api.put_content(
|
16
19
|
options.fetch(:content_id),
|
17
20
|
base_path: options.fetch(:base_path),
|
@@ -19,7 +22,7 @@ module GdsApi
|
|
19
22
|
schema_name: options.fetch(:schema_name, "special_route"),
|
20
23
|
title: options.fetch(:title),
|
21
24
|
description: options.fetch(:description, ""),
|
22
|
-
locale:
|
25
|
+
locale: locale,
|
23
26
|
details: {},
|
24
27
|
routes: [
|
25
28
|
{
|
@@ -30,11 +33,11 @@ module GdsApi
|
|
30
33
|
publishing_app: options.fetch(:publishing_app),
|
31
34
|
rendering_app: options.fetch(:rendering_app),
|
32
35
|
public_updated_at: time.now.iso8601,
|
33
|
-
update_type:
|
36
|
+
update_type: update_type,
|
34
37
|
)
|
35
38
|
|
36
39
|
publishing_api.patch_links(options.fetch(:content_id), links: options[:links]) if options[:links]
|
37
|
-
publishing_api.publish(options.fetch(:content_id))
|
40
|
+
publishing_api.publish(options.fetch(:content_id), update_type, locale: locale)
|
38
41
|
put_content_response
|
39
42
|
end
|
40
43
|
|
@@ -218,24 +218,41 @@ module GdsApi
|
|
218
218
|
.to_return(status: 404)
|
219
219
|
end
|
220
220
|
|
221
|
-
def stub_email_alert_api_creates_a_subscription(
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
221
|
+
def stub_email_alert_api_creates_a_subscription(
|
222
|
+
subscriber_list_id: nil,
|
223
|
+
address: nil,
|
224
|
+
frequency: nil,
|
225
|
+
returned_subscription_id: nil,
|
226
|
+
skip_confirmation_email: false,
|
227
|
+
subscriber_id: nil
|
228
|
+
)
|
229
|
+
response = get_subscription_response(
|
230
|
+
returned_subscription_id,
|
231
|
+
frequency: frequency,
|
232
|
+
subscriber_list_id: subscriber_list_id,
|
233
|
+
subscriber_id: subscriber_id,
|
234
|
+
)
|
235
|
+
|
236
|
+
request_params = {
|
237
|
+
subscriber_list_id: subscriber_list_id,
|
238
|
+
address: address,
|
239
|
+
frequency: frequency,
|
240
|
+
skip_confirmation_email: skip_confirmation_email,
|
241
|
+
}
|
227
242
|
|
228
|
-
def stub_email_alert_api_creates_an_existing_subscription(subscriber_list_id, address, frequency, returned_subscription_id)
|
229
243
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
230
|
-
.with(
|
231
|
-
|
232
|
-
).to_return(status: 200, body: { subscription_id: returned_subscription_id }.to_json)
|
244
|
+
.with(body: hash_including(request_params.compact))
|
245
|
+
.to_return(status: 200, body: response.to_json)
|
233
246
|
end
|
234
247
|
|
235
248
|
def stub_email_alert_api_refuses_to_create_subscription(subscriber_list_id, address, frequency)
|
236
249
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
|
237
250
|
.with(
|
238
|
-
body:
|
251
|
+
body: hash_including(
|
252
|
+
subscriber_list_id: subscriber_list_id,
|
253
|
+
address: address,
|
254
|
+
frequency: frequency,
|
255
|
+
),
|
239
256
|
).to_return(status: 422)
|
240
257
|
end
|
241
258
|
|
@@ -381,7 +398,6 @@ module GdsApi
|
|
381
398
|
document_type = attributes["document_type"]
|
382
399
|
email_document_supertype = attributes["email_document_supertype"]
|
383
400
|
government_document_supertype = attributes["government_document_supertype"]
|
384
|
-
gov_delivery_id = attributes["gov_delivery_id"]
|
385
401
|
content_purpose_supergroup = attributes["content_purpose_supergroup"]
|
386
402
|
combine_mode = attributes["combine_mode"]
|
387
403
|
|
@@ -391,7 +407,6 @@ module GdsApi
|
|
391
407
|
params[:document_type] = document_type if document_type
|
392
408
|
params[:email_document_supertype] = email_document_supertype if email_document_supertype
|
393
409
|
params[:government_document_supertype] = government_document_supertype if government_document_supertype
|
394
|
-
params[:gov_delivery_id] = gov_delivery_id if gov_delivery_id
|
395
410
|
params[:content_purpose_supergroup] = content_purpose_supergroup if content_purpose_supergroup
|
396
411
|
params[:combine_mode] = combine_mode if combine_mode
|
397
412
|
|
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: 68.1.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:
|
11
|
+
date: 2021-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|