gds-api-adapters 43.0.0 → 44.0.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/lib/gds_api/helpers.rb +0 -5
- data/lib/gds_api/test_helpers/content_api.rb +0 -2
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -5
- data/lib/gds_api/business_support_api.rb +0 -19
- data/lib/gds_api/test_helpers/business_support_api.rb +0 -34
- data/lib/gds_api/test_helpers/business_support_helper.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c8b177ccf8310b8cf4ad08ffb31e6da656b7013
|
4
|
+
data.tar.gz: 600428d36ee139da2ef12a3608eb8b5822536143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d964acedebb681e528e9154febb7af23e2562e4ef1b0666fddb231e331ade3882ddcf98ed2934fd11e9bd991cec0039772a2b4eea1e37a314ca40d3aa5d75462
|
7
|
+
data.tar.gz: cc45b21101bd7249f59fe105bac9a84ffec76b97762670509adac7d7d684d136cfdab7be884369020d2a20e088db6b29a3b3167122db80e818ffb7fb573aed20
|
data/lib/gds_api/helpers.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'gds_api/asset_manager'
|
2
|
-
require 'gds_api/business_support_api'
|
3
2
|
require 'gds_api/content_api'
|
4
3
|
require 'gds_api/content_store'
|
5
4
|
require 'gds_api/imminence'
|
@@ -14,10 +13,6 @@ module GdsApi
|
|
14
13
|
@asset_manager_api ||= GdsApi::AssetManager.new(Plek.current.find('asset-manager'), options)
|
15
14
|
end
|
16
15
|
|
17
|
-
def business_support_api(options = {})
|
18
|
-
@business_support_api ||= GdsApi::BusinessSupportApi.new(Plek.current.find("business-support-api"), options)
|
19
|
-
end
|
20
|
-
|
21
16
|
def content_api(options = {})
|
22
17
|
@content_api ||= GdsApi::ContentApi.new(Plek.current.find("contentapi"), options)
|
23
18
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'gds_api/test_helpers/json_client_helper'
|
2
2
|
require 'cgi'
|
3
3
|
require 'gds_api/test_helpers/common_responses'
|
4
|
-
require 'gds_api/test_helpers/business_support_helper'
|
5
4
|
|
6
5
|
module GdsApi
|
7
6
|
module TestHelpers
|
8
7
|
module ContentApi
|
9
8
|
include GdsApi::TestHelpers::CommonResponses
|
10
|
-
include GdsApi::TestHelpers::BusinessSupportHelper
|
11
9
|
# Generally true. If you are initializing the client differently,
|
12
10
|
# you could redefine/override the constant or stub directly.
|
13
11
|
CONTENT_API_ENDPOINT = Plek.current.find('contentapi')
|
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:
|
4
|
+
version: 44.0.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-
|
11
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|
@@ -358,7 +358,6 @@ files:
|
|
358
358
|
- lib/gds-api-adapters.rb
|
359
359
|
- lib/gds_api/asset_manager.rb
|
360
360
|
- lib/gds_api/base.rb
|
361
|
-
- lib/gds_api/business_support_api.rb
|
362
361
|
- lib/gds_api/content_api.rb
|
363
362
|
- lib/gds_api/content_store.rb
|
364
363
|
- lib/gds_api/email_alert_api.rb
|
@@ -390,8 +389,6 @@ files:
|
|
390
389
|
- lib/gds_api/support.rb
|
391
390
|
- lib/gds_api/support_api.rb
|
392
391
|
- lib/gds_api/test_helpers/asset_manager.rb
|
393
|
-
- lib/gds_api/test_helpers/business_support_api.rb
|
394
|
-
- lib/gds_api/test_helpers/business_support_helper.rb
|
395
392
|
- lib/gds_api/test_helpers/common_responses.rb
|
396
393
|
- lib/gds_api/test_helpers/content_api.rb
|
397
394
|
- lib/gds_api/test_helpers/content_api/artefact_stub.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative 'base'
|
2
|
-
require_relative 'exceptions'
|
3
|
-
require_relative 'list_response'
|
4
|
-
|
5
|
-
class GdsApi::BusinessSupportApi < GdsApi::Base
|
6
|
-
def schemes(options = {})
|
7
|
-
get_list(url_for_slug('business-support-schemes', options))
|
8
|
-
end
|
9
|
-
|
10
|
-
def scheme(slug)
|
11
|
-
get_json(url_for_slug("business-support-schemes/#{slug}"))
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def base_url
|
17
|
-
endpoint
|
18
|
-
end
|
19
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'gds_api/test_helpers/business_support_helper'
|
2
|
-
|
3
|
-
module GdsApi
|
4
|
-
module TestHelpers
|
5
|
-
module BusinessSupportApi
|
6
|
-
include GdsApi::TestHelpers::CommonResponses
|
7
|
-
include GdsApi::TestHelpers::BusinessSupportHelper
|
8
|
-
# Generally true. If you are initializing the client differently,
|
9
|
-
# you could redefine/override the constant or stub directly.
|
10
|
-
BUSINESS_SUPPORT_API_ENDPOINT = Plek.current.find('business-support-api')
|
11
|
-
|
12
|
-
def setup_business_support_api_schemes_stubs
|
13
|
-
setup_business_support_stubs(BUSINESS_SUPPORT_API_ENDPOINT, 'business-support-schemes')
|
14
|
-
end
|
15
|
-
|
16
|
-
def business_support_api_has_scheme(scheme, facets = {})
|
17
|
-
api_has_business_support(scheme, facets)
|
18
|
-
end
|
19
|
-
|
20
|
-
def business_support_api_has_schemes(schemes, facets = {})
|
21
|
-
schemes.each do |scheme|
|
22
|
-
business_support_api_has_scheme(scheme, facets)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def business_support_api_has_a_scheme(slug, scheme)
|
27
|
-
title = scheme.delete(:title)
|
28
|
-
stub_request(:get, %r{\A#{BUSINESS_SUPPORT_API_ENDPOINT}/business-support-schemes/#{slug}\.json}).to_return do |_request|
|
29
|
-
{ body: response_base.merge(format: 'business_support', title: title, details: scheme).to_json }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'gds_api/test_helpers/json_client_helper'
|
2
|
-
require 'cgi'
|
3
|
-
require 'gds_api/test_helpers/common_responses'
|
4
|
-
|
5
|
-
|
6
|
-
module GdsApi
|
7
|
-
module TestHelpers
|
8
|
-
module BusinessSupportHelper
|
9
|
-
def setup_business_support_stubs(endpoint, path)
|
10
|
-
@stubbed_business_supports = []
|
11
|
-
stub_request(:get, %r{\A#{endpoint}/#{path}\.json}).to_return do |request|
|
12
|
-
if request.uri.query_values
|
13
|
-
facets = sanitise_facets(request.uri.query_values)
|
14
|
-
results = stubs_for_facets(facets) || []
|
15
|
-
else
|
16
|
-
results = @stubbed_business_supports
|
17
|
-
end
|
18
|
-
{ body: plural_response_base.merge("results" => results, "total" => results.size).to_json }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def api_has_business_support(business_support, facets = {})
|
23
|
-
facets = sanitise_facets(facets)
|
24
|
-
|
25
|
-
if business_support.is_a?(Symbol)
|
26
|
-
bs_with_facets = facets.merge(title: business_support)
|
27
|
-
else
|
28
|
-
bs_with_facets = facets.merge(business_support)
|
29
|
-
end
|
30
|
-
|
31
|
-
@stubbed_business_supports << bs_with_facets unless @stubbed_business_supports.include?(bs_with_facets)
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def stubs_for_facets(facets)
|
37
|
-
@stubbed_business_supports.select do |bs|
|
38
|
-
facet_matches = 0
|
39
|
-
facets.each do |k, v|
|
40
|
-
if bs[k] && (v & bs[k]).any?
|
41
|
-
facet_matches += 1
|
42
|
-
end
|
43
|
-
end
|
44
|
-
facet_matches == facets.keys.size
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def sanitise_facets(facets)
|
49
|
-
Hash[facets.map { |k, v|
|
50
|
-
v = v.split(',') if v.is_a?(String)
|
51
|
-
[k.to_sym, v]
|
52
|
-
}]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|