gds-api-adapters 68.1.0 → 69.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/asset_manager.rb +9 -10
- data/lib/gds_api/email_alert_api.rb +6 -41
- data/lib/gds_api/mapit.rb +4 -0
- data/lib/gds_api/test_helpers/email_alert_api.rb +8 -13
- data/lib/gds_api/test_helpers/local_links_manager.rb +11 -3
- data/lib/gds_api/test_helpers/mapit.rb +14 -0
- 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: 36d53c764d0ec5abb1685e55ff91057da30c9ce250dd46c4d5ae350b7684f66c
|
4
|
+
data.tar.gz: 50687996dcb29b5ca7d8e0ec5cc3fca4ef40228ea2700d901528b9b2f98b30c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c5cb0ce0c5bd0147374a6abff9a1e121ce811775b5120c73fc319df47aebd8c4acdbe264f3507be9e91b19e0a01e55e0711e9538237c940ad96f9de9ce9b08e
|
7
|
+
data.tar.gz: 6584391dac6990ab4adeedc04491a1a9dec7f7ced21e8adc0da65e7c7fcea2bb242ac56e194e8b6572039a9917b9c7b78601899e822b101ba89f294fbb3a7d34
|
@@ -7,12 +7,13 @@ class GdsApi::AssetManager < GdsApi::Base
|
|
7
7
|
#
|
8
8
|
# Makes a +POST+ request to the asset manager api to create an asset.
|
9
9
|
#
|
10
|
-
# The asset must be provided as a +Hash+ with a
|
10
|
+
# The asset must be provided as a +Hash+ with a +file+ attribute that
|
11
11
|
# behaves like a +File+ object. The +content-type+ that the asset manager will
|
12
|
-
# subsequently serve will be based
|
13
|
-
#
|
12
|
+
# subsequently serve will be based on the file's extension (derived from
|
13
|
+
# +#path+). If you supply a +content-type+ via, for example
|
14
14
|
# +ActionDispatch::Http::UploadedFile+ or another multipart wrapper, it will
|
15
|
-
# be ignored.
|
15
|
+
# be ignored. To provide a +content-type+ directly you must be specify it
|
16
|
+
# as a +content_type+ attribute of the hash.
|
16
17
|
#
|
17
18
|
# @param asset [Hash] The attributes for the asset to send to the api. Must
|
18
19
|
# contain +file+, which behaves like a +File+. All other attributes will be
|
@@ -143,12 +144,10 @@ class GdsApi::AssetManager < GdsApi::Base
|
|
143
144
|
#
|
144
145
|
# Makes a +PUT+ request to the asset manager api to update an asset.
|
145
146
|
#
|
146
|
-
# The asset must be provided as a +Hash+ with a
|
147
|
-
# behaves like a +File+ object. The +content-type+
|
148
|
-
#
|
149
|
-
#
|
150
|
-
# +ActionDispatch::Http::UploadedFile+ or another multipart wrapper, it will
|
151
|
-
# be ignored.
|
147
|
+
# The asset must be provided as a +Hash+ with a +file+ attribute that
|
148
|
+
# behaves like a +File+ object. The +content-type+ of the file will be based
|
149
|
+
# on the files extension unless you specify a +content_type+ attribute of
|
150
|
+
# the hash to set it.
|
152
151
|
#
|
153
152
|
# @param id [String] The asset identifier (a UUID).
|
154
153
|
# @param asset [Hash] The attributes for the asset to send to the api. Must
|
@@ -10,44 +10,20 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
10
10
|
#
|
11
11
|
# @param attributes [Hash] document_type, links, tags used to search existing subscriber lists
|
12
12
|
def find_or_create_subscriber_list(attributes)
|
13
|
-
|
14
|
-
rescue GdsApi::HTTPNotFound
|
15
|
-
create_subscriber_list(attributes)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Get a subscriber list
|
19
|
-
#
|
20
|
-
# @param attributes [Hash] document_type, links, tags used to search existing subscriber lists
|
21
|
-
def find_subscriber_list(attributes)
|
22
|
-
tags = attributes["tags"]
|
23
|
-
links = attributes["links"]
|
24
|
-
document_type = attributes["document_type"]
|
25
|
-
email_document_supertype = attributes["email_document_supertype"]
|
26
|
-
government_document_supertype = attributes["government_document_supertype"]
|
27
|
-
combine_mode = attributes["combine_mode"]
|
28
|
-
|
29
|
-
if tags && links
|
13
|
+
if attributes["tags"] && attributes["links"]
|
30
14
|
message = "please provide either tags or links (or neither), but not both"
|
31
15
|
raise ArgumentError, message
|
32
16
|
end
|
33
17
|
|
34
|
-
|
35
|
-
params[:tags] = tags if tags
|
36
|
-
params[:links] = links if links
|
37
|
-
params[:document_type] = document_type if document_type
|
38
|
-
params[:email_document_supertype] = email_document_supertype if email_document_supertype
|
39
|
-
params[:government_document_supertype] = government_document_supertype if government_document_supertype
|
40
|
-
params[:combine_mode] = combine_mode if combine_mode
|
41
|
-
|
42
|
-
query_string = nested_query_string(params)
|
43
|
-
get_json("#{endpoint}/subscriber-lists?" + query_string)
|
18
|
+
post_json("#{endpoint}/subscriber-lists", attributes)
|
44
19
|
end
|
45
20
|
|
46
|
-
#
|
21
|
+
# Get a subscriber list
|
47
22
|
#
|
48
23
|
# @param attributes [Hash] document_type, links, tags used to search existing subscriber lists
|
49
|
-
def
|
50
|
-
|
24
|
+
def find_subscriber_list(attributes)
|
25
|
+
query_string = nested_query_string(attributes)
|
26
|
+
get_json("#{endpoint}/subscriber-lists?" + query_string)
|
51
27
|
end
|
52
28
|
|
53
29
|
# Post a content change
|
@@ -64,17 +40,6 @@ class GdsApi::EmailAlertApi < GdsApi::Base
|
|
64
40
|
post_json("#{endpoint}/messages", message, headers)
|
65
41
|
end
|
66
42
|
|
67
|
-
# Unpublishing alert
|
68
|
-
#
|
69
|
-
# @param message [Hash] content_id
|
70
|
-
#
|
71
|
-
# Used by email-alert-service to send a message to email-alert-api
|
72
|
-
# when an unpublishing message is put on the Rabbitmq queue by
|
73
|
-
# publishing-api
|
74
|
-
def send_unpublish_message(message)
|
75
|
-
post_json("#{endpoint}/unpublish-messages", message)
|
76
|
-
end
|
77
|
-
|
78
43
|
# Get topic matches
|
79
44
|
#
|
80
45
|
# @param attributes [Hash] tags, links, document_type,
|
data/lib/gds_api/mapit.rb
CHANGED
@@ -124,6 +124,14 @@ module GdsApi
|
|
124
124
|
matching.last
|
125
125
|
end
|
126
126
|
|
127
|
+
def stub_email_alert_api_creates_subscriber_list(attributes)
|
128
|
+
stub_request(:post, build_subscriber_lists_url)
|
129
|
+
.to_return(
|
130
|
+
status: 201,
|
131
|
+
body: get_subscriber_list_response(attributes).to_json,
|
132
|
+
)
|
133
|
+
end
|
134
|
+
|
127
135
|
def stub_email_alert_api_has_subscriber_list(attributes)
|
128
136
|
stub_request(:get, build_subscriber_lists_url(attributes))
|
129
137
|
.to_return(
|
@@ -137,24 +145,11 @@ module GdsApi
|
|
137
145
|
.to_return(status: 404)
|
138
146
|
end
|
139
147
|
|
140
|
-
def stub_email_alert_api_creates_subscriber_list(attributes)
|
141
|
-
stub_request(:post, build_subscriber_lists_url)
|
142
|
-
.to_return(
|
143
|
-
status: 201,
|
144
|
-
body: get_subscriber_list_response(attributes).to_json,
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
148
|
def stub_email_alert_api_refuses_to_create_subscriber_list
|
149
149
|
stub_request(:post, build_subscriber_lists_url)
|
150
150
|
.to_return(status: 422)
|
151
151
|
end
|
152
152
|
|
153
|
-
def stub_email_alert_api_accepts_unpublishing_message
|
154
|
-
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/unpublish-messages")
|
155
|
-
.to_return(status: 202, body: {}.to_json)
|
156
|
-
end
|
157
|
-
|
158
153
|
def stub_email_alert_api_accepts_content_change
|
159
154
|
stub_request(:post, "#{EMAIL_ALERT_API_ENDPOINT}/content-changes")
|
160
155
|
.to_return(status: 202, body: {}.to_json)
|
@@ -5,18 +5,20 @@ 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", status: "ok")
|
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,
|
18
19
|
"lgil_code" => lgil,
|
19
20
|
"url" => url,
|
21
|
+
"status" => status,
|
20
22
|
},
|
21
23
|
}
|
22
24
|
|
@@ -25,13 +27,14 @@ module GdsApi
|
|
25
27
|
.to_return(body: response.to_json, status: 200)
|
26
28
|
end
|
27
29
|
|
28
|
-
def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:)
|
30
|
+
def stub_local_links_manager_has_no_link(authority_slug:, lgsl:, lgil:, country_name: "England")
|
29
31
|
response = {
|
30
32
|
"local_authority" => {
|
31
33
|
"name" => authority_slug.capitalize,
|
32
34
|
"snac" => "00AG",
|
33
35
|
"tier" => "unitary",
|
34
36
|
"homepage_url" => "http://#{authority_slug}.example.com",
|
37
|
+
"country_name" => country_name,
|
35
38
|
},
|
36
39
|
}
|
37
40
|
|
@@ -40,13 +43,14 @@ module GdsApi
|
|
40
43
|
.to_return(body: response.to_json, status: 200)
|
41
44
|
end
|
42
45
|
|
43
|
-
def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:)
|
46
|
+
def stub_local_links_manager_has_no_link_and_no_homepage_url(authority_slug:, lgsl:, lgil:, country_name: "England")
|
44
47
|
response = {
|
45
48
|
"local_authority" => {
|
46
49
|
"name" => authority_slug.capitalize,
|
47
50
|
"snac" => "00AG",
|
48
51
|
"tier" => "unitary",
|
49
52
|
"homepage_url" => nil,
|
53
|
+
"country_name" => country_name,
|
50
54
|
},
|
51
55
|
}
|
52
56
|
|
@@ -82,6 +86,7 @@ module GdsApi
|
|
82
86
|
{
|
83
87
|
"name" => authority_slug.capitalize,
|
84
88
|
"homepage_url" => "http://#{authority_slug}.example.com",
|
89
|
+
"country_name" => "England",
|
85
90
|
"tier" => "unitary",
|
86
91
|
},
|
87
92
|
],
|
@@ -98,11 +103,13 @@ module GdsApi
|
|
98
103
|
{
|
99
104
|
"name" => district_slug.capitalize,
|
100
105
|
"homepage_url" => "http://#{district_slug}.example.com",
|
106
|
+
"country_name" => "England",
|
101
107
|
"tier" => "district",
|
102
108
|
},
|
103
109
|
{
|
104
110
|
"name" => county_slug.capitalize,
|
105
111
|
"homepage_url" => "http://#{county_slug}.example.com",
|
112
|
+
"country_name" => "England",
|
106
113
|
"tier" => "county",
|
107
114
|
},
|
108
115
|
],
|
@@ -131,6 +138,7 @@ module GdsApi
|
|
131
138
|
{
|
132
139
|
"name" => authority_slug.capitalize,
|
133
140
|
"homepage_url" => "",
|
141
|
+
"country_name" => "England",
|
134
142
|
"tier" => "unitary",
|
135
143
|
},
|
136
144
|
],
|
@@ -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)
|
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: 69.3.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: 2021-01-
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|