gds-api-adapters 67.1.1 → 68.2.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: 19eaf100f2daa9f68ac9bbd4489af46288c472434d22f81735258284e4d55da6
4
- data.tar.gz: 1d8305795bd9f57730e66a1215031e3f9ab41d88c2f84028aea64c2ca02523a7
3
+ metadata.gz: 6ec0fa71b77c5c2e4b44a7738181d36c6089b99b7afdfd5a34696261bdc0152c
4
+ data.tar.gz: 811610b3bdd0bd041886d456536ff40ec6ec1afa304d406df3298c37e4f0cf5a
5
5
  SHA512:
6
- metadata.gz: bec2d56f7974d78cf2b28bb418115d155fe53adf7bc159b778ea9468357a7acc0565604251813434d4bf89fc53d8cc1062f68b18200c17d639888ea619ce46f1
7
- data.tar.gz: f3a25306f8c628715898387c31ab940aa3011462c6243abba9398d5d93cf8829c4c2d8ea795ab78d6bbe51f375c3aef39d6f69d5a6dcf6a40b6b0fa9da6647d2
6
+ metadata.gz: c0199c4107477873935dfd75c2949bdd2e91034d17e9927df1668c6e214a46d84b5bb9b14abfb2898dcdfc2161ee657a9a8615d0d8ae9dd96a782e9c318c1772
7
+ data.tar.gz: 3b108e03797549bcb7dcdb6b14dad018f8ef3e8d4fc4be605a5468cbff7501960be91a1f441628dc9cea88548cef4b37b53f19d17a5eb5c62568187c67d0ad8d
@@ -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
@@ -37,6 +37,10 @@ class GdsApi::Mapit < GdsApi::Base
37
37
  def postcode
38
38
  @response["postcode"]
39
39
  end
40
+
41
+ def country_name
42
+ @response["country_name"]
43
+ end
40
44
  end
41
45
 
42
46
  private
@@ -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: { 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: { 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
 
@@ -5,13 +5,14 @@ module GdsApi
5
5
  module LocalLinksManager
6
6
  LOCAL_LINKS_MANAGER_ENDPOINT = Plek.current.find("local-links-manager")
7
7
 
8
- def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:)
8
+ def stub_local_links_manager_has_a_link(authority_slug:, lgsl:, lgil:, url:, country_name: "England")
9
9
  response = {
10
10
  "local_authority" => {
11
11
  "name" => authority_slug.capitalize,
12
12
  "snac" => "00AG",
13
13
  "tier" => "unitary",
14
14
  "homepage_url" => "http://#{authority_slug}.example.com",
15
+ "country_name" => country_name,
15
16
  },
16
17
  "local_interaction" => {
17
18
  "lgsl_code" => lgsl,
@@ -25,13 +26,14 @@ module GdsApi
25
26
  .to_return(body: response.to_json, status: 200)
26
27
  end
27
28
 
28
- def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:)
29
+ def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England")
29
30
  response = {
30
31
  "local_authority" => {
31
32
  "name" => authority_slug.capitalize,
32
33
  "snac" => "00AG",
33
34
  "tier" => "unitary",
34
35
  "homepage_url" => "http://#{authority_slug}.example.com",
36
+ "country_name" => country_name,
35
37
  },
36
38
  }
37
39
 
@@ -40,13 +42,14 @@ module GdsApi
40
42
  .to_return(body: response.to_json, status: 200)
41
43
  end
42
44
 
43
- def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:)
45
+ def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England")
44
46
  response = {
45
47
  "local_authority" => {
46
48
  "name" => authority_slug.capitalize,
47
49
  "snac" => "00AG",
48
50
  "tier" => "unitary",
49
51
  "homepage_url" => nil,
52
+ "country_name" => country_name,
50
53
  },
51
54
  }
52
55
 
@@ -82,6 +85,7 @@ module GdsApi
82
85
  {
83
86
  "name" => authority_slug.capitalize,
84
87
  "homepage_url" => "http://#{authority_slug}.example.com",
88
+ "country_name" => "England",
85
89
  "tier" => "unitary",
86
90
  },
87
91
  ],
@@ -98,11 +102,13 @@ module GdsApi
98
102
  {
99
103
  "name" => district_slug.capitalize,
100
104
  "homepage_url" => "http://#{district_slug}.example.com",
105
+ "country_name" => "England",
101
106
  "tier" => "district",
102
107
  },
103
108
  {
104
109
  "name" => county_slug.capitalize,
105
110
  "homepage_url" => "http://#{county_slug}.example.com",
111
+ "country_name" => "England",
106
112
  "tier" => "county",
107
113
  },
108
114
  ],
@@ -131,6 +137,7 @@ module GdsApi
131
137
  {
132
138
  "name" => authority_slug.capitalize,
133
139
  "homepage_url" => "",
140
+ "country_name" => "England",
134
141
  "tier" => "unitary",
135
142
  },
136
143
  ],
@@ -43,6 +43,20 @@ module GdsApi
43
43
  .to_return(body: response.to_json, status: 200)
44
44
  end
45
45
 
46
+ def stub_mapit_has_a_postcode_and_country_name(postcode, coords, country_name)
47
+ response = {
48
+ "wgs84_lat" => coords.first,
49
+ "wgs84_lon" => coords.last,
50
+ "postcode" => postcode,
51
+ "country_name" => country_name,
52
+ }
53
+
54
+ stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(" ", "+") + ".json")
55
+ .to_return(body: response.to_json, status: 200)
56
+ stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial/" + postcode.split(" ").first + ".json")
57
+ .to_return(body: response.to_json, status: 200)
58
+ end
59
+
46
60
  def stub_mapit_does_not_have_a_postcode(postcode)
47
61
  stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/" + postcode.tr(" ", "+") + ".json")
48
62
  .to_return(body: { "code" => 404, "error" => "No Postcode matches the given query." }.to_json, status: 404)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "67.1.1".freeze
2
+ VERSION = "68.2.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.1
4
+ version: 68.2.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-09 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable