gds-api-adapters 63.5.1 → 63.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5930ba264b390c501d2bff817dc92bbb5dc575a73aeb4e039639d5dcba8b2834
4
- data.tar.gz: 3bd8edada18541fb876dd506d2ba0f230ce3e3d6ec361f6530091ab8519642a5
3
+ metadata.gz: c63bd76ee4646694f763c71980fcce76ae359bfd12ad2de8437679eb0f389422
4
+ data.tar.gz: 5729acfdc3d52d7fd1c7e053a7740bc09424006088e6ce0631fed2144479e267
5
5
  SHA512:
6
- metadata.gz: 54863fb58b2392934961c7db3cff706d5616d98f57eb2a8234e4f54d4f93fb13df2dbd5fb977a80563b4d9c380ea666c07f76cbb77c6e0adaefdf3a5c60896e9
7
- data.tar.gz: ee8c87a4a58cd019d8965e3b779bb569145870e1276619215a4d99ab0ef3f780b35a48ed5c5b49eda9de39cf81fd1b3074162ee0977fb7e142351d6375494c60
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/search'
9
- search = GdsApi::Search.new(Plek.new.find('search))
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. Individual clients may decide to
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
- Services.publishing_api.client.options[:timeout] = number_of_seconds
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 'rake/testtask'
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 'pact_broker/client/tasks'
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['PACT_BROKER_USERNAME']
23
- task.pact_broker_basic_auth = { username: ENV['PACT_BROKER_USERNAME'], password: ENV['PACT_BROKER_PASSWORD'] }
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
 
@@ -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, request_body = 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, request_body = nil)
57
- message = "URL: #{url}\nResponse body:\n#{error.http_body}\n\nRequest body:\n#{request_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
@@ -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, params)
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, params)
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
- matcher = request_json_matches(attributes_or_matcher)
271
- else
272
- matcher = attributes_or_matcher
273
- end
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
- matcher = attributes_or_matcher.empty? ? nil : request_json_matching(attributes_or_matcher)
689
- else
690
- matcher = attributes_or_matcher
691
- end
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
- url = SEARCH_ENDPOINT + "/#{index}/documents"
22
- else
23
- url = SEARCH_ENDPOINT + "/documents"
24
- end
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)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "63.5.1".freeze
2
+ VERSION = "63.6.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: 63.5.1
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-02-20 00:00:00.000000000 Z
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.3.0
460
+ version: 2.4.0
461
461
  required_rubygems_version: !ruby/object:Gem::Requirement
462
462
  requirements:
463
463
  - - ">="