gds-api-adapters 2.0.0 → 2.1.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.
@@ -13,7 +13,7 @@ class GdsApi::ContentApi < GdsApi::Base
13
13
  end
14
14
 
15
15
  def artefact(slug)
16
- get_json!("#{base_url}/#{slug}.json")
16
+ get_json("#{base_url}/#{slug}.json")
17
17
  end
18
18
 
19
19
  def local_authority(snac_code)
@@ -1,6 +1,7 @@
1
1
  require 'gds_api/publisher'
2
2
  require 'gds_api/imminence'
3
3
  require 'gds_api/panopticon'
4
+ require 'gds_api/content_api'
4
5
 
5
6
  module GdsApi
6
7
  module Helpers
@@ -24,10 +25,6 @@ module GdsApi
24
25
  Object::const_defined?(:PANOPTICON_API_CREDENTIALS) ? PANOPTICON_API_CREDENTIALS : {}
25
26
  end
26
27
 
27
- def fetch_artefact(params)
28
- panopticon_api.artefact_for_slug(params[:slug]) || OpenStruct.new(section: 'missing', need_id: 'missing', kind: 'missing')
29
- end
30
-
31
28
  def self.included(klass)
32
29
  if klass.respond_to?(:helper_method)
33
30
  klass.helper_method :publisher_api, :panopticon_api, :imminence_api, :content_api
@@ -31,7 +31,7 @@ module GdsApi
31
31
  'Content-Type' => 'application/json',
32
32
  'User-Agent' => "GDS Api Client v. #{GdsApi::VERSION}"
33
33
  }
34
- DEFAULT_TIMEOUT_IN_SECONDS = 2
34
+ DEFAULT_TIMEOUT_IN_SECONDS = 4
35
35
  DEFAULT_CACHE_SIZE = 10
36
36
 
37
37
  def get_raw(url)
@@ -44,6 +44,13 @@ module GdsApi
44
44
  stub_request(:get, url).to_return(status: 404, body: body.to_json, headers: {})
45
45
  end
46
46
 
47
+ def stub_content_api_default_artefact
48
+ stub_request(:get, %r{\A#{CONTENT_API_ENDPOINT}/[a-z0-9-]+\.json}).to_return { |request|
49
+ slug = request.uri.path.split('/').last.chomp('.json')
50
+ {:body => artefact_for_slug(slug).to_json}
51
+ }
52
+ end
53
+
47
54
  def artefact_for_slug(slug)
48
55
  singular_response_base.merge(
49
56
  "title" => titleize_slug(slug),
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = '2.0.0'
2
+ VERSION = '2.1.0'
3
3
  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: 2.0.0
5
+ version: 2.1.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: 2012-09-14 00:00:00 Z
13
+ date: 2012-09-17 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: plek
@@ -202,7 +202,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
202
  requirements:
203
203
  - - ">="
204
204
  - !ruby/object:Gem::Version
205
- hash: 3104708599933595868
205
+ hash: -2247885112967886087
206
206
  segments:
207
207
  - 0
208
208
  version: "0"
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  requirements:
212
212
  - - ">="
213
213
  - !ruby/object:Gem::Version
214
- hash: 3104708599933595868
214
+ hash: -2247885112967886087
215
215
  segments:
216
216
  - 0
217
217
  version: "0"