gds-api-adapters 59.0.0 → 59.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 +4 -4
- data/Rakefile +1 -1
- data/lib/gds_api/base.rb +1 -0
- data/lib/gds_api/content_store.rb +1 -0
- data/lib/gds_api/imminence.rb +1 -1
- data/lib/gds_api/json_client.rb +6 -6
- data/lib/gds_api/licence_application.rb +1 -0
- data/lib/gds_api/rummager.rb +3 -0
- data/lib/gds_api/support_api.rb +2 -3
- data/lib/gds_api/test_helpers/content_item_helpers.rb +0 -1
- data/lib/gds_api/test_helpers/organisations.rb +2 -1
- data/lib/gds_api/test_helpers/publishing_api.rb +2 -0
- data/lib/gds_api/test_helpers/publishing_api_v2.rb +1 -0
- data/lib/gds_api/test_helpers/router.rb +25 -19
- data/lib/gds_api/test_helpers/rummager.rb +11 -10
- data/lib/gds_api/test_helpers/support_api.rb +3 -3
- data/lib/gds_api/test_helpers/worldwide.rb +3 -2
- data/lib/gds_api/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5545c2f65d5f31f2aaf737590b5204ee385ec783ad553d09515ac0b7e3d73929
|
4
|
+
data.tar.gz: 850f74dc5f709157bad18d79308edd76ae3323b8e33d867ebfda9f075eb82b65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce46e8885c9e7b37cffa51ff0a3666270e825ccc073c17659d23d85ed15598f190eb8b016f599aec26275c829062106e3d7500b76f74a0b88bfa194d76568901
|
7
|
+
data.tar.gz: af840ab6b6d7053d2e746bdfe64fc5a00daeba7105d7bbabf771ba54c74e539579cd95d3de2131936d06113063865644f096a858cd4a0ca352e270f9f6791721
|
data/Rakefile
CHANGED
data/lib/gds_api/base.rb
CHANGED
@@ -41,6 +41,7 @@ class GdsApi::Base
|
|
41
41
|
def initialize(endpoint_url, options = {})
|
42
42
|
options[:endpoint_url] = endpoint_url
|
43
43
|
raise InvalidAPIURL unless endpoint_url =~ URI::RFC3986_Parser::RFC3986_URI
|
44
|
+
|
44
45
|
base_options = { logger: GdsApi::Base.logger }
|
45
46
|
default_options = base_options.merge(GdsApi::Base.default_options || {})
|
46
47
|
@options = default_options.merge(options)
|
data/lib/gds_api/imminence.rb
CHANGED
@@ -3,7 +3,7 @@ require_relative 'base'
|
|
3
3
|
class GdsApi::Imminence < GdsApi::Base
|
4
4
|
def api_url(type, params)
|
5
5
|
vals = %i[limit lat lng postcode].select { |p| params.include? p }
|
6
|
-
querystring = URI.encode_www_form
|
6
|
+
querystring = URI.encode_www_form(vals.map { |p| [p, params[p]] })
|
7
7
|
"#{@endpoint}/places/#{type}.json?#{querystring}"
|
8
8
|
end
|
9
9
|
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -12,7 +12,7 @@ module GdsApi
|
|
12
12
|
attr_accessor :logger, :options
|
13
13
|
|
14
14
|
def initialize(options = {})
|
15
|
-
if options[:disable_timeout] || options[:timeout].to_i
|
15
|
+
if options[:disable_timeout] || options[:timeout].to_i.negative?
|
16
16
|
raise "It is no longer possible to disable the timeout."
|
17
17
|
end
|
18
18
|
|
@@ -101,10 +101,10 @@ module GdsApi
|
|
101
101
|
rescue RestClient::Exception => e
|
102
102
|
# Attempt to parse the body as JSON if possible
|
103
103
|
error_details = begin
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
e.http_body ? JSON.parse(e.http_body) : nil
|
105
|
+
rescue JSON::ParserError
|
106
|
+
nil
|
107
|
+
end
|
108
108
|
raise build_specific_http_error(e, url, error_details, params)
|
109
109
|
end
|
110
110
|
|
@@ -174,7 +174,7 @@ module GdsApi
|
|
174
174
|
method_params = with_ssl_options(method_params)
|
175
175
|
end
|
176
176
|
|
177
|
-
|
177
|
+
::RestClient::Request.execute(method_params)
|
178
178
|
rescue Errno::ECONNREFUSED => e
|
179
179
|
logger.error loggable.merge(status: 'refused', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
180
180
|
raise GdsApi::EndpointNotFound.new("Could not connect to #{url}")
|
data/lib/gds_api/rummager.rb
CHANGED
@@ -31,6 +31,7 @@ module GdsApi
|
|
31
31
|
|
32
32
|
def add_document(id, document, index_name)
|
33
33
|
raise(InvalidIndex, index_name) unless index_name == 'metasearch'
|
34
|
+
|
34
35
|
post_json(
|
35
36
|
"#{base_url}/v2/metasearch/documents",
|
36
37
|
document.merge(
|
@@ -41,6 +42,7 @@ module GdsApi
|
|
41
42
|
|
42
43
|
def delete_document(id, index_name)
|
43
44
|
raise(InvalidIndex, index_name) unless index_name == 'metasearch'
|
45
|
+
|
44
46
|
delete_json("#{base_url}/v2/metasearch/documents/#{id}")
|
45
47
|
end
|
46
48
|
end
|
@@ -114,6 +116,7 @@ module GdsApi
|
|
114
116
|
# @deprecated Only in use by Whitehall. Use the `#search` method.
|
115
117
|
def advanced_search(args)
|
116
118
|
raise ArgumentError.new("Args cannot be blank") if args.nil? || args.empty?
|
119
|
+
|
117
120
|
request_path = "#{base_url}/advanced_search?#{Rack::Utils.build_nested_query(args)}"
|
118
121
|
get_json(request_path)
|
119
122
|
end
|
data/lib/gds_api/support_api.rb
CHANGED
@@ -51,9 +51,8 @@ class GdsApi::SupportApi < GdsApi::Base
|
|
51
51
|
post_json("#{endpoint}/anonymous-feedback/content_improvement", params)
|
52
52
|
end
|
53
53
|
|
54
|
-
def anonymous_feedback(
|
55
|
-
|
56
|
-
get_json(uri)
|
54
|
+
def anonymous_feedback(params = {})
|
55
|
+
post_json("#{endpoint}/anonymous-feedback", params)
|
57
56
|
end
|
58
57
|
|
59
58
|
def organisation_summary(organisation_slug, options = {})
|
@@ -52,7 +52,8 @@ module GdsApi
|
|
52
52
|
|
53
53
|
stub_request(:get, links[:self]).
|
54
54
|
to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
55
|
-
|
55
|
+
|
56
|
+
if i.zero?
|
56
57
|
# First page exists at URL with and without page param
|
57
58
|
stub_request(:get, links[:self].sub(/\?page=1/, '')).
|
58
59
|
to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
@@ -123,6 +123,7 @@ module GdsApi
|
|
123
123
|
case expected_value
|
124
124
|
when Hash
|
125
125
|
return false unless actual_value.is_a?(Hash)
|
126
|
+
|
126
127
|
expected_value.all? do |expected_sub_key, expected_sub_value|
|
127
128
|
actual_value.has_key?(expected_sub_key.to_s) &&
|
128
129
|
values_match_recursively(expected_sub_value, actual_value[expected_sub_key.to_s])
|
@@ -130,6 +131,7 @@ module GdsApi
|
|
130
131
|
when Array
|
131
132
|
return false unless actual_value.is_a?(Array)
|
132
133
|
return false unless actual_value.size == expected_value.size
|
134
|
+
|
133
135
|
expected_value.each.with_index.all? do |expected_sub_value, i|
|
134
136
|
values_match_recursively(expected_sub_value, actual_value[i])
|
135
137
|
end
|
@@ -43,12 +43,14 @@ module GdsApi
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def stub_route_registration(path, type, backend_id)
|
46
|
-
route = {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
route = {
|
47
|
+
route: {
|
48
|
+
incoming_path: path,
|
49
|
+
route_type: type,
|
50
|
+
handler: 'backend',
|
51
|
+
backend_id: backend_id
|
52
|
+
}
|
53
|
+
}
|
52
54
|
|
53
55
|
register_stub = stub_route_put(route)
|
54
56
|
commit_stub = stub_router_commit
|
@@ -56,14 +58,16 @@ module GdsApi
|
|
56
58
|
end
|
57
59
|
|
58
60
|
def stub_redirect_registration(path, type, destination, redirect_type, segments_mode = nil)
|
59
|
-
redirect = {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
61
|
+
redirect = {
|
62
|
+
route: {
|
63
|
+
incoming_path: path,
|
64
|
+
route_type: type,
|
65
|
+
handler: 'redirect',
|
66
|
+
redirect_to: destination,
|
67
|
+
redirect_type: redirect_type,
|
68
|
+
segments_mode: segments_mode,
|
69
|
+
}
|
70
|
+
}
|
67
71
|
|
68
72
|
register_stub = stub_route_put(redirect)
|
69
73
|
commit_stub = stub_router_commit
|
@@ -71,11 +75,13 @@ module GdsApi
|
|
71
75
|
end
|
72
76
|
|
73
77
|
def stub_gone_route_registration(path, type)
|
74
|
-
route = {
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
route = {
|
79
|
+
route: {
|
80
|
+
incoming_path: path,
|
81
|
+
route_type: type,
|
82
|
+
handler: 'gone',
|
83
|
+
}
|
84
|
+
}
|
79
85
|
|
80
86
|
register_stub = stub_route_put(route)
|
81
87
|
commit_stub = stub_router_commit
|
@@ -60,6 +60,7 @@ module GdsApi
|
|
60
60
|
if id =~ %r{^/}
|
61
61
|
raise ArgumentError, 'Rummager id must not start with a slash'
|
62
62
|
end
|
63
|
+
|
63
64
|
if index
|
64
65
|
assert_requested(
|
65
66
|
:delete,
|
@@ -133,8 +134,8 @@ module GdsApi
|
|
133
134
|
def search_results_found
|
134
135
|
File.read(
|
135
136
|
File.expand_path(
|
136
|
-
"
|
137
|
-
|
137
|
+
"../../../test/fixtures/services_and_info_fixture.json",
|
138
|
+
__dir__
|
138
139
|
)
|
139
140
|
)
|
140
141
|
end
|
@@ -142,8 +143,8 @@ module GdsApi
|
|
142
143
|
def no_search_results_found
|
143
144
|
File.read(
|
144
145
|
File.expand_path(
|
145
|
-
"
|
146
|
-
|
146
|
+
"../../../test/fixtures/no_services_and_info_data_found_fixture.json",
|
147
|
+
__dir__
|
147
148
|
)
|
148
149
|
)
|
149
150
|
end
|
@@ -151,8 +152,8 @@ module GdsApi
|
|
151
152
|
def sub_sector_organisations_results
|
152
153
|
File.read(
|
153
154
|
File.expand_path(
|
154
|
-
"
|
155
|
-
|
155
|
+
"../../../test/fixtures/sub_sector_organisations.json",
|
156
|
+
__dir__
|
156
157
|
)
|
157
158
|
)
|
158
159
|
end
|
@@ -160,8 +161,8 @@ module GdsApi
|
|
160
161
|
def new_policies_results
|
161
162
|
File.read(
|
162
163
|
File.expand_path(
|
163
|
-
"
|
164
|
-
|
164
|
+
"../../../test/fixtures/new_policies_for_dwp.json",
|
165
|
+
__dir__
|
165
166
|
)
|
166
167
|
)
|
167
168
|
end
|
@@ -169,8 +170,8 @@ module GdsApi
|
|
169
170
|
def old_policies_results
|
170
171
|
File.read(
|
171
172
|
File.expand_path(
|
172
|
-
"
|
173
|
-
|
173
|
+
"../../../test/fixtures/old_policies_for_dwp.json",
|
174
|
+
__dir__
|
174
175
|
)
|
175
176
|
)
|
176
177
|
end
|
@@ -79,9 +79,9 @@ module GdsApi
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def stub_support_api_anonymous_feedback(params, response_body = {})
|
82
|
-
stub_http_request(:
|
83
|
-
with(
|
84
|
-
to_return(status: 200, body: response_body.to_json)
|
82
|
+
stub_http_request(:post, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback")
|
83
|
+
.with(body: params)
|
84
|
+
.to_return(status: 200, body: response_body.to_json)
|
85
85
|
end
|
86
86
|
|
87
87
|
def stub_support_api_anonymous_feedback_organisation_summary(slug, ordering = nil, response_body = {})
|
@@ -30,7 +30,7 @@ module GdsApi
|
|
30
30
|
|
31
31
|
links = { self: "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 1}" }
|
32
32
|
links[:next] = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 2}" if pages[i + 1]
|
33
|
-
links[:previous] = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i}" unless i
|
33
|
+
links[:previous] = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i}" unless i.zero?
|
34
34
|
page_details["_response_info"]["links"] = []
|
35
35
|
link_headers = []
|
36
36
|
links.each do |rel, href|
|
@@ -40,7 +40,8 @@ module GdsApi
|
|
40
40
|
|
41
41
|
stub_request(:get, links[:self]).
|
42
42
|
to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
43
|
-
|
43
|
+
|
44
|
+
if i.zero?
|
44
45
|
# First page exists at URL with and without page param
|
45
46
|
stub_request(:get, links[:self].sub(/\?page=1/, '')).
|
46
47
|
to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
|
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: 59.
|
4
|
+
version: 59.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: 2019-04-
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '3.
|
131
|
+
version: '3.11'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '3.
|
138
|
+
version: '3.11'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: minitest
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|