gds-api-adapters 38.0.0 → 38.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -5
  3. data/lib/gds_api/asset_manager.rb +7 -7
  4. data/lib/gds_api/base.rb +13 -11
  5. data/lib/gds_api/business_support_api.rb +3 -4
  6. data/lib/gds_api/content_api.rb +31 -44
  7. data/lib/gds_api/content_store.rb +2 -3
  8. data/lib/gds_api/email_alert_api.rb +6 -7
  9. data/lib/gds_api/exceptions.rb +4 -1
  10. data/lib/gds_api/gov_uk_delivery.rb +9 -8
  11. data/lib/gds_api/govuk_headers.rb +1 -1
  12. data/lib/gds_api/imminence.rb +9 -10
  13. data/lib/gds_api/json_client.rb +21 -34
  14. data/lib/gds_api/licence_application.rb +2 -2
  15. data/lib/gds_api/list_response.rb +7 -10
  16. data/lib/gds_api/local_links_manager.rb +1 -1
  17. data/lib/gds_api/mapit.rb +5 -6
  18. data/lib/gds_api/middleware/govuk_header_sniffer.rb +1 -1
  19. data/lib/gds_api/need_api.rb +7 -8
  20. data/lib/gds_api/null_cache.rb +2 -2
  21. data/lib/gds_api/organisations.rb +2 -2
  22. data/lib/gds_api/panopticon.rb +11 -11
  23. data/lib/gds_api/performance_platform/data_in.rb +4 -4
  24. data/lib/gds_api/performance_platform/data_out.rb +1 -1
  25. data/lib/gds_api/publishing_api.rb +4 -5
  26. data/lib/gds_api/publishing_api/special_route_publisher.rb +5 -3
  27. data/lib/gds_api/publishing_api_v2.rb +8 -16
  28. data/lib/gds_api/response.rb +2 -5
  29. data/lib/gds_api/router.rb +18 -9
  30. data/lib/gds_api/rummager.rb +6 -7
  31. data/lib/gds_api/support.rb +7 -6
  32. data/lib/gds_api/support_api.rb +14 -14
  33. data/lib/gds_api/test_helpers/asset_manager.rb +3 -6
  34. data/lib/gds_api/test_helpers/business_support_api.rb +4 -4
  35. data/lib/gds_api/test_helpers/business_support_helper.rb +9 -8
  36. data/lib/gds_api/test_helpers/common_responses.rb +10 -12
  37. data/lib/gds_api/test_helpers/content_api.rb +23 -23
  38. data/lib/gds_api/test_helpers/content_api/artefact_stub.rb +13 -12
  39. data/lib/gds_api/test_helpers/content_item_helpers.rb +4 -4
  40. data/lib/gds_api/test_helpers/content_store.rb +3 -3
  41. data/lib/gds_api/test_helpers/email_alert_api.rb +8 -10
  42. data/lib/gds_api/test_helpers/gov_uk_delivery.rb +0 -1
  43. data/lib/gds_api/test_helpers/imminence.rb +4 -4
  44. data/lib/gds_api/test_helpers/intent_helpers.rb +0 -2
  45. data/lib/gds_api/test_helpers/local_links_manager.rb +12 -13
  46. data/lib/gds_api/test_helpers/mapit.rb +14 -15
  47. data/lib/gds_api/test_helpers/need_api.rb +4 -4
  48. data/lib/gds_api/test_helpers/organisations.rb +13 -15
  49. data/lib/gds_api/test_helpers/panopticon.rb +6 -6
  50. data/lib/gds_api/test_helpers/performance_platform/data_in.rb +8 -8
  51. data/lib/gds_api/test_helpers/publishing_api.rb +19 -20
  52. data/lib/gds_api/test_helpers/publishing_api_v2.rb +13 -13
  53. data/lib/gds_api/test_helpers/router.rb +5 -5
  54. data/lib/gds_api/test_helpers/rummager.rb +5 -4
  55. data/lib/gds_api/test_helpers/support.rb +11 -11
  56. data/lib/gds_api/test_helpers/support_api.rb +14 -14
  57. data/lib/gds_api/test_helpers/whitehall_admin_api.rb +1 -1
  58. data/lib/gds_api/test_helpers/worldwide.rb +16 -19
  59. data/lib/gds_api/version.rb +1 -1
  60. data/lib/gds_api/worldwide.rb +4 -4
  61. data/test/asset_manager_test.rb +6 -6
  62. data/test/business_support_api_test.rb +9 -10
  63. data/test/content_api_test.rb +81 -83
  64. data/test/email_alert_api_test.rb +3 -5
  65. data/test/gds_api_base_test.rb +9 -10
  66. data/test/gov_uk_delivery_test.rb +4 -6
  67. data/test/imminence_api_test.rb +7 -9
  68. data/test/json_client_test.rb +71 -64
  69. data/test/licence_application_api_test.rb +5 -7
  70. data/test/list_response_test.rb +27 -32
  71. data/test/mapit_test.rb +7 -9
  72. data/test/middleware/govuk_header_sniffer_test.rb +1 -1
  73. data/test/need_api_test.rb +8 -8
  74. data/test/organisations_api_test.rb +2 -2
  75. data/test/panopticon_registerer_test.rb +10 -10
  76. data/test/panopticon_test.rb +5 -5
  77. data/test/pp_data_in_test.rb +3 -3
  78. data/test/publishing_api_test.rb +2 -6
  79. data/test/publishing_api_v2_test.rb +40 -50
  80. data/test/response_test.rb +21 -22
  81. data/test/router_test.rb +78 -80
  82. data/test/rummager_test.rb +14 -14
  83. data/test/support_api_test.rb +13 -13
  84. data/test/support_test.rb +15 -16
  85. data/test/test_helper.rb +1 -1
  86. data/test/test_helpers/email_alert_api_test.rb +3 -3
  87. data/test/test_helpers/pact_helper.rb +1 -1
  88. data/test/test_helpers/panopticon_test.rb +1 -1
  89. data/test/test_helpers/publishing_api_test.rb +7 -7
  90. data/test/test_helpers/publishing_api_v2_test.rb +5 -9
  91. data/test/worldwide_api_test.rb +3 -3
  92. metadata +2 -3
  93. data/lib/gds_api/core-ext/openstruct.rb +0 -5
@@ -6,7 +6,7 @@ module GdsApi
6
6
  end
7
7
 
8
8
  def headers
9
- header_data.select {|k, v| !(v.nil? || v.empty?) }
9
+ header_data.select { |_k, v| !(v.nil? || v.empty?) }
10
10
  end
11
11
 
12
12
  def clear_headers
@@ -1,20 +1,19 @@
1
1
  require_relative 'base'
2
2
 
3
3
  class GdsApi::Imminence < GdsApi::Base
4
-
5
4
  def api_url(type, params)
6
- vals = [:limit, :lat, :lng, :postcode].select{ |p| params.include? p }
5
+ vals = [:limit, :lat, :lng, :postcode].select { |p| params.include? p }
7
6
  querystring = URI.encode_www_form vals.map { |p| [p, params[p]] }
8
7
  "#{@endpoint}/places/#{type}.json?#{querystring}"
9
8
  end
10
9
 
11
- def places(type, lat, lon, limit=5)
10
+ def places(type, lat, lon, limit = 5)
12
11
  url = api_url(type, lat: lat, lng: lon, limit: limit)
13
12
  places = get_json(url) || []
14
13
  places.map { |p| self.class.parse_place_hash(p) }
15
14
  end
16
15
 
17
- def places_for_postcode(type, postcode, limit=5)
16
+ def places_for_postcode(type, postcode, limit = 5)
18
17
  url = api_url(type, postcode: postcode, limit: limit)
19
18
  places = get_json(url) || []
20
19
  places.map { |p| self.class.parse_place_hash(p) }
@@ -41,27 +40,27 @@ class GdsApi::Imminence < GdsApi::Base
41
40
  get_json(url)
42
41
  end
43
42
 
44
- private
43
+ # @private
45
44
  def self.extract_location_hash(location)
46
45
  # Deal with all known location formats:
47
46
  # Old style: [latitude, longitude]; empty array for no location
48
47
  # New style: hash with keys "longitude", "latitude"; nil for no location
49
48
  case location
50
49
  when Array
51
- {"latitude" => location[0], "longitude" => location[1]}
50
+ { "latitude" => location[0], "longitude" => location[1] }
52
51
  when Hash
53
52
  location
54
53
  when nil
55
- {"latitude" => nil, "longitude" => nil}
54
+ { "latitude" => nil, "longitude" => nil }
56
55
  end
57
56
  end
58
57
 
58
+ # @private
59
59
  def self.extract_address_hash(place_hash)
60
60
  address_fields = [
61
61
  place_hash["address1"],
62
62
  place_hash["address2"]
63
- ].reject { |a| a.nil? or a == "" }
64
- {"address" => address_fields.map(&:strip).join(", ")}
63
+ ].reject { |a| a.nil? || a == "" }
64
+ { "address" => address_fields.map(&:strip).join(", ") }
65
65
  end
66
-
67
66
  end
@@ -9,7 +9,6 @@ require 'null_logger'
9
9
 
10
10
  module GdsApi
11
11
  class JsonClient
12
-
13
12
  include GdsApi::ExceptionHandling
14
13
 
15
14
  # Cache TTL will be overridden for a given request/response by the Expires
@@ -17,7 +16,7 @@ module GdsApi
17
16
  #
18
17
  # LRUCache doesn't respect a cache size of 0, and instead effectively
19
18
  # creates a cache with a size of 1.
20
- def self.cache(size=DEFAULT_CACHE_SIZE, ttl=DEFAULT_CACHE_TTL)
19
+ def self.cache(size = DEFAULT_CACHE_SIZE, ttl = DEFAULT_CACHE_TTL)
21
20
  @cache ||= LRUCache.new(max_size: size, ttl: ttl)
22
21
  end
23
22
 
@@ -28,14 +27,14 @@ module GdsApi
28
27
  # []=(key, value)
29
28
  # store(key, value, expiry_time=nil) - or a Ruby Time object
30
29
  #
31
- def self.cache=(c)
32
- @cache = c
30
+ class << self
31
+ attr_writer :cache
33
32
  end
34
33
 
35
34
  attr_accessor :logger, :options, :cache
36
35
 
37
36
  def initialize(options = {})
38
- if options[:disable_timeout] or options[:timeout].to_i < 0
37
+ if options[:disable_timeout] || options[:timeout].to_i < 0
39
38
  raise "It is no longer possible to disable the timeout."
40
39
  end
41
40
 
@@ -55,7 +54,7 @@ module GdsApi
55
54
  {
56
55
  'Accept' => 'application/json',
57
56
  # GOVUK_APP_NAME is set for all apps by Puppet
58
- 'User-Agent' => "gds-api-adapters/#{GdsApi::VERSION} (#{ENV["GOVUK_APP_NAME"]})"
57
+ 'User-Agent' => "gds-api-adapters/#{GdsApi::VERSION} (#{ENV['GOVUK_APP_NAME']})"
59
58
  }
60
59
  end
61
60
 
@@ -77,35 +76,23 @@ module GdsApi
77
76
  get_raw!(url)
78
77
  end
79
78
 
80
- # Define "safe" methods for each supported HTTP method
81
- #
82
- # Each "bang method" tries to make a request, but raises an exception if
83
- # the response is not successful. These methods discard the HTTPNotFound
84
- # exceptions (and return nil), and pass through all other exceptions.
85
- [:get, :post, :put, :patch, :delete].each do |http_method|
86
- method_name = "#{http_method}_json"
87
- define_method method_name do |url, *args, &block|
88
- send (method_name + "!"), url, *args, &block
89
- end
90
- end
91
-
92
- def get_json!(url, additional_headers = {}, &create_response)
79
+ def get_json(url, additional_headers = {}, &create_response)
93
80
  do_json_request(:get, url, nil, additional_headers, &create_response)
94
81
  end
95
82
 
96
- def post_json!(url, params = {}, additional_headers = {})
83
+ def post_json(url, params = {}, additional_headers = {})
97
84
  do_json_request(:post, url, params, additional_headers)
98
85
  end
99
86
 
100
- def put_json!(url, params, additional_headers = {})
87
+ def put_json(url, params, additional_headers = {})
101
88
  do_json_request(:put, url, params, additional_headers)
102
89
  end
103
90
 
104
- def patch_json!(url, params, additional_headers = {})
91
+ def patch_json(url, params, additional_headers = {})
105
92
  do_json_request(:patch, url, params, additional_headers)
106
93
  end
107
94
 
108
- def delete_json!(url, additional_headers = {})
95
+ def delete_json(url, additional_headers = {})
109
96
  do_json_request(:delete, url, nil, additional_headers)
110
97
  end
111
98
 
@@ -122,22 +109,19 @@ module GdsApi
122
109
  end
123
110
 
124
111
  def post_multipart(url, params)
125
- r = do_raw_request(:post, url, params.merge({
126
- :multipart => true
127
- }))
112
+ r = do_raw_request(:post, url, params.merge(multipart: true))
128
113
  Response.new(r)
129
114
  end
130
115
 
131
116
  def put_multipart(url, params)
132
- r = do_raw_request(:put, url, params.merge({
133
- :multipart => true
134
- }))
117
+ r = do_raw_request(:put, url, params.merge(multipart: true))
135
118
  Response.new(r)
136
119
  end
137
120
 
138
- private
121
+ private
122
+
139
123
  def do_raw_request(method, url, params = nil)
140
- response = do_request(method, url, params)
124
+ do_request(method, url, params)
141
125
  rescue RestClient::Exception => e
142
126
  raise build_specific_http_error(e, url, nil, params)
143
127
  end
@@ -149,7 +133,6 @@ module GdsApi
149
133
  # create_response: optional block to instantiate a custom response object
150
134
  # from the Net::HTTPResponse
151
135
  def do_json_request(method, url, params = nil, additional_headers = {}, &create_response)
152
-
153
136
  begin
154
137
  response = do_request_with_cache(method, url, (params.to_json if params), additional_headers)
155
138
  rescue RestClient::Exception => e
@@ -173,7 +156,7 @@ module GdsApi
173
156
  if @options[:bearer_token]
174
157
  headers = method_params[:headers] || {}
175
158
  method_params.merge(headers: headers.merge(
176
- {"Authorization" => "Bearer #{@options[:bearer_token]}"}
159
+ "Authorization" => "Bearer #{@options[:bearer_token]}"
177
160
  ))
178
161
  elsif @options[:basic_auth]
179
162
  method_params.merge(
@@ -250,7 +233,7 @@ module GdsApi
250
233
  end
251
234
 
252
235
  def do_request(method, url, params = nil, additional_headers = {})
253
- loggable = {request_uri: url, start_time: Time.now.to_f}
236
+ loggable = { request_uri: url, start_time: Time.now.to_f }
254
237
  start_logging = loggable.merge(action: 'start')
255
238
  logger.debug start_logging.to_json
256
239
 
@@ -284,6 +267,10 @@ module GdsApi
284
267
  logger.error loggable.merge(status: 'timeout', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
285
268
  raise GdsApi::TimedOutException.new
286
269
 
270
+ rescue URI::InvalidURIError => e
271
+ logger.error loggable.merge(status: 'invalid_uri', error_message: e.message, error_class: e.class.name, end_time: Time.now.to_f).to_json
272
+ raise GdsApi::InvalidUrl
273
+
287
274
  rescue RestClient::Exception => e
288
275
  # Log the error here, since we have access to loggable, but raise the
289
276
  # exception up to the calling method to deal with
@@ -2,7 +2,7 @@ require_relative "base"
2
2
 
3
3
  class GdsApi::LicenceApplication < GdsApi::Base
4
4
  def all_licences
5
- get_json!("#{@endpoint}/api/licences")
5
+ get_json("#{@endpoint}/api/licences")
6
6
  end
7
7
 
8
8
  def details_for_licence(id, snac_code = nil)
@@ -10,7 +10,7 @@ class GdsApi::LicenceApplication < GdsApi::Base
10
10
  get_json(build_licence_url(id, snac_code))
11
11
  end
12
12
 
13
- private
13
+ private
14
14
 
15
15
  def build_licence_url(id, snac_code)
16
16
  if snac_code
@@ -3,14 +3,12 @@ require "gds_api/response"
3
3
  require "link_header"
4
4
 
5
5
  module GdsApi
6
-
7
6
  # Response class for lists of multiple items.
8
7
  #
9
8
  # This expects responses to be in a common format, with the list of results
10
9
  # contained under the `results` key. The response may also have previous and
11
10
  # subsequent pages, indicated by entries in the response's `Link` header.
12
11
  class ListResponse < Response
13
-
14
12
  # The ListResponse is instantiated with a reference back to the API client,
15
13
  # so it can make requests for the subsequent pages
16
14
  def initialize(response, api_client, options = {})
@@ -39,10 +37,8 @@ module GdsApi
39
37
  # allow the data to change once it's already been loaded, so long as we
40
38
  # retain a reference to any one page in the sequence
41
39
  @next_page ||= if has_next_page?
42
- @api_client.get_list! page_link("next").href
43
- else
44
- nil
45
- end
40
+ @api_client.get_list page_link("next").href
41
+ end
46
42
  end
47
43
 
48
44
  def has_previous_page?
@@ -51,10 +47,10 @@ module GdsApi
51
47
 
52
48
  def previous_page
53
49
  # See the note in `next_page` for why this is memoised
54
- @previous_page ||= if has_previous_page?
55
- @api_client.get_list! page_link("previous").href
56
- else
57
- nil
50
+ @previous_page ||= begin
51
+ if has_previous_page?
52
+ @api_client.get_list(page_link("previous").href)
53
+ end
58
54
  end
59
55
  end
60
56
 
@@ -86,6 +82,7 @@ module GdsApi
86
82
  end
87
83
 
88
84
  private
85
+
89
86
  def link_header
90
87
  @link_header ||= LinkHeader.parse @http_response.headers[:link]
91
88
  end
@@ -1,7 +1,7 @@
1
1
  require_relative 'base'
2
2
 
3
3
  class GdsApi::LocalLinksManager < GdsApi::Base
4
- def local_link(authority_slug, lgsl, lgil=nil)
4
+ def local_link(authority_slug, lgsl, lgil = nil)
5
5
  url = "#{endpoint}/api/link?authority_slug=#{authority_slug}&lgsl=#{lgsl}"
6
6
  url += "&lgil=#{lgil}" if lgil
7
7
  get_json(url)
data/lib/gds_api/mapit.rb CHANGED
@@ -2,7 +2,6 @@ require_relative 'base'
2
2
  require_relative 'exceptions'
3
3
 
4
4
  class GdsApi::Mapit < GdsApi::Base
5
-
6
5
  def location_for_postcode(postcode)
7
6
  response = get_json("#{base_url}/postcode/#{CGI.escape postcode}.json")
8
7
  Location.new(response) unless response.nil?
@@ -32,7 +31,7 @@ class GdsApi::Mapit < GdsApi::Base
32
31
  end
33
32
 
34
33
  def areas
35
- @response['areas'].map {|i, area| OpenStruct.new(area) }
34
+ @response['areas'].map { |_i, area| OpenStruct.new(area) }
36
35
  end
37
36
 
38
37
  def postcode
@@ -40,9 +39,9 @@ class GdsApi::Mapit < GdsApi::Base
40
39
  end
41
40
  end
42
41
 
43
- private
44
- def base_url
45
- endpoint
46
- end
42
+ private
47
43
 
44
+ def base_url
45
+ endpoint
46
+ end
48
47
  end
@@ -12,7 +12,7 @@ module GdsApi
12
12
  @app.call(env)
13
13
  end
14
14
 
15
- private
15
+ private
16
16
 
17
17
  def readable_name
18
18
  @header_name.sub(/^HTTP_/, "").downcase.to_sym
@@ -1,11 +1,10 @@
1
1
  require_relative 'base'
2
2
 
3
3
  class GdsApi::NeedApi < GdsApi::Base
4
-
5
4
  def needs(options = {})
6
5
  query = query_string(options)
7
6
 
8
- get_list!("#{endpoint}/needs#{query}")
7
+ get_list("#{endpoint}/needs#{query}")
9
8
  end
10
9
 
11
10
  def content_id(need_id)
@@ -16,7 +15,7 @@ class GdsApi::NeedApi < GdsApi::Base
16
15
  ids_string = ids.flatten.map(&:to_i).sort.join(',')
17
16
  query = query_string(ids: ids_string)
18
17
 
19
- get_list!("#{endpoint}/needs#{query}")
18
+ get_list("#{endpoint}/needs#{query}")
20
19
  end
21
20
 
22
21
  def need(need_id)
@@ -24,16 +23,16 @@ class GdsApi::NeedApi < GdsApi::Base
24
23
  end
25
24
 
26
25
  def create_need(need)
27
- post_json!("#{endpoint}/needs", need)
26
+ post_json("#{endpoint}/needs", need)
28
27
  end
29
28
 
30
29
  def update_need(need_id, need_update)
31
30
  # `need_update` can be a hash of updated fields or a complete need
32
- put_json!("#{endpoint}/needs/#{CGI.escape(need_id.to_s)}", need_update)
31
+ put_json("#{endpoint}/needs/#{CGI.escape(need_id.to_s)}", need_update)
33
32
  end
34
33
 
35
34
  def organisations
36
- get_json!("#{endpoint}/organisations")["organisations"]
35
+ get_json("#{endpoint}/organisations")["organisations"]
37
36
  end
38
37
 
39
38
  def close(need_id, duplicate_of)
@@ -41,7 +40,7 @@ class GdsApi::NeedApi < GdsApi::Base
41
40
  # a need as a duplicate: { "duplicate_of" => 100001,
42
41
  # "author" => { ... }
43
42
  # }
44
- put_json!("#{endpoint}/needs/#{CGI.escape(need_id.to_s)}/closed", duplicate_of)
43
+ put_json("#{endpoint}/needs/#{CGI.escape(need_id.to_s)}/closed", duplicate_of)
45
44
  end
46
45
 
47
46
  def reopen(need_id, author)
@@ -51,6 +50,6 @@ class GdsApi::NeedApi < GdsApi::Base
51
50
  end
52
51
 
53
52
  def create_note(note)
54
- post_json!("#{endpoint}/notes", note)
53
+ post_json("#{endpoint}/notes", note)
55
54
  end
56
55
  end
@@ -1,13 +1,13 @@
1
1
  module GdsApi
2
2
  class NullCache
3
- def [](k)
3
+ def [](_k)
4
4
  nil
5
5
  end
6
6
 
7
7
  def []=(k, v)
8
8
  end
9
9
 
10
- def store(k, v, expiry_time=nil)
10
+ def store(k, v, expiry_time = nil)
11
11
  end
12
12
  end
13
13
  end
@@ -1,9 +1,8 @@
1
1
  require_relative 'base'
2
2
 
3
3
  class GdsApi::Organisations < GdsApi::Base
4
-
5
4
  def organisations
6
- get_list! "#{base_url}/organisations"
5
+ get_list "#{base_url}/organisations"
7
6
  end
8
7
 
9
8
  def organisation(organisation_slug)
@@ -11,6 +10,7 @@ class GdsApi::Organisations < GdsApi::Base
11
10
  end
12
11
 
13
12
  private
13
+
14
14
  def base_url
15
15
  "#{endpoint}/api"
16
16
  end
@@ -3,7 +3,6 @@ require_relative 'panopticon/registerer'
3
3
  require_relative 'exceptions'
4
4
 
5
5
  class GdsApi::Panopticon < GdsApi::Base
6
-
7
6
  include GdsApi::ExceptionHandling
8
7
 
9
8
  def all
@@ -12,8 +11,8 @@ class GdsApi::Panopticon < GdsApi::Base
12
11
  to_ostruct json
13
12
  end
14
13
 
15
- def artefact_for_slug(slug, opts = {})
16
- return nil if slug.nil? or slug == ''
14
+ def artefact_for_slug(slug, _opts = {})
15
+ return nil if slug.nil? || slug == ''
17
16
  get_json(url_for_slug(slug))
18
17
  end
19
18
 
@@ -24,7 +23,7 @@ class GdsApi::Panopticon < GdsApi::Base
24
23
  end
25
24
 
26
25
  def create_artefact!(artefact)
27
- post_json!(base_url + ".json", artefact)
26
+ post_json(base_url + ".json", artefact)
28
27
  end
29
28
 
30
29
  def put_artefact(id_or_slug, artefact)
@@ -34,7 +33,7 @@ class GdsApi::Panopticon < GdsApi::Base
34
33
  end
35
34
 
36
35
  def put_artefact!(id_or_slug, artefact)
37
- put_json!("#{base_url}/#{id_or_slug}.json", artefact)
36
+ put_json("#{base_url}/#{id_or_slug}.json", artefact)
38
37
  end
39
38
 
40
39
  def update_artefact(id_or_slug, artefact)
@@ -46,35 +45,36 @@ class GdsApi::Panopticon < GdsApi::Base
46
45
  end
47
46
 
48
47
  def delete_artefact!(id_or_slug)
49
- delete_json!("#{base_url}/#{id_or_slug}.json")
48
+ delete_json("#{base_url}/#{id_or_slug}.json")
50
49
  end
51
50
 
52
51
  def create_tag(attributes)
53
- post_json!("#{endpoint}/tags.json", attributes)
52
+ post_json("#{endpoint}/tags.json", attributes)
54
53
  end
55
54
 
56
55
  def put_tag(tag_type, tag_id, attributes)
57
- put_json!(
56
+ put_json(
58
57
  tag_url(tag_type, tag_id),
59
58
  attributes
60
59
  )
61
60
  end
62
61
 
63
62
  def publish_tag(tag_type, tag_id)
64
- post_json!(
63
+ post_json(
65
64
  tag_url(tag_type, tag_id, '/publish'),
66
65
  # we don't need to send any more data along with the publish request,
67
66
  # but a body is still required, so sending an empty JSON hash instead
68
- { }
67
+ {}
69
68
  )
70
69
  end
71
70
 
72
71
  private
72
+
73
73
  def base_url
74
74
  "#{endpoint}/artefacts"
75
75
  end
76
76
 
77
- def tag_url(tag_type, tag_id, action='')
77
+ def tag_url(tag_type, tag_id, action = '')
78
78
  "#{endpoint}/tags/#{tag_type}/#{tag_id}#{action}.json"
79
79
  end
80
80
  end