gds-api-adapters 39.1.0 → 39.2.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: f3acffcc1511f8d85e7ee52c2bb523c7d0cc9466
4
- data.tar.gz: 70c23a71b3cd1eb1e14f0e7b398520abcb6039f3
3
+ metadata.gz: 514ed0bf0b20cf6fb1b1f83552a5fc849ffebde6
4
+ data.tar.gz: 2cb109d81ceac22dd0b4c03d10076fc317365f04
5
5
  SHA512:
6
- metadata.gz: 31b7e70207db38128aaa253364a9bcc29637902f34f84691f50788e6ab728ff95630a438b7740ba85335f10b17c10b9e9e0132d8d2cab6d0863e406f02407668
7
- data.tar.gz: 6cb54eea0cec2a11f48ac03f0ce1499dc17b6065bbc56c07821ef22254a8111a7553ca8ecf51e5ab45c7ee99c947dec75a70a83105017a946448349fe4d95cc2
6
+ metadata.gz: f34e133b44b931a0d371448e106546535811e6ad9983cda84e10505da269b7f648a7e8b19b815cf84a410a9aa86a57a697f28151da370733b2f32d8ea03b5a75
7
+ data.tar.gz: 5697109b3530b175c6125af6acbf4fad1b60a9b6359c6e194053da6c85d393cf3f1a872e28c1eee4b2867ecbb854317e065a20ddde5a05672de8bcec6a9dcff2
data/Rakefile CHANGED
@@ -45,9 +45,5 @@ require "gem_publisher"
45
45
  desc "Publish gem to rubygems.org if necessary"
46
46
  task :publish_gem do |_t|
47
47
  gem = GemPublisher.publish_if_updated("gds-api-adapters.gemspec", :rubygems)
48
- if gem
49
- puts "Published #{gem}"
50
-
51
- Rake::Task["pact:publish:released_version"].invoke
52
- end
48
+ puts "Published #{gem}" if gem
53
49
  end
@@ -99,6 +99,23 @@ class GdsApi::PublishingApiV2 < GdsApi::Base
99
99
  post_json(publish_url(content_id), params)
100
100
  end
101
101
 
102
+ # Import content into the publishing API
103
+ #
104
+ # The publishing-api will delete any content which has the content
105
+ # id provided, and then import the data given.
106
+ #
107
+ # @param content_id [UUID]
108
+ # @param content_items [Array]
109
+ #
110
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_idimport
111
+ def import(content_id, locale, content_items)
112
+ params = {
113
+ history: content_items,
114
+ }
115
+
116
+ post_json("#{endpoint}/v2/content/#{content_id}/import?locale=#{locale}", params)
117
+ end
118
+
102
119
  # Unpublish a content item
103
120
  #
104
121
  # The publishing API will "unpublish" a live item, to remove it from the public
@@ -296,7 +296,7 @@ module GdsApi
296
296
  # publishing_api_has_content allows for flexible passing in of arguments, please use instead
297
297
  def publishing_api_has_fields_for_document(document_type, items, fields)
298
298
  body = Array(items).map { |item|
299
- item.with_indifferent_access.slice(*fields)
299
+ deep_stringify_keys(item).slice(*fields)
300
300
  }
301
301
 
302
302
  query_params = fields.map { |f|
@@ -319,17 +319,19 @@ module GdsApi
319
319
  # Stub GET /v2/content/:content_id to return a specific content item hash
320
320
  #
321
321
  # @param item [Hash]
322
- def publishing_api_has_item(item)
323
- item = item.with_indifferent_access
322
+ def publishing_api_has_item(item, params = {})
323
+ item = deep_transform_keys(item, &:to_sym)
324
324
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + item[:content_id]
325
- stub_request(:get, url).to_return(status: 200, body: item.to_json, headers: {})
325
+ stub_request(:get, url)
326
+ .with(query: hash_including(params))
327
+ .to_return(status: 200, body: item.to_json, headers: {})
326
328
  end
327
329
 
328
330
  # Stub GET /v2/content/:content_id to progress through a series of responses.
329
331
  #
330
332
  # @param items [Array]
331
333
  def publishing_api_has_item_in_sequence(content_id, items)
332
- items = items.map(&:with_indifferent_access)
334
+ items = items.each { |item| deep_transform_keys(item, &:to_sym) }
333
335
  url = PUBLISHING_API_V2_ENDPOINT + "/content/" + content_id
334
336
  calls = -1
335
337
 
@@ -380,7 +382,7 @@ module GdsApi
380
382
  # "version" => 6
381
383
  # }
382
384
  def publishing_api_has_links(links)
383
- links = links.with_indifferent_access
385
+ links = deep_transform_keys(links, &:to_sym)
384
386
  url = PUBLISHING_API_V2_ENDPOINT + "/links/" + links[:content_id]
385
387
  stub_request(:get, url).to_return(status: 200, body: links.to_json, headers: {})
386
388
  end
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '39.1.0'.freeze
2
+ VERSION = '39.2.0'.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: 39.1.0
4
+ version: 39.2.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: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: plek