gds-api-adapters 50.2.0 → 50.3.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.
- checksums.yaml +4 -4
- data/lib/gds_api/publishing_api_v2.rb +22 -0
- data/lib/gds_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0fef63242aff99968f8b74fa2282bf02ea6bc37
|
4
|
+
data.tar.gz: a4ecc3443d8c47072780ae0bb317888c620b4fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b4b790f31b5c9ae6db87bcdd2f8315bbc02db77bc6ec382c8f384f801883583f0ac3a2a4732fd048d03b5a61abb6f87955c38e31350fd8887700674ca8186c
|
7
|
+
data.tar.gz: 191a7631b353ce367f4c1cb00a8ccf780effce1f6244e85bf826f0ca8230c436fc582921ee7ce9cb144e48dc67016a50fa199353df679a06bcaa708bd61a3f7a
|
@@ -315,6 +315,28 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
315
315
|
get_json("#{endpoint}/v2/content#{query}")
|
316
316
|
end
|
317
317
|
|
318
|
+
# Returns an Enumerator of content items for the provided
|
319
|
+
# query string parameters.
|
320
|
+
#
|
321
|
+
# @param params [Hash]
|
322
|
+
#
|
323
|
+
# @return [Enumerator] an enumerator of content items
|
324
|
+
#
|
325
|
+
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2content
|
326
|
+
def get_content_items_enum(params)
|
327
|
+
Enumerator.new do |yielder|
|
328
|
+
(1..Float::INFINITY).each do |index|
|
329
|
+
merged_params = params.merge(page: index)
|
330
|
+
page = get_content_items(merged_params).to_h
|
331
|
+
results = page.fetch('results', [])
|
332
|
+
results.each do |result|
|
333
|
+
yielder << result
|
334
|
+
end
|
335
|
+
break if page.fetch('pages') <= index
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
318
340
|
# FIXME: Add documentation
|
319
341
|
#
|
320
342
|
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2linkables
|
data/lib/gds_api/version.rb
CHANGED