gds-api-adapters 90.0.0 → 91.1.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
  SHA256:
3
- metadata.gz: 9cffcf9f91e4d6d0e06af47378331cc2b6e3cd346c2c9248813d7741d2af80e1
4
- data.tar.gz: 9cd9b674ae9b9cd287aadd7c1454c33b2638827c74efc8d5161ebfbcc579c3f9
3
+ metadata.gz: b228bbfeb3c6670abced9b88f27ff26a2ac8f202c65b4815e7e7bf095bb2f357
4
+ data.tar.gz: dc1d051288ca8e31105dbb25c19f1c822c438b7b15c10a789f4f663fc8d39fa8
5
5
  SHA512:
6
- metadata.gz: ac0d0eabb70dec4d134e7df7ce6d9fafbb4fa667f847094d4edefe1948b436eb344fe3813f676976547f9b45e28fe917fd534e59119457a4b9319df93677e517
7
- data.tar.gz: 20e424eb1c426c9fdda45f674d406f261d22dbd99bdee56cd98d902eeac9e2954b52b08aec061eda2ca334b35eec763045e148578d99d6a0beacb0f641a55166
6
+ metadata.gz: ea46e87d73ad2440115c91e91d73c8aeeb018eca04b0c430bd9c2c5dba7e2041fcc18b62efc0b17631fd8b39cbc9b29098722e8e8404945cf584baef463a0368
7
+ data.tar.gz: caf48a8612c247ac0f6c6e77d0bcf480f77aa74e15fe8ca63316411f818c5a66b36cddc15eb894068e5dfefbe4376b8d9023ae06e0a5b8a5aba5e7a10a623747
@@ -107,35 +107,6 @@ class GdsApi::AccountApi < GdsApi::Base
107
107
  patch_json("#{endpoint}/api/attributes", { attributes: attributes }, auth_headers(govuk_account_session))
108
108
  end
109
109
 
110
- # Get the details of an account-linked email subscription.
111
- #
112
- # @param [String] name Name of the subscription
113
- # @param [String] govuk_account_session Value of the session header
114
- #
115
- # @return [Hash] Details of the subscription, if it exists.
116
- def get_email_subscription(name:, govuk_account_session:)
117
- get_json("#{endpoint}/api/email-subscriptions/#{CGI.escape(name)}", auth_headers(govuk_account_session))
118
- end
119
-
120
- # Create or update an account-linked email subscription.
121
- #
122
- # @param [String] name Name of the subscription
123
- # @param [String] topic_slug The email-alert-api topic slug to subscribe to
124
- # @param [String] govuk_account_session Value of the session header
125
- #
126
- # @return [Hash] Details of the newly created subscription.
127
- def put_email_subscription(name:, topic_slug:, govuk_account_session:)
128
- put_json("#{endpoint}/api/email-subscriptions/#{CGI.escape(name)}", { topic_slug: topic_slug }, auth_headers(govuk_account_session))
129
- end
130
-
131
- # Unsubscribe and delete an account-linked email subscription.
132
- #
133
- # @param [String] name Name of the subscription
134
- # @param [String] govuk_account_session Value of the session header
135
- def delete_email_subscription(name:, govuk_account_session:)
136
- delete_json("#{endpoint}/api/email-subscriptions/#{CGI.escape(name)}", {}, auth_headers(govuk_account_session))
137
- end
138
-
139
110
  private
140
111
 
141
112
  def nested_query_string(params)
@@ -239,6 +239,18 @@ class GdsApi::AssetManager < GdsApi::Base
239
239
  get_raw("#{base_url}/#{uri_encode(legacy_url_path)}")
240
240
  end
241
241
 
242
+ # Fetches an asset given the id and filename
243
+ #
244
+ # @param id [String] The asset identifier.
245
+ # @param filename [String] Filename of the asset.
246
+ # @return [GdsApi::Response] A response object containing the raw asset.
247
+ # If the asset cannot be found, +GdsApi::HTTPNotFound+ will be raised.
248
+ #
249
+ # @raise [HTTPErrorResponse] if the request returns an error
250
+ def media(id, filename)
251
+ get_raw("#{base_url}/media/#{id}/#{filename}")
252
+ end
253
+
242
254
  private
243
255
 
244
256
  def base_url
@@ -0,0 +1,8 @@
1
+ module GdsApi
2
+ class SearchApiV2 < Base
3
+ def search(args, additional_headers = {})
4
+ request_url = "#{endpoint}/search.json?#{Rack::Utils.build_nested_query(args)}"
5
+ get_json(request_url, additional_headers)
6
+ end
7
+ end
8
+ end
@@ -172,100 +172,6 @@ module GdsApi
172
172
  )
173
173
  end
174
174
 
175
- ####################################
176
- # GET /api/email-subscriptions/:name
177
- ####################################
178
- def stub_account_api_get_email_subscription(name:, topic_slug: "slug", email_alert_api_subscription_id: "12345", **options)
179
- stub_account_api_request(
180
- :get,
181
- "/api/email-subscriptions/#{name}",
182
- response_body: {
183
- email_subscription: {
184
- name: name,
185
- topic_slug: topic_slug,
186
- email_alert_api_subscription_id: email_alert_api_subscription_id,
187
- },
188
- },
189
- **options,
190
- )
191
- end
192
-
193
- def stub_account_api_get_email_subscription_does_not_exist(name:, **options)
194
- stub_account_api_request(
195
- :get,
196
- "/api/email-subscriptions/#{name}",
197
- response_status: 404,
198
- **options,
199
- )
200
- end
201
-
202
- def stub_account_api_unauthorized_get_email_subscription(name:, **options)
203
- stub_account_api_request(
204
- :get,
205
- "/api/email-subscriptions/#{name}",
206
- response_status: 401,
207
- **options,
208
- )
209
- end
210
-
211
- ####################################
212
- # PUT /api/email-subscriptions/:name
213
- ####################################
214
- def stub_account_api_put_email_subscription(name:, topic_slug: nil, **options)
215
- stub_account_api_request(
216
- :put,
217
- "/api/email-subscriptions/#{name}",
218
- with: { body: hash_including({ topic_slug: topic_slug }.compact) },
219
- response_body: {
220
- email_subscription: {
221
- name: name,
222
- topic_slug: topic_slug || "slug",
223
- },
224
- },
225
- **options,
226
- )
227
- end
228
-
229
- def stub_account_api_unauthorized_put_email_subscription(name:, topic_slug: nil, **options)
230
- stub_account_api_request(
231
- :put,
232
- "/api/email-subscriptions/#{name}",
233
- with: { body: hash_including({ topic_slug: topic_slug }.compact) },
234
- response_status: 401,
235
- **options,
236
- )
237
- end
238
-
239
- #######################################
240
- # DELETE /api/email-subscriptions/:name
241
- #######################################
242
- def stub_account_api_delete_email_subscription(name:, **options)
243
- stub_account_api_request(
244
- :delete,
245
- "/api/email-subscriptions/#{name}",
246
- response_status: 204,
247
- **options,
248
- )
249
- end
250
-
251
- def stub_account_api_delete_email_subscription_does_not_exist(name:, **options)
252
- stub_account_api_request(
253
- :delete,
254
- "/api/email-subscriptions/#{name}",
255
- response_status: 404,
256
- **options,
257
- )
258
- end
259
-
260
- def stub_account_api_unauthorized_delete_email_subscription(name:, **options)
261
- stub_account_api_request(
262
- :delete,
263
- "/api/email-subscriptions/#{name}",
264
- response_status: 401,
265
- **options,
266
- )
267
- end
268
-
269
175
  #####################
270
176
  # GET /api/attributes
271
177
  #####################
@@ -21,11 +21,14 @@ module GdsApi
21
21
  .to_return(body: body.to_json, status: 200)
22
22
  end
23
23
 
24
- def stub_asset_manager_has_an_asset(id, atts)
24
+ def stub_asset_manager_has_an_asset(id, atts, filename = "")
25
25
  response = atts.merge("_response_info" => { "status" => "ok" })
26
26
 
27
27
  stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/assets/#{id}")
28
28
  .to_return(body: response.to_json, status: 200)
29
+
30
+ stub_request(:get, "#{ASSET_MANAGER_ENDPOINT}/media/#{id}/#{filename}")
31
+ .to_return(body: "Some file content", status: 200)
29
32
  end
30
33
 
31
34
  def stub_asset_manager_has_a_whitehall_asset(legacy_url_path, atts)
@@ -1,3 +1,3 @@
1
1
  module GdsApi
2
- VERSION = "90.0.0".freeze
2
+ VERSION = "91.1.0".freeze
3
3
  end
data/lib/gds_api.rb CHANGED
@@ -16,6 +16,7 @@ require "gds_api/organisations"
16
16
  require "gds_api/publishing_api"
17
17
  require "gds_api/router"
18
18
  require "gds_api/search"
19
+ require "gds_api/search_api_v2"
19
20
  require "gds_api/support"
20
21
  require "gds_api/support_api"
21
22
  require "gds_api/worldwide"
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: 90.0.0
4
+ version: 91.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-31 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -367,6 +367,7 @@ files:
367
367
  - lib/gds_api/response.rb
368
368
  - lib/gds_api/router.rb
369
369
  - lib/gds_api/search.rb
370
+ - lib/gds_api/search_api_v2.rb
370
371
  - lib/gds_api/support.rb
371
372
  - lib/gds_api/support_api.rb
372
373
  - lib/gds_api/test_helpers/account_api.rb
@@ -416,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
416
417
  - !ruby/object:Gem::Version
417
418
  version: '0'
418
419
  requirements: []
419
- rubygems_version: 3.4.17
420
+ rubygems_version: 3.4.19
420
421
  signing_key:
421
422
  specification_version: 4
422
423
  summary: Adapters to work with GDS APIs