gds-api-adapters 63.5.1 → 63.6.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/README.md +4 -23
- data/Rakefile +4 -4
- data/lib/gds_api/exceptions.rb +3 -4
- data/lib/gds_api/json_client.rb +2 -2
- data/lib/gds_api/test_helpers/publishing_api.rb +10 -10
- data/lib/gds_api/test_helpers/search.rb +5 -5
- data/lib/gds_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63bd76ee4646694f763c71980fcce76ae359bfd12ad2de8437679eb0f389422
|
4
|
+
data.tar.gz: 5729acfdc3d52d7fd1c7e053a7740bc09424006088e6ce0631fed2144479e267
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7676cf189a66b0b699c08ae50605a4f481da8b775201876e641167b49d7a6fc33a2139c97f4b7d0801af335e3c32929afc7bb8c6cc562cd2999c889f7603f5c3
|
7
|
+
data.tar.gz: 2c9f91be586e98a61e91dccf0c8bb66a9db31d1bbac59eccabf13e7fc8689f169126907d15a50ad483cb5605934240438ce5e2fbd97243511718be2278e7c359
|
data/README.md
CHANGED
@@ -5,9 +5,8 @@ A set of API adapters to work with the GDS APIs.
|
|
5
5
|
Example usage:
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
require 'gds_api/
|
9
|
-
|
10
|
-
results = search.search(q: "taxes")
|
8
|
+
require 'gds_api/publishing_api'
|
9
|
+
GdsApi.publishing_api.get_content("f3bbdec2-0e62-4520-a7fd-6ffd5d36e03a")
|
11
10
|
```
|
12
11
|
|
13
12
|
Example adapters for frequently used applications:
|
@@ -39,12 +38,11 @@ GdsApi::Base.logger = Logger.new("/path/to/file.log")
|
|
39
38
|
## Setting the timeout
|
40
39
|
|
41
40
|
By default the JsonClient timeout is set to 4 seconds. If this is exceeded a
|
42
|
-
`GdsApi::TimedOutException` will be raised.
|
43
|
-
override this timeout. Alternatively, you can override this in the application
|
41
|
+
`GdsApi::TimedOutException` will be raised. You can override this by doing:
|
44
42
|
that uses the adapter with:
|
45
43
|
|
46
44
|
```ruby
|
47
|
-
|
45
|
+
adapter = GdsApi.publishing_api(timeout: <number_of_seconds>)
|
48
46
|
```
|
49
47
|
|
50
48
|
In most cases, there is an upper-limit of 30 seconds imposed by the app server
|
@@ -85,23 +83,6 @@ There are also test helpers for stubbing various requests in other apps.
|
|
85
83
|
|
86
84
|
See [all the test helpers in lib/gds_api/test_helpers](/lib/gds_api/test_helpers).
|
87
85
|
|
88
|
-
### Dependencies
|
89
|
-
|
90
|
-
Some of the helpers come with additional dependencies that you'll need to
|
91
|
-
have installed and configured in your consuming app/lib.
|
92
|
-
|
93
|
-
At time of writing, these are:
|
94
|
-
|
95
|
-
* [WebMock](https://github.com/bblimke/webmock)
|
96
|
-
|
97
|
-
### Documentation
|
98
|
-
|
99
|
-
See [RubyDoc](http://www.rubydoc.info/gems/gds-api-adapters) for some limited documentation.
|
100
|
-
|
101
|
-
To run a Yard server locally to preview documentation, run:
|
102
|
-
|
103
|
-
$ bundle exec yard server --reload
|
104
|
-
|
105
86
|
## Licence
|
106
87
|
|
107
88
|
Released under the MIT Licence, a copy of which can be found in the file
|
data/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
require "rdoc/task"
|
4
|
-
require
|
4
|
+
require "rake/testtask"
|
5
5
|
|
6
6
|
RDoc::Task.new do |rd|
|
7
7
|
rd.rdoc_files.include("lib/**/*.rb")
|
@@ -15,12 +15,12 @@ Rake::TestTask.new("test") do |t|
|
|
15
15
|
end
|
16
16
|
task default: :test
|
17
17
|
|
18
|
-
require
|
18
|
+
require "pact_broker/client/tasks"
|
19
19
|
|
20
20
|
def configure_pact_broker_location(task)
|
21
21
|
task.pact_broker_base_url = ENV.fetch("PACT_BROKER_BASE_URL")
|
22
|
-
if ENV[
|
23
|
-
task.pact_broker_basic_auth = { username: ENV[
|
22
|
+
if ENV["PACT_BROKER_USERNAME"]
|
23
|
+
task.pact_broker_basic_auth = { username: ENV["PACT_BROKER_USERNAME"], password: ENV["PACT_BROKER_PASSWORD"] }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/lib/gds_api/exceptions.rb
CHANGED
@@ -22,11 +22,10 @@ module GdsApi
|
|
22
22
|
class HTTPErrorResponse < BaseError
|
23
23
|
attr_accessor :code, :error_details
|
24
24
|
|
25
|
-
def initialize(code, message = nil, error_details = nil
|
25
|
+
def initialize(code, message = nil, error_details = nil)
|
26
26
|
super(message)
|
27
27
|
@code = code
|
28
28
|
@error_details = error_details
|
29
|
-
@request_body = request_body
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
@@ -53,8 +52,8 @@ module GdsApi
|
|
53
52
|
class HTTPGatewayTimeout < HTTPIntermittentServerError; end
|
54
53
|
|
55
54
|
module ExceptionHandling
|
56
|
-
def build_specific_http_error(error, url, details = nil
|
57
|
-
message = "URL: #{url}\nResponse body:\n#{error.http_body}
|
55
|
+
def build_specific_http_error(error, url, details = nil)
|
56
|
+
message = "URL: #{url}\nResponse body:\n#{error.http_body}"
|
58
57
|
code = error.http_code
|
59
58
|
error_class_for_code(code).new(code, message, details)
|
60
59
|
end
|
data/lib/gds_api/json_client.rb
CHANGED
@@ -83,7 +83,7 @@ module GdsApi
|
|
83
83
|
def do_raw_request(method, url, params = nil)
|
84
84
|
do_request(method, url, params)
|
85
85
|
rescue RestClient::Exception => e
|
86
|
-
raise build_specific_http_error(e, url, nil
|
86
|
+
raise build_specific_http_error(e, url, nil)
|
87
87
|
end
|
88
88
|
|
89
89
|
# method: the symbolic name of the method to use, e.g. :get, :post
|
@@ -105,7 +105,7 @@ module GdsApi
|
|
105
105
|
rescue JSON::ParserError
|
106
106
|
nil
|
107
107
|
end
|
108
|
-
raise build_specific_http_error(e, url, error_details
|
108
|
+
raise build_specific_http_error(e, url, error_details)
|
109
109
|
end
|
110
110
|
|
111
111
|
# If no custom response is given, just instantiate Response
|
@@ -266,11 +266,11 @@ module GdsApi
|
|
266
266
|
# @param attributes_or_matcher [Object]
|
267
267
|
# @param times [Integer]
|
268
268
|
def assert_publishing_api(verb, url, attributes_or_matcher = nil, times = 1)
|
269
|
-
if attributes_or_matcher.is_a?(Hash)
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
269
|
+
matcher = if attributes_or_matcher.is_a?(Hash)
|
270
|
+
request_json_matches(attributes_or_matcher)
|
271
|
+
else
|
272
|
+
attributes_or_matcher
|
273
|
+
end
|
274
274
|
|
275
275
|
if matcher
|
276
276
|
assert_requested(verb, url, times: times, &matcher)
|
@@ -684,11 +684,11 @@ module GdsApi
|
|
684
684
|
end
|
685
685
|
|
686
686
|
def assert_publishing_api_put(url, attributes_or_matcher = {}, times = 1)
|
687
|
-
if attributes_or_matcher.is_a?(Hash)
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
687
|
+
matcher = if attributes_or_matcher.is_a?(Hash)
|
688
|
+
attributes_or_matcher.empty? ? nil : request_json_matching(attributes_or_matcher)
|
689
|
+
else
|
690
|
+
attributes_or_matcher
|
691
|
+
end
|
692
692
|
|
693
693
|
if matcher
|
694
694
|
assert_requested(:put, url, times: times, &matcher)
|
@@ -17,11 +17,11 @@ module GdsApi
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def assert_search_posted_item(attributes, index: nil, **options)
|
20
|
-
if index
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
url = if index
|
21
|
+
SEARCH_ENDPOINT + "/#{index}/documents"
|
22
|
+
else
|
23
|
+
SEARCH_ENDPOINT + "/documents"
|
24
|
+
end
|
25
25
|
|
26
26
|
assert_requested(:post, url, **options) do |req|
|
27
27
|
data = JSON.parse(req.body)
|
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: 63.
|
4
|
+
version: 63.6.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: 2020-
|
11
|
+
date: 2020-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -457,7 +457,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
457
457
|
requirements:
|
458
458
|
- - ">="
|
459
459
|
- !ruby/object:Gem::Version
|
460
|
-
version: 2.
|
460
|
+
version: 2.4.0
|
461
461
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
462
462
|
requirements:
|
463
463
|
- - ">="
|