gds-api-adapters 52.6.0 → 52.7.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/govuk_headers.rb +1 -1
- data/lib/gds_api/imminence.rb +1 -1
- data/lib/gds_api/json_client.rb +0 -5
- data/lib/gds_api/null_cache.rb +2 -4
- data/lib/gds_api/publishing_api.rb +1 -0
- data/lib/gds_api/publishing_api_v2.rb +16 -9
- data/lib/gds_api/response.rb +1 -1
- data/lib/gds_api/router.rb +1 -1
- data/lib/gds_api/test_helpers/mapit.rb +3 -2
- data/lib/gds_api/version.rb +1 -1
- metadata +26 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e8fb67f01e255a264b4c5af3bfc7726d1147caad20049d9ec32f4e87244c754
|
4
|
+
data.tar.gz: 8de0575d7e68cb46dd177a63ab6ab7fdee11238b191f611d38491367fe8a6f4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74cfbd519a7fee3bdbff93ac43dffefcfb26adb3c2dbbc8673b8e13e75a5fb97dd27252063a22fa7d5a140945ed87c3df9d0ec4da5cbb619d3507b5369fe3e9e
|
7
|
+
data.tar.gz: 3664cbb17b43ed08f7d434e2e6d2ecb0cd09b78667b12b9957ffa3b36e8badca38ec905227ee40ef853a3b1bab516683d1b7a150791a69cb23d5ccfb346ce85f
|
data/lib/gds_api/imminence.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative 'base'
|
|
2
2
|
|
3
3
|
class GdsApi::Imminence < GdsApi::Base
|
4
4
|
def api_url(type, params)
|
5
|
-
vals = [
|
5
|
+
vals = %i[limit lat lng postcode].select { |p| params.include? p }
|
6
6
|
querystring = URI.encode_www_form vals.map { |p| [p, params[p]] }
|
7
7
|
"#{@endpoint}/places/#{type}.json?#{querystring}"
|
8
8
|
end
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -259,26 +259,21 @@ module GdsApi
|
|
259
259
|
end
|
260
260
|
|
261
261
|
return ::RestClient::Request.execute(method_params)
|
262
|
-
|
263
262
|
rescue Errno::ECONNREFUSED => e
|
264
263
|
logger.error loggable.merge(status: 'refused', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
265
264
|
raise GdsApi::EndpointNotFound.new("Could not connect to #{url}")
|
266
|
-
|
267
265
|
rescue RestClient::Exceptions::Timeout => e
|
268
266
|
logger.error loggable.merge(status: 'timeout', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
269
267
|
raise GdsApi::TimedOutException.new
|
270
|
-
|
271
268
|
rescue URI::InvalidURIError => e
|
272
269
|
logger.error loggable.merge(status: 'invalid_uri', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
273
270
|
raise GdsApi::InvalidUrl
|
274
|
-
|
275
271
|
rescue RestClient::Exception => e
|
276
272
|
# Log the error here, since we have access to loggable, but raise the
|
277
273
|
# exception up to the calling method to deal with
|
278
274
|
loggable.merge!(status: e.http_code, end_time: Time.now.to_f, body: e.http_body)
|
279
275
|
logger.warn loggable.to_json
|
280
276
|
raise
|
281
|
-
|
282
277
|
rescue Errno::ECONNRESET => e
|
283
278
|
logger.error loggable.merge(status: 'connection_reset', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
|
284
279
|
raise GdsApi::TimedOutException.new
|
data/lib/gds_api/null_cache.rb
CHANGED
@@ -104,10 +104,7 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
104
104
|
update_type: update_type
|
105
105
|
}
|
106
106
|
|
107
|
-
optional_keys = [
|
108
|
-
:locale,
|
109
|
-
:previous_version,
|
110
|
-
]
|
107
|
+
optional_keys = %i[locale previous_version]
|
111
108
|
|
112
109
|
params = merge_optional_keys(params, options, optional_keys)
|
113
110
|
|
@@ -174,10 +171,7 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
174
171
|
#
|
175
172
|
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_iddiscard-draft
|
176
173
|
def discard_draft(content_id, options = {})
|
177
|
-
optional_keys = [
|
178
|
-
:locale,
|
179
|
-
:previous_version,
|
180
|
-
]
|
174
|
+
optional_keys = %i[locale previous_version]
|
181
175
|
|
182
176
|
params = merge_optional_keys({}, options, optional_keys)
|
183
177
|
|
@@ -291,7 +285,7 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
291
285
|
links: params.fetch(:links)
|
292
286
|
}
|
293
287
|
|
294
|
-
payload = merge_optional_keys(payload, params, [
|
288
|
+
payload = merge_optional_keys(payload, params, %i[previous_version bulk_publishing])
|
295
289
|
|
296
290
|
patch_json(links_url(content_id), payload)
|
297
291
|
end
|
@@ -422,6 +416,19 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
422
416
|
post_json("#{endpoint}/v2/links/by-content-id", content_ids: content_ids).to_hash
|
423
417
|
end
|
424
418
|
|
419
|
+
# Reserves a path for a publishing application
|
420
|
+
#
|
421
|
+
# Returns success or failure only.
|
422
|
+
#
|
423
|
+
# @param payload [Hash]
|
424
|
+
# @option payload [Hash] publishing_app The publishing application, like `content-tagger`
|
425
|
+
#
|
426
|
+
# @see https://docs.publishing.service.gov.uk/apis/publishing-api/api.html#put-pathsbase_path
|
427
|
+
def put_path(base_path, payload)
|
428
|
+
url = "#{endpoint}/paths#{base_path}"
|
429
|
+
put_json(url, payload)
|
430
|
+
end
|
431
|
+
|
425
432
|
private
|
426
433
|
|
427
434
|
def content_url(content_id, params = {})
|
data/lib/gds_api/response.rb
CHANGED
@@ -87,7 +87,7 @@ module GdsApi
|
|
87
87
|
when Hash
|
88
88
|
Hash[value.map { |k, v|
|
89
89
|
# NOTE: Don't bother transforming if the value is nil
|
90
|
-
if 'web_url'
|
90
|
+
if k == 'web_url' && v
|
91
91
|
# Use relative URLs to route when the web_url value is on the
|
92
92
|
# same domain as the site root. Note that we can't just use the
|
93
93
|
# `route_to` method, as this would give us technically correct
|
data/lib/gds_api/router.rb
CHANGED
@@ -19,7 +19,7 @@ class GdsApi::Router < GdsApi::Base
|
|
19
19
|
|
20
20
|
def get_route(path, type = nil)
|
21
21
|
if type
|
22
|
-
|
22
|
+
warn "DEPRECATION WARNING: passing type to GdsApi::Router#get_route is deprecated and will be removed in a future version. Caller: #{caller(1..1)}"
|
23
23
|
end
|
24
24
|
get_json("#{endpoint}/routes?incoming_path=#{CGI.escape(path)}")
|
25
25
|
end
|
@@ -23,7 +23,7 @@ module GdsApi
|
|
23
23
|
"postcode" => postcode
|
24
24
|
}
|
25
25
|
|
26
|
-
area_response = Hash[areas.map.with_index {|area, i|
|
26
|
+
area_response = Hash[areas.map.with_index { |area, i|
|
27
27
|
[i, {
|
28
28
|
'codes' => {
|
29
29
|
'ons' => area['ons'],
|
@@ -31,7 +31,8 @@ module GdsApi
|
|
31
31
|
'govuk_slug' => area['govuk_slug']
|
32
32
|
},
|
33
33
|
'name' => area['name'],
|
34
|
-
'type' => area['type']
|
34
|
+
'type' => area['type'],
|
35
|
+
'country_name' => area['country_name']
|
35
36
|
}]
|
36
37
|
}]
|
37
38
|
|
data/lib/gds_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,31 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 52.
|
4
|
+
version: 52.7.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: 2018-
|
11
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.9.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.9.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: null_logger
|
14
|
+
name: addressable
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - ">="
|
@@ -67,35 +53,35 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: 0.1.1
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: null_logger
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
|
-
- - "
|
59
|
+
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
61
|
+
version: '0'
|
76
62
|
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- - "
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
70
|
+
name: plek
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: 1.9.0
|
90
76
|
type: :runtime
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
82
|
+
version: 1.9.0
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: rack-cache
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ">="
|
@@ -108,6 +94,20 @@ dependencies:
|
|
108
94
|
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rest-client
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: govuk-content-schema-test-helpers
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|