gds-api-adapters 67.0.1 → 68.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 98cbc4b338641aff5589875074e2fb2d6ef4227a004f04855cfffbf9c0eb5348
4
- data.tar.gz: 5934de7d813457a5cf01c026ff91bed99445492a43df9c9704abc123db140c7d
3
+ metadata.gz: d65f642d5b2a1a78b79cada08224db09ac522eed4c6f2a096916ae076f0c6328
4
+ data.tar.gz: 314f7be8b8aea542036199fae93de9b9c7c7f3e18b1d5234b0872c26c3ae35f8
5
5
  SHA512:
6
- metadata.gz: 00bab1a4b50de5937794758bbdca11c093d3d58c147fed73cb1c3ad89c0c1a9c8d4e2cac2691a31540d9d5c1f92de9a413c25b339a1430dbc367e7f5649afe08
7
- data.tar.gz: 14a690b77a277f543b800d48da87cac0c78e6edaf2ced0e04a5f9244104707b3f3cf34e77f9cba0cd39e3fca0c53a2672659a17b00611d575d28c43bd25d236b
6
+ metadata.gz: 8269a099df5843b9bc45dabad688a59461b9fcb7b50c876b69981ee8fc919db8e318421a9ac478dacff2f4bb0a73e0675589686bfaf878e024f06a17117d351d
7
+ data.tar.gz: 426d5db6c08678e134ecbd84b315f2cb22df30a5fcbcb3e1de89ff980d5edebcd75b229e6cb4ef95c4a7f86c78f3909452246376a7fb5750ec63fcaf1d4d3831
@@ -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)
@@ -116,12 +114,13 @@ class GdsApi::EmailAlertApi < GdsApi::Base
116
114
  # Subscribe
117
115
  #
118
116
  # @return [Hash] subscription_id
119
- def subscribe(subscriber_list_id:, address:, frequency: "immediately")
117
+ def subscribe(subscriber_list_id:, address:, frequency: "immediately", skip_confirmation_email: false)
120
118
  post_json(
121
119
  "#{endpoint}/subscriptions",
122
120
  subscriber_list_id: subscriber_list_id,
123
121
  address: address,
124
122
  frequency: frequency,
123
+ skip_confirmation_email: skip_confirmation_email,
125
124
  )
126
125
  end
127
126
 
@@ -130,7 +129,6 @@ class GdsApi::EmailAlertApi < GdsApi::Base
130
129
  # @return [Hash] subscriber_list: {
131
130
  # id
132
131
  # title
133
- # gov_delivery_id
134
132
  # created_at
135
133
  # updated_at
136
134
  # document_type
@@ -224,16 +222,14 @@ class GdsApi::EmailAlertApi < GdsApi::Base
224
222
  #
225
223
  # @param [string] address Address to send verification email to
226
224
  # @param [string] destination Path on GOV.UK that subscriber will be emailed
227
- # @param [string, nil] redirect Path on GOV.UK to be encoded into the token for redirecting
228
225
  #
229
226
  # @return [Hash] subscriber
230
227
  #
231
- def send_subscriber_verification_email(address:, destination:, redirect: nil)
228
+ def send_subscriber_verification_email(address:, destination:)
232
229
  post_json(
233
230
  "#{endpoint}/subscribers/auth-token",
234
231
  address: address,
235
232
  destination: destination,
236
- redirect: redirect,
237
233
  )
238
234
  end
239
235
 
@@ -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
 
@@ -98,9 +98,9 @@ module GdsApi
98
98
  subscriptions.each do |id, params|
99
99
  latest_id, latest_params = get_latest_matching(params, subscriptions)
100
100
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}")
101
- .to_return(status: 200, body: get_subscription_response(id, params).to_json)
101
+ .to_return(status: 200, body: get_subscription_response(id, **params).to_json)
102
102
  stub_request(:get, "#{EMAIL_ALERT_API_ENDPOINT}/subscriptions/#{id}/latest")
103
- .to_return(status: 200, body: get_subscription_response(latest_id, latest_params).to_json)
103
+ .to_return(status: 200, body: get_subscription_response(latest_id, **latest_params).to_json)
104
104
  end
105
105
  end
106
106
 
@@ -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
 
@@ -394,9 +394,11 @@ module GdsApi
394
394
  # Stub GET /v2/content/:content_id to return a 404 response
395
395
  #
396
396
  # @param content_id [UUID]
397
- def stub_publishing_api_does_not_have_item(content_id)
397
+ def stub_publishing_api_does_not_have_item(content_id, params = {})
398
398
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + content_id
399
- stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
399
+ stub_request(:get, url)
400
+ .with(query: hash_including(params))
401
+ .to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
400
402
  end
401
403
 
402
404
  # Stub a request to links endpoint
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "67.0.1".freeze
2
+ VERSION = "68.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: 67.0.1
4
+ version: 68.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: 2020-07-22 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '2.6'
201
+ version: '3.6'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '2.6'
208
+ version: '3.6'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: pry
211
211
  requirement: !ruby/object:Gem::Requirement
@@ -447,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
447
447
  - !ruby/object:Gem::Version
448
448
  version: '0'
449
449
  requirements: []
450
- rubygems_version: 3.0.3
450
+ rubygems_version: 3.1.4
451
451
  signing_key:
452
452
  specification_version: 4
453
453
  summary: Adapters to work with GDS APIs