gds-api-adapters 10.6.3 → 10.6.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gds_api/content_api.rb +17 -9
- data/lib/gds_api/version.rb +1 -1
- data/test/content_api_test.rb +7 -0
- metadata +3 -3
data/lib/gds_api/content_api.rb
CHANGED
@@ -75,16 +75,11 @@ class GdsApi::ContentApi < GdsApi::Base
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def artefact(slug, params={})
|
78
|
-
|
79
|
-
|
80
|
-
if query.any?
|
81
|
-
url += "?#{query.join("&")}"
|
82
|
-
end
|
78
|
+
get_json(artefact_url(slug, params))
|
79
|
+
end
|
83
80
|
|
84
|
-
|
85
|
-
|
86
|
-
end
|
87
|
-
get_json(url)
|
81
|
+
def artefact!(slug, params={})
|
82
|
+
get_json!(artefact_url(slug, params))
|
88
83
|
end
|
89
84
|
|
90
85
|
def artefacts
|
@@ -152,4 +147,17 @@ class GdsApi::ContentApi < GdsApi::Base
|
|
152
147
|
def key_for_tag_type(tag_type)
|
153
148
|
tag_type.nil? ? "tag" : CGI.escape(tag_type)
|
154
149
|
end
|
150
|
+
|
151
|
+
def artefact_url(slug, params)
|
152
|
+
url = "#{base_url}/#{CGI.escape(slug)}.json"
|
153
|
+
query = params.map { |k,v| "#{k}=#{v}" }
|
154
|
+
if query.any?
|
155
|
+
url += "?#{query.join("&")}"
|
156
|
+
end
|
157
|
+
|
158
|
+
if params[:edition] && ! options.include?(:bearer_token)
|
159
|
+
raise GdsApi::NoBearerToken
|
160
|
+
end
|
161
|
+
url
|
162
|
+
end
|
155
163
|
end
|
data/lib/gds_api/version.rb
CHANGED
data/test/content_api_test.rb
CHANGED
@@ -190,6 +190,13 @@ describe GdsApi::ContentApi do
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
+
it "should raise a 410 if an artefact has been archived" do
|
194
|
+
content_api_has_an_archived_artefact("atlantis")
|
195
|
+
assert_raises GdsApi::HTTPGone do
|
196
|
+
@api.artefact!("atlantis")
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
193
200
|
it "should be able to fetch artefacts with a '/' in the slug" do
|
194
201
|
content_api_has_an_artefact("foreign-travel-advice/aruba")
|
195
202
|
response = @api.artefact("foreign-travel-advice/aruba")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gds-api-adapters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.6.
|
4
|
+
version: 10.6.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -376,7 +376,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
376
376
|
version: '0'
|
377
377
|
segments:
|
378
378
|
- 0
|
379
|
-
hash: -
|
379
|
+
hash: -4240733080959165707
|
380
380
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
381
381
|
none: false
|
382
382
|
requirements:
|
@@ -385,7 +385,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
385
385
|
version: '0'
|
386
386
|
segments:
|
387
387
|
- 0
|
388
|
-
hash: -
|
388
|
+
hash: -4240733080959165707
|
389
389
|
requirements: []
|
390
390
|
rubyforge_project:
|
391
391
|
rubygems_version: 1.8.23
|