gds-api-adapters 67.1.0 → 68.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa2f8e5ae181c47883077132c2fb3a4910d28567860c2466f594ebf0d5aaa305
4
- data.tar.gz: 1f5c76190d01dea3f9d7772bd613e7b05f532e2a1df4eaed2987df335ac707e6
3
+ metadata.gz: ef6c438b86f67140c5ae9eac92199cdc2b27075f1254a5d79e9a5194b5e9635b
4
+ data.tar.gz: fe7ce293b7cb055a2e8fcd4c3329b8ebad0603c8abf6e2a069360e135472fdcf
5
5
  SHA512:
6
- metadata.gz: d86be0927061f0fe19b6da7333dcdbba7ab1f54411a6c6bfbbe59f7bbc9a6b6c469609e3ecd597c5c2d41798170f114f14396791b980a7c26968e45fcb975913
7
- data.tar.gz: fb2556343854773fec59ce8e02341263cfb5829bdd18223c65381035274b6554aeb431fc12e98a0483c1608879c272bead25f58f97ce29d540a33c17b3631905
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
@@ -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: "en",
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: options.fetch(:update_type, "major"),
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(subscriber_list_id, address, frequency, returned_subscription_id)
222
- stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions")
223
- .with(
224
- body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
225
- ).to_return(status: 201, body: { subscription_id: returned_subscription_id }.to_json)
226
- end
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
- body: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
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: { subscriber_list_id: subscriber_list_id, address: address, frequency: frequency }.to_json,
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
 
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "67.1.0".freeze
2
+ VERSION = "68.1.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: 67.1.0
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: 2020-12-08 00:00:00.000000000 Z
11
+ date: 2021-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable