gds-api-adapters 70.0.0 → 71.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gds_api/account_api.rb +1 -1
- data/lib/gds_api/test_helpers/account_api.rb +2 -2
- data/lib/gds_api/version.rb +1 -1
- metadata +2 -6
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43e07de0971fb6d31f613c0e6ecf3894ddc198755ad003da36e6c43e37dedf5
|
4
|
+
data.tar.gz: 66369531af1d7c4412b79994759e360b78cb67b2e842a3d6f82e10267bd18876
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1f75189c94449dac72f8e3826b67c36d57e55a40103a69aa2cc48dce9cbc75eff901b060d2d360d301ec482bca4937f5178a57b3b53a1e497bb96ca1a84490
|
7
|
+
data.tar.gz: 2cca74c89f2a0f827a09917fe6817aeac7199871f1f4c990845668b68c7daff9889dd2f885c809399c732d98b8c074f607072c24db8ad438a287b23f96a5dcb9
|
data/lib/gds_api/account_api.rb
CHANGED
@@ -75,7 +75,7 @@ class GdsApi::AccountApi < GdsApi::Base
|
|
75
75
|
#
|
76
76
|
# @return [Hash] A new session header
|
77
77
|
def set_attributes(attributes:, govuk_account_session:)
|
78
|
-
patch_json("#{endpoint}/api/attributes", { attributes: attributes
|
78
|
+
patch_json("#{endpoint}/api/attributes", { attributes: attributes }, auth_headers(govuk_account_session))
|
79
79
|
end
|
80
80
|
|
81
81
|
private
|
@@ -87,11 +87,11 @@ module GdsApi
|
|
87
87
|
def stub_account_api_set_attributes(govuk_account_session: nil, attributes: nil, new_govuk_account_session: nil)
|
88
88
|
if govuk_account_session
|
89
89
|
stub_request(:patch, "#{ACCOUNT_API_ENDPOINT}/api/attributes")
|
90
|
-
.with(body: hash_including({ attributes: attributes
|
90
|
+
.with(body: hash_including({ attributes: attributes }.compact), headers: { GdsApi::AccountApi::AUTH_HEADER_NAME => govuk_account_session })
|
91
91
|
.to_return(status: 200, body: { govuk_account_session: new_govuk_account_session }.compact.to_json)
|
92
92
|
else
|
93
93
|
stub_request(:patch, "#{ACCOUNT_API_ENDPOINT}/api/attributes")
|
94
|
-
.with(body: hash_including({ attributes: attributes
|
94
|
+
.with(body: hash_including({ attributes: attributes }.compact))
|
95
95
|
.to_return(status: 200, body: { govuk_account_session: new_govuk_account_session }.compact.to_json)
|
96
96
|
end
|
97
97
|
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.0.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-03-
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -389,8 +389,6 @@ files:
|
|
389
389
|
- lib/gds_api/maslow.rb
|
390
390
|
- lib/gds_api/middleware/govuk_header_sniffer.rb
|
391
391
|
- lib/gds_api/organisations.rb
|
392
|
-
- lib/gds_api/performance_platform/data_in.rb
|
393
|
-
- lib/gds_api/performance_platform/data_out.rb
|
394
392
|
- lib/gds_api/publishing_api.rb
|
395
393
|
- lib/gds_api/publishing_api/special_route_publisher.rb
|
396
394
|
- lib/gds_api/railtie.rb
|
@@ -413,8 +411,6 @@ files:
|
|
413
411
|
- lib/gds_api/test_helpers/local_links_manager.rb
|
414
412
|
- lib/gds_api/test_helpers/mapit.rb
|
415
413
|
- lib/gds_api/test_helpers/organisations.rb
|
416
|
-
- lib/gds_api/test_helpers/performance_platform/data_in.rb
|
417
|
-
- lib/gds_api/test_helpers/performance_platform/data_out.rb
|
418
414
|
- lib/gds_api/test_helpers/publishing_api.rb
|
419
415
|
- lib/gds_api/test_helpers/router.rb
|
420
416
|
- lib/gds_api/test_helpers/search.rb
|
@@ -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) # rubocop:disable Style/OptionalBooleanParameter
|
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
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module GdsApi
|
2
|
-
module TestHelpers
|
3
|
-
module PerformancePlatform
|
4
|
-
module DataIn
|
5
|
-
PP_DATA_IN_ENDPOINT = "http://www.performance.dev.gov.uk".freeze
|
6
|
-
|
7
|
-
def stub_service_feedback_day_aggregate_submission(slug, request_body = nil)
|
8
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
9
|
-
post_stub.with(body: request_body) unless request_body.nil?
|
10
|
-
post_stub.to_return(status: 200)
|
11
|
-
end
|
12
|
-
|
13
|
-
def stub_corporate_content_problem_report_count_submission(submissions = nil)
|
14
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/gov-uk-content/feedback-count")
|
15
|
-
post_stub.with(body: submissions.to_json) unless submissions.nil?
|
16
|
-
post_stub.to_return(status: 200)
|
17
|
-
end
|
18
|
-
|
19
|
-
def stub_corporate_content_urls_with_the_most_problem_reports_submission(submissions = nil)
|
20
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/gov-uk-content/top-urls")
|
21
|
-
post_stub.with(body: submissions.to_json) unless submissions.nil?
|
22
|
-
post_stub.to_return(status: 200)
|
23
|
-
end
|
24
|
-
|
25
|
-
def stub_problem_report_daily_totals_submission(submissions = nil)
|
26
|
-
post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/govuk-info/page-contacts")
|
27
|
-
post_stub.with(body: submissions.to_json) unless submissions.nil?
|
28
|
-
post_stub.to_return(status: 200)
|
29
|
-
end
|
30
|
-
|
31
|
-
def stub_service_feedback_bucket_unavailable_for(slug)
|
32
|
-
stub_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/#{slug}/customer-satisfaction").to_return(status: 404)
|
33
|
-
end
|
34
|
-
|
35
|
-
def stub_pp_isnt_available
|
36
|
-
stub_request(:post, /#{PP_DATA_IN_ENDPOINT}\/.*/).to_return(status: 503)
|
37
|
-
end
|
38
|
-
|
39
|
-
def stub_pp_dataset_unavailable
|
40
|
-
stub_request(:any, /#{PP_DATA_IN_ENDPOINT}/).to_return(status: 404)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module GdsApi
|
2
|
-
module TestHelpers
|
3
|
-
module PerformancePlatform
|
4
|
-
module DataOut
|
5
|
-
PP_DATA_OUT_ENDPOINT = "https://www.performance.service.gov.uk".freeze
|
6
|
-
|
7
|
-
def stub_service_feedback(slug, response_body = {})
|
8
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
9
|
-
.to_return(status: 200, body: response_body.to_json)
|
10
|
-
end
|
11
|
-
|
12
|
-
def stub_data_set_not_available(slug)
|
13
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
|
14
|
-
.to_return(status: 404)
|
15
|
-
end
|
16
|
-
|
17
|
-
def stub_service_not_available
|
18
|
-
stub_request(:any, /#{PP_DATA_OUT_ENDPOINT}\/.*/).to_return(status: 503)
|
19
|
-
end
|
20
|
-
|
21
|
-
def stub_search_terms(slug, response_body = {})
|
22
|
-
options = {
|
23
|
-
slug: slug,
|
24
|
-
transaction: "search-terms",
|
25
|
-
group_by: "searchKeyword",
|
26
|
-
collect: "searchUniques:sum",
|
27
|
-
}
|
28
|
-
stub_statistics(options, false, response_body)
|
29
|
-
end
|
30
|
-
|
31
|
-
def stub_searches(slug, is_multipart, response_body = {})
|
32
|
-
options = {
|
33
|
-
slug: slug,
|
34
|
-
transaction: "search-terms",
|
35
|
-
group_by: "pagePath",
|
36
|
-
collect: "searchUniques:sum",
|
37
|
-
}
|
38
|
-
stub_statistics(options, is_multipart, response_body)
|
39
|
-
end
|
40
|
-
|
41
|
-
def stub_page_views(slug, is_multipart, response_body = {})
|
42
|
-
options = {
|
43
|
-
slug: slug,
|
44
|
-
transaction: "page-statistics",
|
45
|
-
group_by: "pagePath",
|
46
|
-
collect: "uniquePageviews:sum",
|
47
|
-
}
|
48
|
-
stub_statistics(options, is_multipart, response_body)
|
49
|
-
end
|
50
|
-
|
51
|
-
def stub_problem_reports(slug, is_multipart, response_body = {})
|
52
|
-
options = {
|
53
|
-
slug: slug,
|
54
|
-
transaction: "page-contacts",
|
55
|
-
group_by: "pagePath",
|
56
|
-
collect: "total:sum",
|
57
|
-
}
|
58
|
-
stub_statistics(options, is_multipart, response_body)
|
59
|
-
end
|
60
|
-
|
61
|
-
def stub_statistics(options, is_multipart, response_body = {})
|
62
|
-
params = {
|
63
|
-
group_by: options[:group_by],
|
64
|
-
collect: options[:collect],
|
65
|
-
duration: 42,
|
66
|
-
period: "day",
|
67
|
-
end_at: Date.today.to_time.getutc.iso8601,
|
68
|
-
}
|
69
|
-
|
70
|
-
filter_param = is_multipart ? :filter_by_prefix : :filter_by
|
71
|
-
params[filter_param] = "pagePath:#{options[:slug]}"
|
72
|
-
|
73
|
-
stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/#{options[:transaction]}")
|
74
|
-
.with(query: params)
|
75
|
-
.to_return(status: 200, body: response_body.to_json)
|
76
|
-
end
|
77
|
-
|
78
|
-
def stub_search_404(slug)
|
79
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms")
|
80
|
-
.with(query: hash_including(filter_by: slug))
|
81
|
-
.to_return(status: 404, headers: { content_type: "application/json" })
|
82
|
-
end
|
83
|
-
|
84
|
-
def stub_page_views_404(slug)
|
85
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics")
|
86
|
-
.with(query: hash_including(filter_by: slug))
|
87
|
-
.to_return(status: 404, headers: { content_type: "application/json" })
|
88
|
-
end
|
89
|
-
|
90
|
-
def stub_problem_reports_404(slug)
|
91
|
-
stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts")
|
92
|
-
.with(query: hash_including(filter_by: slug))
|
93
|
-
.to_return(status: 404, headers: { content_type: "application/json" })
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|