gds-api-adapters 52.6.0 → 52.7.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: accf0f5721d9f46ecb702af9350c6c473283f8730f28248dbe511b1510659c85
4
- data.tar.gz: 27d8cb31d8ffec45ac356c963f2d1c0fb53b71b3e01598e408093a5dbff1a5a2
3
+ metadata.gz: 8e8fb67f01e255a264b4c5af3bfc7726d1147caad20049d9ec32f4e87244c754
4
+ data.tar.gz: 8de0575d7e68cb46dd177a63ab6ab7fdee11238b191f611d38491367fe8a6f4d
5
5
  SHA512:
6
- metadata.gz: 636879880957a7bb7d8f4f516ed6a2fef9e0e7c8599928f5602d4a826115b4e3c0d32f3ba8f1908ae6cfe2ba626d88f0fc89644d5bd798a01d59c64b83ee618e
7
- data.tar.gz: d0867f25e9925feef2b27260430470ab6e640f7bbc60383917626d1899dcbe221c67671274a861b8764cf7d24c0bd291b38bd7e8ba6389c5e047b12d2b76d937
6
+ metadata.gz: 74cfbd519a7fee3bdbff93ac43dffefcfb26adb3c2dbbc8673b8e13e75a5fb97dd27252063a22fa7d5a140945ed87c3df9d0ec4da5cbb619d3507b5369fe3e9e
7
+ data.tar.gz: 3664cbb17b43ed08f7d434e2e6d2ecb0cd09b78667b12b9957ffa3b36e8badca38ec905227ee40ef853a3b1bab516683d1b7a150791a69cb23d5ccfb346ce85f
@@ -6,7 +6,7 @@ module GdsApi
6
6
  end
7
7
 
8
8
  def headers
9
- header_data.select { |_k, v| !(v.nil? || v.empty?) }
9
+ header_data.reject { |_k, v| (v.nil? || v.empty?) }
10
10
  end
11
11
 
12
12
  def clear_headers
@@ -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 = [:limit, :lat, :lng, :postcode].select { |p| params.include? p }
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
@@ -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
@@ -4,10 +4,8 @@ module GdsApi
4
4
  nil
5
5
  end
6
6
 
7
- def []=(k, v)
8
- end
7
+ def []=(k, v); end
9
8
 
10
- def store(k, v, expiry_time = nil)
11
- end
9
+ def store(k, v, expiry_time = nil); end
12
10
  end
13
11
  end
@@ -12,6 +12,7 @@ class GdsApi::PublishingApi < GdsApi::Base
12
12
  e
13
13
  end
14
14
 
15
+ # @deprecated Use GdsApi::PublishingApiV2
15
16
  def put_path(base_path, payload)
16
17
  put_json(paths_url(base_path), payload)
17
18
  end
@@ -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, [:previous_version, :bulk_publishing])
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 = {})
@@ -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' == k && v
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
@@ -19,7 +19,7 @@ class GdsApi::Router < GdsApi::Base
19
19
 
20
20
  def get_route(path, type = nil)
21
21
  if type
22
- $stderr.puts "DEPRECATION WARNING: passing type to GdsApi::Router#get_route is deprecated and will be removed in a future version. Caller: #{caller[0]}"
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
 
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '52.6.0'.freeze
2
+ VERSION = '52.7.0'.freeze
3
3
  end
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.6.0
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-06-07 00:00:00.000000000 Z
11
+ date: 2018-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: plek
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: rest-client
56
+ name: null_logger
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: '2.0'
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: '2.0'
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
- name: rack-cache
70
+ name: plek
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
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: '0'
82
+ version: 1.9.0
97
83
  - !ruby/object:Gem::Dependency
98
- name: addressable
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