gds-api-adapters 47.2.0 → 47.2.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9beeebdd14a6ba6e0dcb9fe915f52098c375aee
|
4
|
+
data.tar.gz: 3571c136855f8bd8dde4401e1d6f03618053bf80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad6b6483bcaadf6e547e642d08e815644f9128bbfb538899d7d225652144512486462dd31c6092888d88908cd6f40aa67cac71bde46b126c4249a635fee8e650
|
7
|
+
data.tar.gz: 380cfbb331bb62003a27befb0b7cd84eaee1581f1b6b76a927ed07351a720c060b4491abe2940dbe56e59c3537720d29c0cb6f2279e5f11e2bcde096d420b9a5
|
@@ -29,10 +29,12 @@ module GdsApi
|
|
29
29
|
],
|
30
30
|
publishing_app: options.fetch(:publishing_app),
|
31
31
|
rendering_app: options.fetch(:rendering_app),
|
32
|
-
public_updated_at: time.now.iso8601
|
32
|
+
public_updated_at: time.now.iso8601,
|
33
|
+
update_type: options.fetch(:update_type, "major")
|
34
|
+
)
|
33
35
|
|
34
36
|
publishing_api.patch_links(options.fetch(:content_id), links: options[:links]) if options[:links]
|
35
|
-
publishing_api.publish(options.fetch(:content_id)
|
37
|
+
publishing_api.publish(options.fetch(:content_id))
|
36
38
|
put_content_response
|
37
39
|
end
|
38
40
|
|
@@ -312,6 +312,18 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
|
|
312
312
|
get_json("#{endpoint}/v2/linked/#{content_id}#{query}")
|
313
313
|
end
|
314
314
|
|
315
|
+
# Returns a paginated list of editions for the provided query string
|
316
|
+
# parameters.
|
317
|
+
#
|
318
|
+
# @param params [Hash]
|
319
|
+
#
|
320
|
+
# @return [GdsApi::Response] a paginated list of editions
|
321
|
+
#
|
322
|
+
# @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2editions
|
323
|
+
def get_editions(params = {})
|
324
|
+
get_json(get_editions_url(params))
|
325
|
+
end
|
326
|
+
|
315
327
|
private
|
316
328
|
|
317
329
|
def content_url(content_id, params = {})
|
@@ -340,6 +352,11 @@ private
|
|
340
352
|
"#{endpoint}/v2/content/#{content_id}/discard-draft"
|
341
353
|
end
|
342
354
|
|
355
|
+
def get_editions_url(params)
|
356
|
+
query = query_string(params)
|
357
|
+
"#{endpoint}/v2/editions#{query}"
|
358
|
+
end
|
359
|
+
|
343
360
|
def merge_optional_keys(params, options, optional_keys)
|
344
361
|
optional_keys.each_with_object(params) do |optional_key, hash|
|
345
362
|
hash.merge!(optional_key => options[optional_key]) if options[optional_key]
|
@@ -509,6 +509,40 @@ module GdsApi
|
|
509
509
|
)
|
510
510
|
end
|
511
511
|
|
512
|
+
# Stub GET /v2/editions to return a set of editions
|
513
|
+
#
|
514
|
+
# @example
|
515
|
+
#
|
516
|
+
# publishing_api_get_editions(
|
517
|
+
# vehicle_recalls_and_faults, # this is a variable containing an array of editions
|
518
|
+
# fields: fields, #example: let(:fields) { %i[base_path content_id public_updated_at title publication_state] }
|
519
|
+
# per_page: 50
|
520
|
+
# )
|
521
|
+
# @param items [Array]
|
522
|
+
# @param params [Hash]
|
523
|
+
def publishing_api_get_editions(editions, params = {})
|
524
|
+
url = PUBLISHING_API_V2_ENDPOINT + "/editions"
|
525
|
+
|
526
|
+
results = editions.map do |edition|
|
527
|
+
next edition unless params[:fields]
|
528
|
+
edition.select { |k| params[:fields].include?(k) }
|
529
|
+
end
|
530
|
+
|
531
|
+
per_page = (params[:per_page] || 100).to_i
|
532
|
+
results = results.take(per_page)
|
533
|
+
|
534
|
+
body = {
|
535
|
+
results: results,
|
536
|
+
links: [
|
537
|
+
{ rel: "self", href: "#{PUBLISHING_API_V2_ENDPOINT}/editions" },
|
538
|
+
],
|
539
|
+
}
|
540
|
+
|
541
|
+
stub_request(:get, url)
|
542
|
+
.with(query: params)
|
543
|
+
.to_return(status: 200, body: body.to_json, headers: {})
|
544
|
+
end
|
545
|
+
|
512
546
|
private
|
513
547
|
|
514
548
|
def stub_publishing_api_put(*args)
|
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: 47.2.
|
4
|
+
version: 47.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Stewart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: plek
|