gds-api-adapters 47.8.0 → 47.9.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
  SHA1:
3
- metadata.gz: ae9092a1631e64f9ea4fc2918fbdb52873399aa0
4
- data.tar.gz: 500b4e397139072aa10050f592ba7d01a84d342a
3
+ metadata.gz: 086bb1489e91664b8193ca9797842b8051a8d386
4
+ data.tar.gz: ab1324db0ccbc1910a4514d416d16e73c7dd6d5e
5
5
  SHA512:
6
- metadata.gz: d6dc31f2d4b3f3450cd12c5bd9215ade7243414b16d7c09c867e1f79a95baf218660f285cbd3787b2fa7f8e80a167fbff6e8edd22b4620cf8dc9341529d5e69e
7
- data.tar.gz: 0a671c633d045aad1961ed8dc55df24a5ad5fc32c1396a34599ecb3b07d9b6dbe3bb942b7526e42bce81eb8ce794f8ec5d897f8a888c0deb78ffc3f7daf94e8e
6
+ metadata.gz: f03df9f6d8edb24140f443d8d6a7cb41b60aa5aad56b33444292b8fbf2cf235fc0c871ef8dc98ceecb275e539c450f290e86f95f8bc709f00a55965509d95dff
7
+ data.tar.gz: 9cf89b5aeee884d7f6a15f02c9613d7c307509b5567c81209f37bd0fd438163b570b1fb92ca471d6381d74f3021dab1c3acfed70bc7e4584e0f472493a3d27b6
@@ -1,16 +1,12 @@
1
1
  module GdsApi
2
- class BaseError < StandardError
3
- end
4
-
5
- class EndpointNotFound < BaseError
6
- end
2
+ # Abstract error class
3
+ class BaseError < StandardError; end
7
4
 
8
- class TimedOutException < BaseError
9
- end
10
-
11
- class TooManyRedirects < BaseError
12
- end
5
+ class EndpointNotFound < BaseError; end
6
+ class TimedOutException < BaseError; end
7
+ class InvalidUrl < BaseError; end
13
8
 
9
+ # Superclass for all 4XX and 5XX errors
14
10
  class HTTPErrorResponse < BaseError
15
11
  attr_accessor :code, :error_details
16
12
 
@@ -22,46 +18,26 @@ module GdsApi
22
18
  end
23
19
  end
24
20
 
25
- class HTTPClientError < HTTPErrorResponse
26
- end
27
-
28
- class HTTPServerError < HTTPErrorResponse
29
- end
30
-
31
- class HTTPNotFound < HTTPClientError
32
- end
33
-
34
- class HTTPGone < HTTPClientError
35
- end
21
+ # Superclass & fallback for all 4XX errors
22
+ class HTTPClientError < HTTPErrorResponse; end
36
23
 
37
- class HTTPUnauthorized < HTTPClientError
38
- end
24
+ class HTTPNotFound < HTTPClientError; end
25
+ class HTTPGone < HTTPClientError; end
26
+ class HTTPPayloadTooLarge < HTTPClientError; end
27
+ class HTTPUnauthorized < HTTPClientError; end
28
+ class HTTPForbidden < HTTPClientError; end
29
+ class HTTPConflict < HTTPClientError; end
30
+ class HTTPUnprocessableEntity < HTTPClientError; end
39
31
 
40
- class HTTPForbidden < HTTPClientError
41
- end
32
+ # Superclass & fallback for all 5XX errors
33
+ class HTTPServerError < HTTPErrorResponse; end
42
34
 
43
- class HTTPConflict < HTTPClientError
44
- end
45
-
46
- class HTTPUnprocessableEntity < HTTPClientError
47
- end
48
-
49
- class InvalidUrl < BaseError; end
50
-
51
- class NoBearerToken < BaseError; end
35
+ class HTTPInternalServerError < HTTPServerError; end
36
+ class HTTPBadGateway < HTTPServerError; end
37
+ class HTTPUnavailable < HTTPServerError; end
38
+ class HTTPGatewayTimeout < HTTPServerError; end
52
39
 
53
40
  module ExceptionHandling
54
- def ignoring(exception_or_exceptions)
55
- yield
56
- rescue *exception_or_exceptions
57
- # Discard the exception
58
- nil
59
- end
60
-
61
- def ignoring_missing(&block)
62
- ignoring([HTTPNotFound, HTTPGone], &block)
63
- end
64
-
65
41
  def build_specific_http_error(error, url, details = nil, request_body = nil)
66
42
  message = "URL: #{url}\nResponse body:\n#{error.http_body}\n\nRequest body:\n#{request_body}"
67
43
  code = error.http_code
@@ -80,10 +56,20 @@ module GdsApi
80
56
  GdsApi::HTTPConflict
81
57
  when 410
82
58
  GdsApi::HTTPGone
59
+ when 413
60
+ GdsApi::HTTPPayloadTooLarge
83
61
  when 422
84
62
  GdsApi::HTTPUnprocessableEntity
85
63
  when (400..499)
86
64
  GdsApi::HTTPClientError
65
+ when 500
66
+ GdsApi::HTTPInternalServerError
67
+ when 502
68
+ GdsApi::HTTPBadGateway
69
+ when 503
70
+ GdsApi::HTTPUnavailable
71
+ when 504
72
+ GdsApi::HTTPGatewayTimeout
87
73
  when (500..599)
88
74
  GdsApi::HTTPServerError
89
75
  else
@@ -347,6 +347,32 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
347
347
  end
348
348
  end
349
349
 
350
+ # Returns a mapping of content_ids => links hashes
351
+ #
352
+ # @param content_ids [Array]
353
+ #
354
+ # @return [Hash] a mapping of content_id => links
355
+ #
356
+ # @example
357
+ #
358
+ # publishing_api.get_links_for_content_ids([
359
+ # "e1067450-7d13-45ff-ada4-5e3dd4025fb7",
360
+ # "72ed754c-4c82-415f-914a-ab6760454cb4"
361
+ # ])
362
+ #
363
+ # #=> {
364
+ # "e1067450-7d13-45ff-ada4-5e3dd4025fb7" => {
365
+ # links: {
366
+ # taxons: ["13bba81c-b2b1-4b13-a3de-b24748977198"]},
367
+ # ... (and more attributes)
368
+ # version: 10},
369
+ # "72ed754c-4c82-415f-914a-ab6760454cb4" => { ..etc }
370
+ # }
371
+ #
372
+ def get_links_for_content_ids(content_ids)
373
+ post_json("#{endpoint}/v2/links/by-content-id", content_ids: content_ids).to_hash
374
+ end
375
+
350
376
  private
351
377
 
352
378
  def content_url(content_id, params = {})
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '47.8.0'.freeze
2
+ VERSION = '47.9.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: 47.8.0
4
+ version: 47.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-07 00:00:00.000000000 Z
11
+ date: 2017-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek