gds-api-adapters 69.3.0 → 71.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/gds_api.rb +14 -0
- data/lib/gds_api/account_api.rb +157 -0
- data/lib/gds_api/base.rb +1 -1
- data/lib/gds_api/content_store.rb +1 -1
- data/lib/gds_api/exceptions.rb +20 -3
- data/lib/gds_api/json_client.rb +8 -8
- data/lib/gds_api/link_checker_api.rb +0 -31
- data/lib/gds_api/response.rb +1 -0
- data/lib/gds_api/search.rb +6 -6
- data/lib/gds_api/test_helpers/account_api.rb +380 -0
- data/lib/gds_api/test_helpers/calendars.rb +1 -1
- data/lib/gds_api/test_helpers/content_store.rb +9 -12
- data/lib/gds_api/test_helpers/link_checker_api.rb +0 -17
- data/lib/gds_api/test_helpers/mapit.rb +10 -10
- data/lib/gds_api/test_helpers/publishing_api.rb +18 -19
- data/lib/gds_api/test_helpers/search.rb +1 -1
- data/lib/gds_api/version.rb +1 -1
- metadata +10 -12
- data/lib/gds_api/performance_platform/data_in.rb +0 -27
- data/lib/gds_api/performance_platform/data_out.rb +0 -131
- data/lib/gds_api/test_helpers/performance_platform/data_in.rb +0 -45
- data/lib/gds_api/test_helpers/performance_platform/data_out.rb +0 -98
@@ -4,7 +4,7 @@ module GdsApi
|
|
4
4
|
def calendars_endpoint(in_division: nil)
|
5
5
|
endpoint = "#{Plek.new.website_root}/bank-holidays"
|
6
6
|
endpoint += "/#{in_division}" unless in_division.nil?
|
7
|
-
endpoint
|
7
|
+
"#{endpoint}.json"
|
8
8
|
end
|
9
9
|
|
10
10
|
def stub_calendars_has_no_bank_holidays(in_division: nil)
|
@@ -7,7 +7,7 @@ module GdsApi
|
|
7
7
|
module ContentStore
|
8
8
|
include ContentItemHelpers
|
9
9
|
|
10
|
-
def content_store_endpoint(draft
|
10
|
+
def content_store_endpoint(draft: false)
|
11
11
|
draft ? Plek.current.find("draft-content-store") : Plek.current.find("content-store")
|
12
12
|
end
|
13
13
|
|
@@ -21,10 +21,10 @@ module GdsApi
|
|
21
21
|
def stub_content_store_has_item(base_path, body = content_item_for_base_path(base_path), options = {})
|
22
22
|
max_age = options.fetch(:max_age, 900)
|
23
23
|
visibility = options[:private] ? "private" : "public"
|
24
|
-
url = content_store_endpoint(options[:draft]) + "/content" + base_path
|
25
24
|
body = body.to_json unless body.is_a?(String)
|
26
25
|
|
27
|
-
|
26
|
+
endpoint = content_store_endpoint(draft: options[:draft])
|
27
|
+
stub_request(:get, "#{endpoint}/content#{base_path}").to_return(
|
28
28
|
status: 200,
|
29
29
|
body: body,
|
30
30
|
headers: {
|
@@ -35,11 +35,9 @@ module GdsApi
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def stub_content_store_does_not_have_item(base_path, options = {})
|
38
|
-
|
39
|
-
stub_request(:get,
|
40
|
-
|
41
|
-
url = content_store_endpoint(options[:draft]) + "/incoming-links" + base_path
|
42
|
-
stub_request(:get, url).to_return(status: 404, headers: {})
|
38
|
+
endpoint = content_store_endpoint(draft: options[:draft])
|
39
|
+
stub_request(:get, "#{endpoint}/content#{base_path}").to_return(status: 404, headers: {})
|
40
|
+
stub_request(:get, "#{endpoint}/incoming-links#{base_path}").to_return(status: 404, headers: {})
|
43
41
|
end
|
44
42
|
|
45
43
|
# Content store has gone item
|
@@ -67,10 +65,9 @@ module GdsApi
|
|
67
65
|
# "details" => {}
|
68
66
|
# }
|
69
67
|
def stub_content_store_has_gone_item(base_path, body = gone_content_item_for_base_path(base_path), options = {})
|
70
|
-
url = content_store_endpoint(options[:draft]) + "/content" + base_path
|
71
68
|
body = body.to_json unless body.is_a?(String)
|
72
|
-
|
73
|
-
stub_request(:get,
|
69
|
+
endpoint = content_store_endpoint(draft: options[:draft])
|
70
|
+
stub_request(:get, "#{endpoint}/content#{base_path}").to_return(
|
74
71
|
status: 410,
|
75
72
|
body: body,
|
76
73
|
headers: {},
|
@@ -86,7 +83,7 @@ module GdsApi
|
|
86
83
|
end
|
87
84
|
|
88
85
|
def stub_content_store_has_incoming_links(base_path, links)
|
89
|
-
url = content_store_endpoint
|
86
|
+
url = "#{content_store_endpoint}/incoming-links#{base_path}"
|
90
87
|
body = links.to_json
|
91
88
|
|
92
89
|
stub_request(:get, url).to_return(body: body)
|
@@ -72,23 +72,6 @@ module GdsApi
|
|
72
72
|
headers: { "Content-Type" => "application/json" },
|
73
73
|
)
|
74
74
|
end
|
75
|
-
|
76
|
-
def stub_link_checker_api_upsert_resource_monitor(app:, reference:, links:)
|
77
|
-
response_body = { id: 1 }.to_json
|
78
|
-
|
79
|
-
request_body = {
|
80
|
-
links: links,
|
81
|
-
app: app,
|
82
|
-
reference: reference,
|
83
|
-
}.to_json
|
84
|
-
|
85
|
-
stub_request(:post, "#{LINK_CHECKER_API_ENDPOINT}/monitor")
|
86
|
-
.with(body: request_body)
|
87
|
-
.to_return(
|
88
|
-
body: response_body,
|
89
|
-
headers: { "Content-Type" => "application/json" },
|
90
|
-
)
|
91
|
-
end
|
92
75
|
end
|
93
76
|
end
|
94
77
|
end
|
@@ -10,9 +10,9 @@ module GdsApi
|
|
10
10
|
"postcode" => postcode,
|
11
11
|
}
|
12
12
|
|
13
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode
|
13
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/#{postcode.tr(' ', '+')}.json")
|
14
14
|
.to_return(body: response.to_json, status: 200)
|
15
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial
|
15
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial/#{postcode.split(' ').first}.json")
|
16
16
|
.to_return(body: response.to_json, status: 200)
|
17
17
|
end
|
18
18
|
|
@@ -37,9 +37,9 @@ module GdsApi
|
|
37
37
|
}]
|
38
38
|
end]
|
39
39
|
|
40
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode
|
40
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/#{postcode.tr(' ', '+')}.json")
|
41
41
|
.to_return(body: response.merge("areas" => area_response).to_json, status: 200)
|
42
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial
|
42
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial/#{postcode.split(' ').first}.json")
|
43
43
|
.to_return(body: response.to_json, status: 200)
|
44
44
|
end
|
45
45
|
|
@@ -51,29 +51,29 @@ module GdsApi
|
|
51
51
|
"country_name" => country_name,
|
52
52
|
}
|
53
53
|
|
54
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode
|
54
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/#{postcode.tr(' ', '+')}.json")
|
55
55
|
.to_return(body: response.to_json, status: 200)
|
56
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial
|
56
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/partial/#{postcode.split(' ').first}.json")
|
57
57
|
.to_return(body: response.to_json, status: 200)
|
58
58
|
end
|
59
59
|
|
60
60
|
def stub_mapit_does_not_have_a_postcode(postcode)
|
61
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode
|
61
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/#{postcode.tr(' ', '+')}.json")
|
62
62
|
.to_return(body: { "code" => 404, "error" => "No Postcode matches the given query." }.to_json, status: 404)
|
63
63
|
end
|
64
64
|
|
65
65
|
def stub_mapit_does_not_have_a_bad_postcode(postcode)
|
66
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode
|
66
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/postcode/#{postcode.tr(' ', '+')}.json")
|
67
67
|
.to_return(body: { "code" => 400, "error" => "Postcode '#{postcode}' is not valid." }.to_json, status: 400)
|
68
68
|
end
|
69
69
|
|
70
70
|
def stub_mapit_has_areas(area_type, areas)
|
71
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/areas
|
71
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/areas/#{area_type}.json")
|
72
72
|
.to_return(body: areas.to_json, status: 200)
|
73
73
|
end
|
74
74
|
|
75
75
|
def stub_mapit_does_not_have_areas(area_type)
|
76
|
-
stub_request(:get, "#{MAPIT_ENDPOINT}/areas
|
76
|
+
stub_request(:get, "#{MAPIT_ENDPOINT}/areas/#{area_type}.json")
|
77
77
|
.to_return(body: [].to_json, status: 200)
|
78
78
|
end
|
79
79
|
|
@@ -8,7 +8,7 @@ module GdsApi
|
|
8
8
|
module PublishingApi
|
9
9
|
include ContentItemHelpers
|
10
10
|
|
11
|
-
PUBLISHING_API_V2_ENDPOINT = Plek.current.find(
|
11
|
+
PUBLISHING_API_V2_ENDPOINT = "#{Plek.current.find('publishing-api')}/v2".freeze
|
12
12
|
PUBLISHING_API_ENDPOINT = Plek.current.find("publishing-api")
|
13
13
|
|
14
14
|
# Stub a PUT /v2/content/:content_id request with the given content id and request body.
|
@@ -213,7 +213,7 @@ module GdsApi
|
|
213
213
|
# @param attributes_or_matcher [Object]
|
214
214
|
# @param times [Integer]
|
215
215
|
def assert_publishing_api_put_content(content_id, attributes_or_matcher = nil, times = 1)
|
216
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
216
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}"
|
217
217
|
assert_publishing_api(:put, url, attributes_or_matcher, times)
|
218
218
|
end
|
219
219
|
|
@@ -243,7 +243,7 @@ module GdsApi
|
|
243
243
|
# @param attributes_or_matcher [Object]
|
244
244
|
# @param times [Integer]
|
245
245
|
def assert_publishing_api_patch_links(content_id, attributes_or_matcher = nil, times = 1)
|
246
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
246
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/links/#{content_id}"
|
247
247
|
assert_publishing_api(:patch, url, attributes_or_matcher, times)
|
248
248
|
end
|
249
249
|
|
@@ -308,7 +308,7 @@ module GdsApi
|
|
308
308
|
# @param items [Array]
|
309
309
|
# @param params [Hash]
|
310
310
|
def stub_publishing_api_has_content(items, params = {})
|
311
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
311
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/content"
|
312
312
|
|
313
313
|
if params.respond_to? :fetch
|
314
314
|
per_page = params.fetch(:per_page, 50)
|
@@ -369,7 +369,7 @@ module GdsApi
|
|
369
369
|
# @param item [Hash]
|
370
370
|
def stub_publishing_api_has_item(item, params = {})
|
371
371
|
item = deep_transform_keys(item, &:to_sym)
|
372
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
372
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{item[:content_id]}"
|
373
373
|
stub_request(:get, url)
|
374
374
|
.with(query: hash_including(params))
|
375
375
|
.to_return(status: 200, body: item.to_json, headers: {})
|
@@ -380,7 +380,7 @@ module GdsApi
|
|
380
380
|
# @param items [Array]
|
381
381
|
def stub_publishing_api_has_item_in_sequence(content_id, items)
|
382
382
|
items = items.each { |item| deep_transform_keys(item, &:to_sym) }
|
383
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
383
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}"
|
384
384
|
calls = -1
|
385
385
|
|
386
386
|
stub_request(:get, url).to_return do |_request|
|
@@ -395,7 +395,7 @@ module GdsApi
|
|
395
395
|
#
|
396
396
|
# @param content_id [UUID]
|
397
397
|
def stub_publishing_api_does_not_have_item(content_id, params = {})
|
398
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
398
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/content/#{content_id}"
|
399
399
|
stub_request(:get, url)
|
400
400
|
.with(query: hash_including(params))
|
401
401
|
.to_return(status: 404, body: resource_not_found(content_id, "content item").to_json, headers: {})
|
@@ -433,7 +433,7 @@ module GdsApi
|
|
433
433
|
# }
|
434
434
|
def stub_publishing_api_has_links(links)
|
435
435
|
links = deep_transform_keys(links, &:to_sym)
|
436
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
436
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/links/#{links[:content_id]}"
|
437
437
|
stub_request(:get, url).to_return(status: 200, body: links.to_json, headers: {})
|
438
438
|
end
|
439
439
|
|
@@ -497,7 +497,7 @@ module GdsApi
|
|
497
497
|
request_params["with_drafts"] = false unless with_drafts
|
498
498
|
request_params["generate"] = true if generate
|
499
499
|
|
500
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
500
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/expanded-links/#{links[:content_id]}"
|
501
501
|
stub_request(:get, url)
|
502
502
|
.with(query: request_params)
|
503
503
|
.to_return(status: 200, body: links.to_json, headers: {})
|
@@ -528,7 +528,7 @@ module GdsApi
|
|
528
528
|
# }
|
529
529
|
# }
|
530
530
|
def stub_publishing_api_has_links_for_content_ids(links)
|
531
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
531
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/links/by-content-id"
|
532
532
|
stub_request(:post, url).with(body: { content_ids: links.keys }).to_return(status: 200, body: links.to_json, headers: {})
|
533
533
|
end
|
534
534
|
|
@@ -536,7 +536,7 @@ module GdsApi
|
|
536
536
|
#
|
537
537
|
# @param content_id [UUID]
|
538
538
|
def stub_publishing_api_does_not_have_links(content_id)
|
539
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
539
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/links/#{content_id}"
|
540
540
|
stub_request(:get, url).to_return(status: 404, body: resource_not_found(content_id, "link set").to_json, headers: {})
|
541
541
|
end
|
542
542
|
|
@@ -552,7 +552,7 @@ module GdsApi
|
|
552
552
|
# })
|
553
553
|
#
|
554
554
|
def stub_publishing_api_has_lookups(lookup_hash)
|
555
|
-
url = PUBLISHING_API_ENDPOINT
|
555
|
+
url = "#{PUBLISHING_API_ENDPOINT}/lookup-by-base-path"
|
556
556
|
stub_request(:post, url).to_return(body: lookup_hash.to_json)
|
557
557
|
end
|
558
558
|
|
@@ -605,7 +605,7 @@ module GdsApi
|
|
605
605
|
# @param items [Array]
|
606
606
|
# @param params [Hash]
|
607
607
|
def stub_publishing_api_get_editions(editions, params = {})
|
608
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
608
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}/editions"
|
609
609
|
|
610
610
|
results = editions.map do |edition|
|
611
611
|
next edition unless params[:fields]
|
@@ -670,7 +670,7 @@ module GdsApi
|
|
670
670
|
end
|
671
671
|
|
672
672
|
def stub_publishing_api_destroy_intent(base_path)
|
673
|
-
url = PUBLISHING_API_ENDPOINT
|
673
|
+
url = "#{PUBLISHING_API_ENDPOINT}/publish-intent#{base_path}"
|
674
674
|
stub_request(:delete, url).to_return(status: 200, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" })
|
675
675
|
end
|
676
676
|
|
@@ -679,7 +679,7 @@ module GdsApi
|
|
679
679
|
end
|
680
680
|
|
681
681
|
def assert_publishing_api_put_intent(base_path, attributes_or_matcher = {}, times = 1)
|
682
|
-
url = PUBLISHING_API_ENDPOINT
|
682
|
+
url = "#{PUBLISHING_API_ENDPOINT}/publish-intent#{base_path}"
|
683
683
|
assert_publishing_api_put(url, attributes_or_matcher, times)
|
684
684
|
end
|
685
685
|
|
@@ -792,8 +792,7 @@ module GdsApi
|
|
792
792
|
def stub_publishing_api_returns_path_reservation_validation_error_for(base_path, error_fields = {})
|
793
793
|
error_fields = { "base_path" => ["Computer says no"] } if error_fields.empty?
|
794
794
|
|
795
|
-
message = error_fields.keys.first.to_s.capitalize.gsub(/_/,
|
796
|
-
error_fields.values.flatten.first
|
795
|
+
message = "#{error_fields.keys.first.to_s.capitalize.gsub(/_/, ' ')} #{error_fields.values.flatten.first}"
|
797
796
|
|
798
797
|
error = { code: 422, message: message, fields: error_fields }
|
799
798
|
|
@@ -817,7 +816,7 @@ module GdsApi
|
|
817
816
|
response_hash = { status: 200, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" } }
|
818
817
|
response_hash.merge!(override_response_hash)
|
819
818
|
response_hash[:body] = response_hash[:body].to_json if response_hash[:body].is_a?(Hash)
|
820
|
-
url = PUBLISHING_API_V2_ENDPOINT
|
819
|
+
url = "#{PUBLISHING_API_V2_ENDPOINT}#{resource_path}/#{content_id}"
|
821
820
|
stub_request(method, url).with(body: body).to_return(response_hash)
|
822
821
|
end
|
823
822
|
|
@@ -858,7 +857,7 @@ module GdsApi
|
|
858
857
|
end
|
859
858
|
|
860
859
|
def stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, code)
|
861
|
-
url = PUBLISHING_API_ENDPOINT
|
860
|
+
url = "#{PUBLISHING_API_ENDPOINT}/paths#{base_path}"
|
862
861
|
body = { publishing_app: publishing_app }
|
863
862
|
stub_request(:delete, url).with(body: body).to_return(status: code, body: "{}", headers: { "Content-Type" => "application/json; charset=utf-8" })
|
864
863
|
end
|
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: 71.3.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: 2021-
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -266,16 +266,16 @@ dependencies:
|
|
266
266
|
name: rubocop-govuk
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
268
268
|
requirements:
|
269
|
-
- -
|
269
|
+
- - '='
|
270
270
|
- !ruby/object:Gem::Version
|
271
|
-
version:
|
271
|
+
version: 4.0.0.pre.1
|
272
272
|
type: :development
|
273
273
|
prerelease: false
|
274
274
|
version_requirements: !ruby/object:Gem::Requirement
|
275
275
|
requirements:
|
276
|
-
- -
|
276
|
+
- - '='
|
277
277
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
278
|
+
version: 4.0.0.pre.1
|
279
279
|
- !ruby/object:Gem::Dependency
|
280
280
|
name: simplecov
|
281
281
|
requirement: !ruby/object:Gem::Requirement
|
@@ -371,6 +371,7 @@ files:
|
|
371
371
|
- Rakefile
|
372
372
|
- lib/gds-api-adapters.rb
|
373
373
|
- lib/gds_api.rb
|
374
|
+
- lib/gds_api/account_api.rb
|
374
375
|
- lib/gds_api/asset_manager.rb
|
375
376
|
- lib/gds_api/base.rb
|
376
377
|
- lib/gds_api/calendars.rb
|
@@ -388,8 +389,6 @@ files:
|
|
388
389
|
- lib/gds_api/maslow.rb
|
389
390
|
- lib/gds_api/middleware/govuk_header_sniffer.rb
|
390
391
|
- lib/gds_api/organisations.rb
|
391
|
-
- lib/gds_api/performance_platform/data_in.rb
|
392
|
-
- lib/gds_api/performance_platform/data_out.rb
|
393
392
|
- lib/gds_api/publishing_api.rb
|
394
393
|
- lib/gds_api/publishing_api/special_route_publisher.rb
|
395
394
|
- lib/gds_api/railtie.rb
|
@@ -398,6 +397,7 @@ files:
|
|
398
397
|
- lib/gds_api/search.rb
|
399
398
|
- lib/gds_api/support.rb
|
400
399
|
- lib/gds_api/support_api.rb
|
400
|
+
- lib/gds_api/test_helpers/account_api.rb
|
401
401
|
- lib/gds_api/test_helpers/asset_manager.rb
|
402
402
|
- lib/gds_api/test_helpers/calendars.rb
|
403
403
|
- lib/gds_api/test_helpers/common_responses.rb
|
@@ -411,8 +411,6 @@ files:
|
|
411
411
|
- lib/gds_api/test_helpers/local_links_manager.rb
|
412
412
|
- lib/gds_api/test_helpers/mapit.rb
|
413
413
|
- lib/gds_api/test_helpers/organisations.rb
|
414
|
-
- lib/gds_api/test_helpers/performance_platform/data_in.rb
|
415
|
-
- lib/gds_api/test_helpers/performance_platform/data_out.rb
|
416
414
|
- lib/gds_api/test_helpers/publishing_api.rb
|
417
415
|
- lib/gds_api/test_helpers/router.rb
|
418
416
|
- lib/gds_api/test_helpers/search.rb
|
@@ -440,14 +438,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
440
438
|
requirements:
|
441
439
|
- - ">="
|
442
440
|
- !ruby/object:Gem::Version
|
443
|
-
version: 2.
|
441
|
+
version: 2.6.0
|
444
442
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
445
443
|
requirements:
|
446
444
|
- - ">="
|
447
445
|
- !ruby/object:Gem::Version
|
448
446
|
version: '0'
|
449
447
|
requirements: []
|
450
|
-
rubygems_version: 3.
|
448
|
+
rubygems_version: 3.0.3
|
451
449
|
signing_key:
|
452
450
|
specification_version: 4
|
453
451
|
summary: Adapters to work with GDS APIs
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module GdsApi
|
4
|
-
class PerformancePlatformDatasetNotConfigured < BaseError; end
|
5
|
-
|
6
|
-
module PerformancePlatform
|
7
|
-
class DataIn < GdsApi::Base
|
8
|
-
def submit_service_feedback_day_aggregate(slug, request_details)
|
9
|
-
post_json("#{endpoint}/data/#{slug}/customer-satisfaction", request_details)
|
10
|
-
rescue GdsApi::HTTPNotFound
|
11
|
-
raise PerformancePlatformDatasetNotConfigured, "Dataset for slug [#{slug}] not set up"
|
12
|
-
end
|
13
|
-
|
14
|
-
def corporate_content_problem_report_count(entries)
|
15
|
-
post_json("#{endpoint}/data/gov-uk-content/feedback-count", entries)
|
16
|
-
end
|
17
|
-
|
18
|
-
def corporate_content_urls_with_the_most_problem_reports(entries)
|
19
|
-
post_json("#{endpoint}/data/gov-uk-content/top-urls", entries)
|
20
|
-
end
|
21
|
-
|
22
|
-
def submit_problem_report_daily_totals(entries)
|
23
|
-
post_json("#{endpoint}/data/govuk-info/page-contacts", entries)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module GdsApi
|
4
|
-
module PerformancePlatform
|
5
|
-
class DataOut < GdsApi::Base
|
6
|
-
# Fetch all service feedback from the performance platform for a given transaction
|
7
|
-
# page slug.
|
8
|
-
#
|
9
|
-
# Makes a +GET+ request.
|
10
|
-
#
|
11
|
-
# The results are ordered date ascending.
|
12
|
-
#
|
13
|
-
# @param transaction_page_slug [String] The slug for which service feedback is
|
14
|
-
# needed.
|
15
|
-
#
|
16
|
-
# # @example
|
17
|
-
#
|
18
|
-
# performance_platform_data_out.service_feedback('register-to-vote')
|
19
|
-
#
|
20
|
-
# #=> {
|
21
|
-
# "data": [
|
22
|
-
# {
|
23
|
-
# "_day_start_at": "2014-06-10T00:00:00+00:00",
|
24
|
-
# "_hour_start_at": "2014-06-10T00:00:00+00:00",
|
25
|
-
# "_id": "20140610_register-to-vote",
|
26
|
-
# "_month_start_at": "2014-06-01T00:00:00+00:00",
|
27
|
-
# "_quarter_start_at": "2014-04-01T00:00:00+00:00",
|
28
|
-
# "_timestamp": "2014-06-10T00:00:00+00:00",
|
29
|
-
# "_updated_at": "2014-06-11T00:30:50.901000+00:00",
|
30
|
-
# "_week_start_at": "2014-06-09T00:00:00+00:00",
|
31
|
-
# "comments": 217,
|
32
|
-
# "period": "day",
|
33
|
-
# "rating_1": 4,
|
34
|
-
# "rating_2": 6,
|
35
|
-
# "rating_3": 7,
|
36
|
-
# "rating_4": 74,
|
37
|
-
# "rating_5": 574,
|
38
|
-
# "slug": "register-to-vote",
|
39
|
-
# "total": 665
|
40
|
-
# },
|
41
|
-
# ...
|
42
|
-
# }
|
43
|
-
def service_feedback(transaction_page_slug)
|
44
|
-
get_json("#{endpoint}/data/#{transaction_page_slug}/customer-satisfaction")
|
45
|
-
end
|
46
|
-
|
47
|
-
# Fetching statistics data from the performance platform for a given page slug
|
48
|
-
#
|
49
|
-
# Makes a +GET+ request.
|
50
|
-
#
|
51
|
-
# @param slug [String] Points to the page for which we are requesting
|
52
|
-
# statistics.
|
53
|
-
# @param is_multipart [Boolean] Flag that marks whether the slug is multipart
|
54
|
-
# or not:
|
55
|
-
#
|
56
|
-
# - simple: `/european-health-insurance-card`
|
57
|
-
# - multipart: `/european-health-insurance-card/123`
|
58
|
-
#
|
59
|
-
# # @examples
|
60
|
-
#
|
61
|
-
# 1. Without multipart filtering:
|
62
|
-
#
|
63
|
-
# performance_platform_data_out.search_terms('/european-health-insurance-card')
|
64
|
-
#
|
65
|
-
# 2. With multipart filtering:
|
66
|
-
#
|
67
|
-
# performance_platform_data_out.searches('/european-health-insurance-card', true)
|
68
|
-
# performance_platform_data_out.page_views('/european-health-insurance-card', true)
|
69
|
-
# performance_platform_data_out.problem_reports('/european-health-insurance-card', true)
|
70
|
-
|
71
|
-
def search_terms(slug)
|
72
|
-
options = {
|
73
|
-
slug: slug,
|
74
|
-
transaction: "search-terms",
|
75
|
-
group_by: "searchKeyword",
|
76
|
-
collect: "searchUniques:sum",
|
77
|
-
}
|
78
|
-
statistics(options)
|
79
|
-
end
|
80
|
-
|
81
|
-
def searches(slug, is_multipart)
|
82
|
-
options = {
|
83
|
-
slug: slug,
|
84
|
-
transaction: "search-terms",
|
85
|
-
group_by: "pagePath",
|
86
|
-
collect: "searchUniques:sum",
|
87
|
-
}
|
88
|
-
statistics(options, is_multipart)
|
89
|
-
end
|
90
|
-
|
91
|
-
def page_views(slug, is_multipart)
|
92
|
-
options = {
|
93
|
-
slug: slug,
|
94
|
-
transaction: "page-statistics",
|
95
|
-
group_by: "pagePath",
|
96
|
-
collect: "uniquePageviews:sum",
|
97
|
-
}
|
98
|
-
statistics(options, is_multipart)
|
99
|
-
end
|
100
|
-
|
101
|
-
def problem_reports(slug, is_multipart)
|
102
|
-
options = {
|
103
|
-
slug: slug,
|
104
|
-
transaction: "page-contacts",
|
105
|
-
group_by: "pagePath",
|
106
|
-
collect: "total:sum",
|
107
|
-
}
|
108
|
-
statistics(options, is_multipart)
|
109
|
-
end
|
110
|
-
|
111
|
-
# This can be used as a free form call to the performance platform.
|
112
|
-
# The performance platform uses Backdrop and its query language for
|
113
|
-
# storing and querying data.
|
114
|
-
# Backdrop can be found here: https://github.com/alphagov/backdrop
|
115
|
-
def statistics(options, is_multipart = false)
|
116
|
-
params = {
|
117
|
-
group_by: options[:group_by],
|
118
|
-
collect: options[:collect],
|
119
|
-
duration: 42,
|
120
|
-
period: "day",
|
121
|
-
end_at: Date.today.to_time.getutc.iso8601,
|
122
|
-
}
|
123
|
-
|
124
|
-
filter_param = is_multipart ? :filter_by_prefix : :filter_by
|
125
|
-
params[filter_param] = "pagePath:" + options[:slug]
|
126
|
-
|
127
|
-
get_json("#{endpoint}/data/govuk-info/#{options[:transaction]}#{query_string(params)}")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|