gds-api-adapters 36.0.1 → 36.1.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
  SHA1:
3
- metadata.gz: 32b60409e9f3b162e8dbe7f8a34c45359de60cfd
4
- data.tar.gz: d8521c663666103d7a84d67d52c750da6e989ff3
3
+ metadata.gz: bcbac32e46d147fa75d158358e3f43b858dc717f
4
+ data.tar.gz: f0085c380372ea653dbe604d12b956ce47cfb6c9
5
5
  SHA512:
6
- metadata.gz: 5c318720e3148b537583771dc8aba4ef80f035e7ce24200fe1592e51aed0f46c5ad63d68ffc1f11abe921fa4e43daa319c2cb983b51517853da545d3e4819089
7
- data.tar.gz: ded39f290c4f4c81cb3e30212e03c6ba049a4fec18c19fd49a0df7f60d806e7f5b452f8306d7ae9c59a761dd919afbbf9361c4533ab9b02ac4e4729dd3c300c5
6
+ metadata.gz: 777ae29ce2fd0b642452b4bf84c292a0aa2b198b1945ddccfce464841c6c119ac912e8308b228fd8dceee1ef4185e0809b7eeaf8ca6e2c155b4e8f6495724a35
7
+ data.tar.gz: 5a7182ee26869c0ee8da18208538a3032a5501980109974bea46f482ee5ab40d570dacfc1f0236cbd90f877ca20faef423fed7369b51db91370a7c63d7036f0d
@@ -47,4 +47,75 @@ class GdsApi::SupportApi < GdsApi::Base
47
47
  def feedback_export_request(id)
48
48
  get_json!("#{endpoint}/anonymous-feedback/export-requests/#{id}")
49
49
  end
50
+
51
+ # Fetch a list of problem reports.
52
+ #
53
+ # Makes a +GET+ request.
54
+ #
55
+ # If no options are supplied, the first page of unreviewed feedback is returned.
56
+ #
57
+ # The results are ordered date descending.
58
+ #
59
+ # # ==== Options [+Hash+]
60
+ #
61
+ # * +:from_date+ - from date for list of reports.
62
+ # * +:to_date+ - to date for list of reports.
63
+ # * +:page+ - page number for reports.
64
+ # * +:include_reviewed+ - if true, includes reviewed reports in the list.
65
+ #
66
+ # # @example
67
+ #
68
+ # support_api.problem_reports({ from_date: '2016-12-12', to_date: '2016-12-13', page: 1, include_reviewed: true }).to_h
69
+ #
70
+ # #=> {
71
+ # results: [
72
+ # {
73
+ # id: 1,
74
+ # type: "problem-report",
75
+ # what_wrong: "Yeti",
76
+ # what_doing: "Skiing",
77
+ # url: "http://www.dev.gov.uk/skiing",
78
+ # referrer: "https://www.gov.uk/browse",
79
+ # user_agent: "Safari",
80
+ # path: "/skiing",
81
+ # marked_as_spam: false,
82
+ # reviewed: true,
83
+ # created_at: "2015-01-01T16:00:00.000Z"
84
+ # },
85
+ # ...
86
+ # ]
87
+ # total_count: 1000,
88
+ # current_page: 1,
89
+ # pages: 50,
90
+ # page_size: 50
91
+ # }
92
+ def problem_reports(options = {})
93
+ uri = "#{endpoint}/anonymous-feedback/problem-reports" + query_string(options)
94
+ get_json!(uri)
95
+ end
96
+
97
+ # Update multiple problem reports as reviewed for spam.
98
+ #
99
+ # Makes a +PUT+ request.
100
+ #
101
+ # @param request_details [Hash] Containing keys that match IDs of Problem
102
+ # Reports mapped to a boolean value - true if
103
+ # that report is to be marked as spam, or false otherwise.
104
+ #
105
+ # # @example
106
+ #
107
+ # support_api.mark_reviewed_for_spam({ "1" => false, "2" => true }).to_h
108
+ #
109
+ # #=> { "success" => true } (status: 200)
110
+ #
111
+ # # @example
112
+ #
113
+ # Where there is no problem report with ID of 1.
114
+ #
115
+ # support_api.mark_reviewed_for_spam({ "1" => true }).to_h
116
+ #
117
+ # #=> { "success" => false} (status: 400)
118
+ def mark_reviewed_for_spam(request_details)
119
+ put_json!("#{endpoint}/anonymous-feedback/problem-reports/mark-reviewed-for-spam", { reviewed_problem_report_ids: request_details })
120
+ end
50
121
  end
@@ -44,6 +44,18 @@ module GdsApi
44
44
  get_stub.to_return(response)
45
45
  end
46
46
 
47
+ def stub_support_problem_reports(params, response_body = {})
48
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports").
49
+ with(query: params).
50
+ to_return(status: 200, body: response_body.to_json)
51
+ end
52
+
53
+ def stub_support_mark_reviewed_for_spam(request_details = nil, response_body = {})
54
+ post_stub = stub_http_request(:put, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports/mark-reviewed-for-spam")
55
+ post_stub.with(:body => { reviewed_problem_report_ids: request_details}) unless request_details.nil?
56
+ post_stub.to_return(status: 200, body: response_body.to_json)
57
+ end
58
+
47
59
  def support_api_isnt_available
48
60
  stub_request(:post, /#{SUPPORT_API_ENDPOINT}\/.*/).to_return(:status => 503)
49
61
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '36.0.1'
2
+ VERSION = '36.1.0'
3
3
  end
@@ -71,7 +71,7 @@ describe GdsApi::SupportApi do
71
71
  page: 55,
72
72
  )
73
73
 
74
- result = @api.anonymous_feedback(
74
+ @api.anonymous_feedback(
75
75
  path_prefix: "/vat-rates",
76
76
  page: 55,
77
77
  )
@@ -112,7 +112,7 @@ describe GdsApi::SupportApi do
112
112
  assert_requested(stub_post)
113
113
  end
114
114
  end
115
-
115
+
116
116
  describe "POST /anonymous-feedback/global-export-requests" do
117
117
  it "makes a POST request to the support API" do
118
118
  params = {from_date: "1 June 2016", to_date: "8 June 2016", notification_email: "foo@example.com"}
@@ -152,4 +152,27 @@ describe GdsApi::SupportApi do
152
152
  assert_requested(stub_get)
153
153
  end
154
154
  end
155
+
156
+ describe "GET /anonymous-feedback/problem-reports" do
157
+ it "fetches a list of problem reports" do
158
+ params = { from_date: '2016-12-12', to_date: '2016-12-13', page: 1, exclude_reviewed: true }
159
+ stub_get = stub_support_problem_reports(params)
160
+
161
+ @api.problem_reports(params)
162
+
163
+ assert_requested(stub_get)
164
+ end
165
+ end
166
+
167
+ describe "POST /anonymous-feedback/problem-reports/mark-reviewed-for-spam" do
168
+ it "makes a PUT request to the support API" do
169
+ params = { "1" => true, "2" => true }
170
+
171
+ stub_post = stub_support_mark_reviewed_for_spam(params)
172
+
173
+ @api.mark_reviewed_for_spam(params)
174
+
175
+ assert_requested(stub_post)
176
+ end
177
+ end
155
178
  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: 36.0.1
4
+ version: 36.1.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: 2016-09-21 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek