gds-api-adapters 5.4.0 → 5.5.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.
@@ -21,6 +21,12 @@ class GdsApi::GovUkDelivery < GdsApi::Base
21
21
  post_url(url, data)
22
22
  end
23
23
 
24
+ def signup_url(feed_url)
25
+ if response = get_json("#{base_url}/list-url?feed_url=#{CGI.escape(feed_url)}")
26
+ response.list_url
27
+ end
28
+ end
29
+
24
30
  def notify(feed_urls, subject, body)
25
31
  data = {feed_urls: feed_urls, subject: subject, body: body}
26
32
  url = "#{base_url}/notifications"
@@ -9,6 +9,10 @@ module GdsApi
9
9
  def stub_gov_uk_delivery_post_request(method, params_hash)
10
10
  stub_request(:post, "#{GOVUK_DELIVERY_ENDPOINT}/#{method}").with(body: params_hash.to_json)
11
11
  end
12
+
13
+ def stub_gov_uk_delivery_get_request(method, params_hash)
14
+ stub_request(:get, "#{GOVUK_DELIVERY_ENDPOINT}/#{method}?#{URI.encode_www_form(params_hash)}")
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '5.4.0'
2
+ VERSION = '5.5.0'
3
3
  end
@@ -35,9 +35,33 @@ describe GdsApi::GovUkDelivery do
35
35
  assert_requested stub
36
36
  end
37
37
 
38
+ it "can get a subscription URL" do
39
+ expected_payload = { feed_url: 'http://example.com/feed'}
40
+ stub = stub_gov_uk_delivery_get_request('list-url', expected_payload).to_return(created_response_json_hash({list_url: 'thing'}))
41
+
42
+ assert @api.signup_url('http://example.com/feed')
43
+ assert_requested stub
44
+ end
45
+
46
+ it "returns nil if the API 404s" do
47
+ expected_payload = { feed_url: 'http://example.com/feed'}
48
+ stub = stub_gov_uk_delivery_get_request('list-url', expected_payload).to_return(not_found_hash)
49
+
50
+ assert @api.signup_url('http://example.com/feed').nil?
51
+ end
52
+
38
53
  private
39
54
 
40
55
  def created_response_hash
41
56
  { body: '', status: 201 }
42
57
  end
58
+
59
+ def not_found_hash
60
+ { body: '', status: 404 }
61
+ end
62
+
63
+ def created_response_json_hash(data)
64
+ { body: data.to_json, status: 201 }
65
+ end
66
+
43
67
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gds-api-adapters
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 5.4.0
5
+ version: 5.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - James Stewart
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-04-11 00:00:00 Z
13
+ date: 2013-04-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: plek
@@ -187,54 +187,54 @@ extensions: []
187
187
  extra_rdoc_files: []
188
188
 
189
189
  files:
190
- - lib/gds_api/gov_uk_delivery.rb
191
190
  - lib/gds_api/version.rb
192
- - lib/gds_api/publisher.rb
191
+ - lib/gds_api/base.rb
192
+ - lib/gds_api/gov_uk_delivery.rb
193
+ - lib/gds_api/licence_application.rb
193
194
  - lib/gds_api/panopticon/registerer.rb
194
- - lib/gds_api/asset_manager.rb
195
- - lib/gds_api/content_api.rb
195
+ - lib/gds_api/needotron.rb
196
196
  - lib/gds_api/imminence.rb
197
+ - lib/gds_api/rummager.rb
198
+ - lib/gds_api/content_api.rb
199
+ - lib/gds_api/mapit.rb
200
+ - lib/gds_api/exceptions.rb
201
+ - lib/gds_api/json_client.rb
202
+ - lib/gds_api/core-ext/openstruct.rb
203
+ - lib/gds_api/response.rb
204
+ - lib/gds_api/content_api/list_response.rb
205
+ - lib/gds_api/content_api/response.rb
206
+ - lib/gds_api/publisher.rb
197
207
  - lib/gds_api/test_helpers/gov_uk_delivery.rb
198
- - lib/gds_api/test_helpers/publisher.rb
199
- - lib/gds_api/test_helpers/asset_manager.rb
200
- - lib/gds_api/test_helpers/content_api.rb
201
- - lib/gds_api/test_helpers/imminence.rb
202
208
  - lib/gds_api/test_helpers/licence_application.rb
209
+ - lib/gds_api/test_helpers/imminence.rb
210
+ - lib/gds_api/test_helpers/content_api.rb
203
211
  - lib/gds_api/test_helpers/mapit.rb
204
212
  - lib/gds_api/test_helpers/content_api/artefact_stub.rb
213
+ - lib/gds_api/test_helpers/publisher.rb
214
+ - lib/gds_api/test_helpers/asset_manager.rb
205
215
  - lib/gds_api/test_helpers/panopticon.rb
206
216
  - lib/gds_api/test_helpers/json_client_helper.rb
207
- - lib/gds_api/licence_application.rb
208
- - lib/gds_api/base.rb
209
- - lib/gds_api/mapit.rb
210
- - lib/gds_api/json_client.rb
211
- - lib/gds_api/response.rb
212
- - lib/gds_api/content_api/list_response.rb
213
- - lib/gds_api/content_api/response.rb
214
- - lib/gds_api/rummager.rb
215
- - lib/gds_api/panopticon.rb
216
- - lib/gds_api/core-ext/openstruct.rb
217
217
  - lib/gds_api/part_methods.rb
218
- - lib/gds_api/needotron.rb
219
- - lib/gds_api/exceptions.rb
218
+ - lib/gds_api/asset_manager.rb
219
+ - lib/gds_api/panopticon.rb
220
220
  - lib/gds_api/helpers.rb
221
221
  - README.md
222
222
  - Rakefile
223
- - test/panopticon_api_test.rb
223
+ - test/rummager_test.rb
224
224
  - test/publisher_api_test.rb
225
+ - test/content_api_response_test.rb
226
+ - test/licence_application_api_test.rb
225
227
  - test/mapit_test.rb
226
228
  - test/gov_uk_delivery_test.rb
227
- - test/rummager_test.rb
229
+ - test/panopticon_api_test.rb
228
230
  - test/imminence_api_test.rb
229
- - test/panopticon_registerer_test.rb
230
- - test/content_api_test.rb
231
- - test/asset_manager_test.rb
232
- - test/content_api_response_test.rb
233
231
  - test/json_client_test.rb
234
- - test/gds_api_base_test.rb
235
- - test/licence_application_api_test.rb
236
- - test/fixtures/hello.txt
237
232
  - test/test_helper.rb
233
+ - test/fixtures/hello.txt
234
+ - test/asset_manager_test.rb
235
+ - test/gds_api_base_test.rb
236
+ - test/content_api_test.rb
237
+ - test/panopticon_registerer_test.rb
238
238
  homepage: http://github.com/alphagov/gds-api-adapters
239
239
  licenses: []
240
240
 
@@ -248,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
248
248
  requirements:
249
249
  - - ">="
250
250
  - !ruby/object:Gem::Version
251
- hash: -1093811920964553750
251
+ hash: 3858152326931361631
252
252
  segments:
253
253
  - 0
254
254
  version: "0"
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  requirements:
258
258
  - - ">="
259
259
  - !ruby/object:Gem::Version
260
- hash: -1093811920964553750
260
+ hash: 3858152326931361631
261
261
  segments:
262
262
  - 0
263
263
  version: "0"
@@ -269,18 +269,18 @@ signing_key:
269
269
  specification_version: 3
270
270
  summary: Adapters to work with GDS APIs
271
271
  test_files:
272
- - test/panopticon_api_test.rb
272
+ - test/rummager_test.rb
273
273
  - test/publisher_api_test.rb
274
+ - test/content_api_response_test.rb
275
+ - test/licence_application_api_test.rb
274
276
  - test/mapit_test.rb
275
277
  - test/gov_uk_delivery_test.rb
276
- - test/rummager_test.rb
278
+ - test/panopticon_api_test.rb
277
279
  - test/imminence_api_test.rb
278
- - test/panopticon_registerer_test.rb
279
- - test/content_api_test.rb
280
- - test/asset_manager_test.rb
281
- - test/content_api_response_test.rb
282
280
  - test/json_client_test.rb
283
- - test/gds_api_base_test.rb
284
- - test/licence_application_api_test.rb
285
- - test/fixtures/hello.txt
286
281
  - test/test_helper.rb
282
+ - test/fixtures/hello.txt
283
+ - test/asset_manager_test.rb
284
+ - test/gds_api_base_test.rb
285
+ - test/content_api_test.rb
286
+ - test/panopticon_registerer_test.rb