gds-api-adapters 63.4.0 → 67.0.1

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -23
  3. data/Rakefile +7 -8
  4. data/lib/gds_api.rb +3 -15
  5. data/lib/gds_api/asset_manager.rb +1 -1
  6. data/lib/gds_api/base.rb +8 -3
  7. data/lib/gds_api/email_alert_api.rb +9 -9
  8. data/lib/gds_api/exceptions.rb +3 -4
  9. data/lib/gds_api/imminence.rb +3 -3
  10. data/lib/gds_api/json_client.rb +8 -8
  11. data/lib/gds_api/list_response.rb +6 -6
  12. data/lib/gds_api/performance_platform/data_out.rb +21 -21
  13. data/lib/gds_api/publishing_api.rb +2 -2
  14. data/lib/gds_api/response.rb +80 -6
  15. data/lib/gds_api/test_helpers/asset_manager.rb +0 -17
  16. data/lib/gds_api/test_helpers/calendars.rb +0 -9
  17. data/lib/gds_api/test_helpers/content_store.rb +0 -9
  18. data/lib/gds_api/test_helpers/email_alert_api.rb +9 -33
  19. data/lib/gds_api/test_helpers/imminence.rb +11 -14
  20. data/lib/gds_api/test_helpers/licence_application.rb +8 -16
  21. data/lib/gds_api/test_helpers/link_checker_api.rb +0 -8
  22. data/lib/gds_api/test_helpers/local_links_manager.rb +0 -13
  23. data/lib/gds_api/test_helpers/mapit.rb +15 -26
  24. data/lib/gds_api/test_helpers/organisations.rb +13 -18
  25. data/lib/gds_api/test_helpers/performance_platform/data_out.rb +34 -34
  26. data/lib/gds_api/test_helpers/publishing_api.rb +38 -59
  27. data/lib/gds_api/test_helpers/search.rb +5 -5
  28. data/lib/gds_api/test_helpers/support.rb +0 -5
  29. data/lib/gds_api/test_helpers/support_api.rb +16 -20
  30. data/lib/gds_api/test_helpers/worldwide.rb +52 -32
  31. data/lib/gds_api/version.rb +1 -1
  32. metadata +14 -31
  33. data/lib/gds_api/publishing_api_v2.rb +0 -14
  34. data/lib/gds_api/test_helpers/alias_deprecated.rb +0 -13
  35. data/lib/gds_api/test_helpers/publishing_api_v2.rb +0 -13
@@ -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,9 +1,6 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
-
3
1
  module GdsApi
4
2
  module TestHelpers
5
3
  module Support
6
- extend AliasDeprecated
7
4
  SUPPORT_ENDPOINT = Plek.current.find("support")
8
5
 
9
6
  def stub_support_foi_request_creation(request_details = nil)
@@ -21,8 +18,6 @@ module GdsApi
21
18
  def stub_support_isnt_available
22
19
  stub_request(:post, /#{SUPPORT_ENDPOINT}\/.*/).to_return(status: 503)
23
20
  end
24
-
25
- alias_deprecated :support_isnt_available, :stub_support_isnt_available
26
21
  end
27
22
  end
28
23
  end
@@ -1,11 +1,9 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "cgi"
3
2
  require "plek"
4
3
 
5
4
  module GdsApi
6
5
  module TestHelpers
7
6
  module SupportApi
8
- extend AliasDeprecated
9
7
  SUPPORT_API_ENDPOINT = Plek.current.find("support-api")
10
8
 
11
9
  def stub_support_api_problem_report_creation(request_details = nil)
@@ -65,9 +63,9 @@ module GdsApi
65
63
  end
66
64
 
67
65
  def stub_support_api_problem_reports(params, response_body = {})
68
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports").
69
- with(query: params).
70
- to_return(status: 200, body: response_body.to_json)
66
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/problem-reports")
67
+ .with(query: params)
68
+ .to_return(status: 200, body: response_body.to_json)
71
69
  end
72
70
 
73
71
  def stub_support_api_mark_reviewed_for_spam(request_details = nil, response_body = {})
@@ -89,8 +87,8 @@ module GdsApi
89
87
  def stub_support_api_anonymous_feedback_organisation_summary(slug, ordering = nil, response_body = {})
90
88
  uri = "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/organisations/#{slug}"
91
89
  uri << "?ordering=#{ordering}" if ordering
92
- stub_http_request(:get, uri).
93
- to_return(status: 200, body: response_body.to_json)
90
+ stub_http_request(:get, uri)
91
+ .to_return(status: 200, body: response_body.to_json)
94
92
  end
95
93
 
96
94
  def stub_support_api_organisations_list(response_body = nil)
@@ -111,8 +109,8 @@ module GdsApi
111
109
  },
112
110
  ]
113
111
 
114
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations").
115
- to_return(status: 200, body: response_body.to_json)
112
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations")
113
+ .to_return(status: 200, body: response_body.to_json)
116
114
  end
117
115
 
118
116
  def stub_support_api_organisation(slug = "cabinet-office", response_body = nil)
@@ -124,22 +122,22 @@ module GdsApi
124
122
  govuk_status: "live",
125
123
  }
126
124
 
127
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations/#{slug}").
128
- to_return(status: 200, body: response_body.to_json)
125
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/organisations/#{slug}")
126
+ .to_return(status: 200, body: response_body.to_json)
129
127
  end
130
128
 
131
129
  def stub_support_api_document_type_list(response_body = nil)
132
- response_body ||= %w(case_study detailed_guide smart_answer)
130
+ response_body ||= %w[case_study detailed_guide smart_answer]
133
131
 
134
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types").
135
- to_return(status: 200, body: response_body.to_json)
132
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types")
133
+ .to_return(status: 200, body: response_body.to_json)
136
134
  end
137
135
 
138
136
  def stub_support_api_anonymous_feedback_doc_type_summary(document_type, ordering = nil, response_body = nil)
139
137
  uri = "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/document-types/#{document_type}"
140
138
  uri << "?ordering=#{ordering}" if ordering
141
- stub_http_request(:get, uri).
142
- to_return(status: 200, body: response_body.to_json)
139
+ stub_http_request(:get, uri)
140
+ .to_return(status: 200, body: response_body.to_json)
143
141
  end
144
142
 
145
143
  def stub_support_api_feedback_export_request(id, response_body = nil)
@@ -148,15 +146,13 @@ module GdsApi
148
146
  ready: true,
149
147
  }
150
148
 
151
- stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/export-requests/#{id}").
152
- to_return(status: 200, body: response_body.to_json)
149
+ stub_http_request(:get, "#{SUPPORT_API_ENDPOINT}/anonymous-feedback/export-requests/#{id}")
150
+ .to_return(status: 200, body: response_body.to_json)
153
151
  end
154
152
 
155
153
  def stub_any_support_api_call
156
154
  stub_request(:any, %r{\A#{SUPPORT_API_ENDPOINT}})
157
155
  end
158
-
159
- alias_deprecated :support_api_isnt_available, :stub_support_api_isnt_available
160
156
  end
161
157
  end
162
158
  end
@@ -1,14 +1,12 @@
1
- require "gds_api/test_helpers/alias_deprecated"
2
1
  require "gds_api/test_helpers/json_client_helper"
3
2
  require "gds_api/test_helpers/common_responses"
4
3
 
5
4
  module GdsApi
6
5
  module TestHelpers
7
6
  module Worldwide
8
- extend AliasDeprecated
9
7
  include GdsApi::TestHelpers::CommonResponses
10
8
 
11
- WORLDWIDE_API_ENDPOINT = Plek.current.find("whitehall-frontend")
9
+ WORLDWIDE_API_ENDPOINT = Plek.new.website_root
12
10
 
13
11
  # Sets up the index endpoints for the given country slugs
14
12
  # The stubs are setup to paginate in chunks of 20
@@ -23,12 +21,14 @@ module GdsApi
23
21
  end
24
22
 
25
23
  pages.each_with_index do |page, i|
26
- page_details = plural_response_base.merge("results" => page,
24
+ page_details = plural_response_base.merge(
25
+ "results" => page,
27
26
  "total" => location_slugs.size,
28
27
  "pages" => pages.size,
29
28
  "current_page" => i + 1,
30
29
  "page_size" => 20,
31
- "start_index" => i * 20 + 1)
30
+ "start_index" => i * 20 + 1,
31
+ )
32
32
 
33
33
  links = { self: "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 1}" }
34
34
  links[:next] = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations?page=#{i + 2}" if pages[i + 1]
@@ -40,32 +40,59 @@ module GdsApi
40
40
  link_headers << "<#{href}>; rel=\"#{rel}\""
41
41
  end
42
42
 
43
- stub_request(:get, links[:self]).
44
- to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
43
+ stub_request(:get, links[:self])
44
+ .to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
45
45
 
46
- if i.zero?
47
- # First page exists at URL with and without page param
48
- stub_request(:get, links[:self].sub(/\?page=1/, "")).
49
- to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
50
- end
46
+ next unless i.zero?
47
+
48
+ # First page exists at URL with and without page param
49
+ stub_request(:get, links[:self].sub(/\?page=1/, ""))
50
+ .to_return(status: 200, body: page_details.to_json, headers: { "Link" => link_headers.join(", ") })
51
51
  end
52
52
  end
53
53
 
54
54
  def stub_worldwide_api_has_selection_of_locations
55
- stub_worldwide_api_has_locations %w(
56
- afghanistan angola australia bahamas belarus brazil brunei cambodia chad
57
- croatia denmark eritrea france ghana iceland japan laos luxembourg malta
58
- micronesia mozambique nicaragua panama portugal sao-tome-and-principe singapore
59
- south-korea sri-lanka uk-delegation-to-council-of-europe
55
+ stub_worldwide_api_has_locations %w[
56
+ afghanistan
57
+ angola
58
+ australia
59
+ bahamas
60
+ belarus
61
+ brazil
62
+ brunei
63
+ cambodia
64
+ chad
65
+ croatia
66
+ denmark
67
+ eritrea
68
+ france
69
+ ghana
70
+ iceland
71
+ japan
72
+ laos
73
+ luxembourg
74
+ malta
75
+ micronesia
76
+ mozambique
77
+ nicaragua
78
+ panama
79
+ portugal
80
+ sao-tome-and-principe
81
+ singapore
82
+ south-korea
83
+ sri-lanka
84
+ uk-delegation-to-council-of-europe
60
85
  uk-delegation-to-organization-for-security-and-co-operation-in-europe
61
- united-kingdom venezuela vietnam
62
- )
86
+ united-kingdom
87
+ venezuela
88
+ vietnam
89
+ ]
63
90
  end
64
91
 
65
92
  def stub_worldwide_api_has_location(location_slug, details = nil)
66
93
  details ||= world_location_for_slug(location_slug)
67
- stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}").
68
- to_return(status: 200, body: details.to_json)
94
+ stub_request(:get, "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}")
95
+ .to_return(status: 200, body: details.to_json)
69
96
  end
70
97
 
71
98
  def stub_worldwide_api_does_not_have_location(location_slug)
@@ -75,15 +102,15 @@ module GdsApi
75
102
  def stub_worldwide_api_has_organisations_for_location(location_slug, json_or_hash)
76
103
  json = json_or_hash.is_a?(Hash) ? json_or_hash.to_json : json_or_hash
77
104
  url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
78
- stub_request(:get, url).
79
- to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
105
+ stub_request(:get, url)
106
+ .to_return(status: 200, body: json, headers: { "Link" => "<#{url}; rel\"self\"" })
80
107
  end
81
108
 
82
109
  def stub_worldwide_api_has_no_organisations_for_location(location_slug)
83
110
  details = { "results" => [], "total" => 0, "_response_info" => { "status" => "ok" } }
84
111
  url = "#{WORLDWIDE_API_ENDPOINT}/api/world-locations/#{location_slug}/organisations"
85
- stub_request(:get, url).
86
- to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
112
+ stub_request(:get, url)
113
+ .to_return(status: 200, body: details.to_json, headers: { "Link" => "<#{url}; rel\"self\"" })
87
114
  end
88
115
 
89
116
  def world_location_for_slug(slug)
@@ -112,13 +139,6 @@ module GdsApi
112
139
  "content_id" => "content_id_for_#{slug}",
113
140
  }
114
141
  end
115
-
116
- alias_deprecated :worldwide_api_has_locations, :stub_worldwide_api_has_locations
117
- alias_deprecated :worldwide_api_has_selection_of_locations, :stub_worldwide_api_has_selection_of_locations
118
- alias_deprecated :worldwide_api_has_location, :stub_worldwide_api_has_location
119
- alias_deprecated :worldwide_api_has_does_not_have_location, :stub_worldwide_api_does_not_have_location
120
- alias_deprecated :worldwide_api_has_organisations_for_location, :stub_worldwide_api_has_organisations_for_location
121
- alias_deprecated :worldwide_api_has_no_organisations_for_location, :stub_worldwide_api_has_no_organisations_for_location
122
142
  end
123
143
  end
124
144
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "63.4.0".freeze
2
+ VERSION = "67.0.1".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.4.0
4
+ version: 67.0.1
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-10 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.9.0
69
- - !ruby/object:Gem::Dependency
70
- name: rack-cache
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rest-client
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +142,14 @@ dependencies:
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: '1.3'
145
+ version: '1.11'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: '1.3'
152
+ version: '1.11'
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: pact
169
155
  requirement: !ruby/object:Gem::Requirement
@@ -179,47 +165,47 @@ dependencies:
179
165
  - !ruby/object:Gem::Version
180
166
  version: '1.20'
181
167
  - !ruby/object:Gem::Dependency
182
- name: pact-consumer-minitest
168
+ name: pact_broker-client
183
169
  requirement: !ruby/object:Gem::Requirement
184
170
  requirements:
185
171
  - - "~>"
186
172
  - !ruby/object:Gem::Version
187
- version: '1.0'
173
+ version: '1.14'
188
174
  type: :development
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
- version: '1.0'
180
+ version: '1.14'
195
181
  - !ruby/object:Gem::Dependency
196
- name: pact-mock_service
182
+ name: pact-consumer-minitest
197
183
  requirement: !ruby/object:Gem::Requirement
198
184
  requirements:
199
185
  - - "~>"
200
186
  - !ruby/object:Gem::Version
201
- version: '2.6'
187
+ version: '1.0'
202
188
  type: :development
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
192
  - - "~>"
207
193
  - !ruby/object:Gem::Version
208
- version: '2.6'
194
+ version: '1.0'
209
195
  - !ruby/object:Gem::Dependency
210
- name: pact_broker-client
196
+ name: pact-mock_service
211
197
  requirement: !ruby/object:Gem::Requirement
212
198
  requirements:
213
199
  - - "~>"
214
200
  - !ruby/object:Gem::Version
215
- version: '1.14'
201
+ version: '2.6'
216
202
  type: :development
217
203
  prerelease: false
218
204
  version_requirements: !ruby/object:Gem::Requirement
219
205
  requirements:
220
206
  - - "~>"
221
207
  - !ruby/object:Gem::Version
222
- version: '1.14'
208
+ version: '2.6'
223
209
  - !ruby/object:Gem::Dependency
224
210
  name: pry
225
211
  requirement: !ruby/object:Gem::Requirement
@@ -406,14 +392,12 @@ files:
406
392
  - lib/gds_api/performance_platform/data_out.rb
407
393
  - lib/gds_api/publishing_api.rb
408
394
  - lib/gds_api/publishing_api/special_route_publisher.rb
409
- - lib/gds_api/publishing_api_v2.rb
410
395
  - lib/gds_api/railtie.rb
411
396
  - lib/gds_api/response.rb
412
397
  - lib/gds_api/router.rb
413
398
  - lib/gds_api/search.rb
414
399
  - lib/gds_api/support.rb
415
400
  - lib/gds_api/support_api.rb
416
- - lib/gds_api/test_helpers/alias_deprecated.rb
417
401
  - lib/gds_api/test_helpers/asset_manager.rb
418
402
  - lib/gds_api/test_helpers/calendars.rb
419
403
  - lib/gds_api/test_helpers/common_responses.rb
@@ -430,7 +414,6 @@ files:
430
414
  - lib/gds_api/test_helpers/performance_platform/data_in.rb
431
415
  - lib/gds_api/test_helpers/performance_platform/data_out.rb
432
416
  - lib/gds_api/test_helpers/publishing_api.rb
433
- - lib/gds_api/test_helpers/publishing_api_v2.rb
434
417
  - lib/gds_api/test_helpers/router.rb
435
418
  - lib/gds_api/test_helpers/search.rb
436
419
  - lib/gds_api/test_helpers/support.rb
@@ -457,7 +440,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
457
440
  requirements:
458
441
  - - ">="
459
442
  - !ruby/object:Gem::Version
460
- version: 2.3.0
443
+ version: 2.4.0
461
444
  required_rubygems_version: !ruby/object:Gem::Requirement
462
445
  requirements:
463
446
  - - ">="
@@ -1,14 +0,0 @@
1
- require_relative "publishing_api"
2
-
3
- # Adapter for the Publishing API.
4
- #
5
- # @see https://github.com/alphagov/publishing-api
6
- # @see https://github.com/alphagov/publishing-api/blob/master/doc/publishing-application-examples.md
7
- # @see https://github.com/alphagov/publishing-api/blob/master/doc/model.md
8
- # @api documented
9
- class GdsApi::PublishingApiV2 < GdsApi::PublishingApi
10
- def initialize(*args)
11
- warn "GdsApi::PublishingApiV2 is deprecated. Use GdsApi::PublishingApi instead."
12
- super
13
- end
14
- end
@@ -1,13 +0,0 @@
1
- module GdsApi
2
- module TestHelpers
3
- module AliasDeprecated
4
- def alias_deprecated(deprecated_method, replacement_method)
5
- class_name = self.name
6
- define_method(deprecated_method) do |*args, &block|
7
- warn "##{deprecated_method} is deprecated on #{class_name} and will be removed in a future version. Use ##{replacement_method} instead"
8
- public_send(replacement_method, *args, &block)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- require "gds_api/test_helpers/publishing_api"
2
-
3
- module GdsApi
4
- module TestHelpers
5
- module PublishingApiV2
6
- include PublishingApi
7
-
8
- def self.included(_base)
9
- warn "GdsApi::TestHelpers::PublishingApiV2 is deprecated. Use GdsApi::TestHelpers::PublishingApi instead."
10
- end
11
- end
12
- end
13
- end