gds-api-adapters 63.0.0 → 63.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 154a65678536f8bc302691fd8491ec4cf42d968a0567dc18b90e0b0d110a63f7
4
- data.tar.gz: 4ca5ca74bf707a09dace341942326a0ed9d189c085ce6ed2e9d8b42bd0c74403
3
+ metadata.gz: 5a863b33914da6a3b366207bc6a642664f19538645afbef4feba3b4d3eff1909
4
+ data.tar.gz: d49d4cb121b671f37bcc43f573a7c430637f8f50b180a9508d63598d46d02408
5
5
  SHA512:
6
- metadata.gz: 7b715c10926dc05aba2b73673c8748b0a976b166be64b74698d10252fb873eaf9b8af8370aac775eb223140e19ffbae35a26025a6b05d5119f815d5ffa536407
7
- data.tar.gz: f440ca06f27c10fa07420da1bac34f6cdc7e753122db0c8369a2a6ae08661da2aed0d547c0214073a24357e337b13744576c01e3d585695e7238b3ad500574de
6
+ metadata.gz: a40058bfe9040279b5d27b1caac8363dd4c3d2f3cf8d22c29d19fb50af20e27f5f93c390cc08c6e9194e4edca1d378aee7be83a39f0d2dcbebc3e8c018180aea
7
+ data.tar.gz: 3600add23c8bb27cd0de72ef2dfbb8b27cf1e2b4a9cd2e7e6bab5c9122e4933964e21fe12d122b048b427beca353eb9e1bfbbe587fe7613989b22f9b53314f19
data/README.md CHANGED
@@ -12,7 +12,7 @@ results = search.search(q: "taxes")
12
12
 
13
13
  Example adapters for frequently used applications:
14
14
 
15
- - [Publishing API](lib/gds_api/publishing_api_v2.rb) ([docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/PublishingApiV2), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/publishing_api_v2.rb), [test helper docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/TestHelpers/PublishingApiV2))
15
+ - [Publishing API](lib/gds_api/publishing_api.rb) ([docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/PublishingApi), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/publishing_api.rb), [test helper docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/TestHelpers/PublishingApi))
16
16
  - [Content Store](lib/gds_api/content_store.rb) ([docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/ContentStore), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/content_store.rb), [test helper docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/TestHelpers/ContentStore))
17
17
  - [Search API](lib/gds_api/search.rb) ([docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/Search), [test helper code](https://github.com/alphagov/gds-api-adapters/blob/master/lib/gds_api/test_helpers/search.rb), [test helper docs](http://www.rubydoc.info/gems/gds-api-adapters/GdsApi/TestHelpers/Search))
18
18
 
@@ -1,7 +1,453 @@
1
1
  require_relative "base"
2
2
  require_relative "exceptions"
3
3
 
4
+ # Adapter for the Publishing API.
5
+ #
6
+ # @see https://github.com/alphagov/publishing-api
7
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/publishing-application-examples.md
8
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/model.md
9
+ # @api documented
4
10
  class GdsApi::PublishingApi < GdsApi::Base
11
+ # Put a content item
12
+ #
13
+ # @param content_id [UUID]
14
+ # @param payload [Hash] A valid content item
15
+ #
16
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#put-v2contentcontent_id
17
+ def put_content(content_id, payload)
18
+ put_json(content_url(content_id), payload)
19
+ end
20
+
21
+ # Return a content item
22
+ #
23
+ # Raises exception if the item doesn't exist.
24
+ #
25
+ # @param content_id [UUID]
26
+ # @param params [Hash]
27
+ # @option params [String] locale The language, defaults to 'en' in publishing-api.
28
+ #
29
+ # @return [GdsApi::Response] a content item
30
+ #
31
+ # @raise [HTTPNotFound] when the content item is not found
32
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2contentcontent_id
33
+ def get_content(content_id, params = {})
34
+ get_json(content_url(content_id, params))
35
+ end
36
+
37
+ # Find the content_ids for a list of base_paths.
38
+ #
39
+ # @param base_paths [Array]
40
+ # @param exclude_document_types [Array] (optional)
41
+ # @param exclude_unpublishing_types [Array] (optional)
42
+ # @param with_drafts [Boolean] (optional)
43
+ # @return [Hash] a hash, keyed by `base_path` with `content_id` as value
44
+ # @example
45
+ #
46
+ # publishing_api.lookup_content_ids(base_paths: ['/foo', '/bar'])
47
+ # # => { "/foo" => "51ac4247-fd92-470a-a207-6b852a97f2db", "/bar" => "261bd281-f16c-48d5-82d2-9544019ad9ca" }
48
+ #
49
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-lookup-by-base-path
50
+ def lookup_content_ids(base_paths:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
51
+ options = { base_paths: base_paths }
52
+ options[:exclude_document_types] = exclude_document_types if exclude_document_types
53
+ options[:exclude_unpublishing_types] = exclude_unpublishing_types if exclude_unpublishing_types
54
+ options[:with_drafts] = with_drafts if with_drafts
55
+ response = post_json("#{endpoint}/lookup-by-base-path", options)
56
+ response.to_hash
57
+ end
58
+
59
+ # Find the content_id for a base_path.
60
+ #
61
+ # Convenience method if you only need to look up one content_id for a
62
+ # base_path. For multiple base_paths, use {GdsApi::PublishingApiV2#lookup_content_ids}.
63
+ #
64
+ # @param base_path [String]
65
+ # @param exclude_document_types [Array] (optional)
66
+ # @param exclude_unpublishing_types [Array] (optional)
67
+ # @param with_drafts [Boolean] (optional)
68
+ #
69
+ # @return [UUID] the `content_id` for the `base_path`
70
+ #
71
+ # @example
72
+ #
73
+ # publishing_api.lookup_content_id(base_path: '/foo')
74
+ # # => "51ac4247-fd92-470a-a207-6b852a97f2db"
75
+ #
76
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-lookup-by-base-path
77
+ def lookup_content_id(base_path:, exclude_document_types: nil, exclude_unpublishing_types: nil, with_drafts: false)
78
+ lookups = lookup_content_ids(
79
+ base_paths: [base_path],
80
+ exclude_document_types: exclude_document_types,
81
+ exclude_unpublishing_types: exclude_unpublishing_types,
82
+ with_drafts: with_drafts,
83
+ )
84
+ lookups[base_path]
85
+ end
86
+
87
+ # Publish a content item
88
+ #
89
+ # The publishing-api will "publish" a draft item, so that it will be visible
90
+ # on the public site.
91
+ #
92
+ # @param content_id [UUID]
93
+ # @param update_type [String] Either 'major', 'minor' or 'republish'
94
+ # @param options [Hash]
95
+ # @option options [String] locale The language, defaults to 'en' in publishing-api.
96
+ #
97
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_idpublish
98
+ def publish(content_id, update_type = nil, options = {})
99
+ params = {
100
+ update_type: update_type,
101
+ }
102
+
103
+ optional_keys = %i[locale previous_version]
104
+
105
+ params = merge_optional_keys(params, options, optional_keys)
106
+
107
+ post_json(publish_url(content_id), params)
108
+ end
109
+
110
+ # Republish a content item
111
+ #
112
+ # The publishing-api will "republish" a live edition. This can be used to remove an unpublishing or to
113
+ # re-send a published edition downstream
114
+ #
115
+ # @param content_id [UUID]
116
+ # @param options [Hash]
117
+ # @option options [String] locale The language, defaults to 'en' in publishing-api.
118
+ #
119
+ # @see ...
120
+ def republish(content_id, options = {})
121
+ optional_keys = %i[locale previous_version]
122
+
123
+ params = merge_optional_keys({}, options, optional_keys)
124
+
125
+ post_json(republish_url(content_id), params)
126
+ end
127
+
128
+ # Import content into the publishing API
129
+ #
130
+ # The publishing-api will delete any content which has the content
131
+ # id provided, and then import the data given.
132
+ #
133
+ # @param content_id [UUID]
134
+ # @param content_items [Array]
135
+ #
136
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_idimport
137
+ def import(content_id, locale, content_items)
138
+ params = {
139
+ history: content_items,
140
+ }
141
+
142
+ post_json("#{endpoint}/v2/content/#{content_id}/import?locale=#{locale}", params)
143
+ end
144
+
145
+ # Unpublish a content item
146
+ #
147
+ # The publishing API will "unpublish" a live item, to remove it from the public
148
+ # site, or update an existing unpublishing.
149
+ #
150
+ # @param content_id [UUID]
151
+ # @param type [String] Either 'withdrawal', 'gone' or 'redirect'.
152
+ # @param explanation [String] (optional) Text to show on the page.
153
+ # @param alternative_path [String] (optional) Alternative path to show on the page or redirect to.
154
+ # @param discard_drafts [Boolean] (optional) Whether to discard drafts on that item. Defaults to false.
155
+ # @param previous_version [Integer] (optional) A lock version number for optimistic locking.
156
+ # @param locale [String] (optional) The content item locale.
157
+ # @param unpublished_at [Time] (optional) The time the content was withdrawn. Ignored for types other than withdrawn
158
+ # @param redirects [Array] (optional) Required if no alternative_path is given. An array of redirect values, ie: { path:, type:, destination: }
159
+ #
160
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_idunpublish
161
+ def unpublish(content_id, type:, explanation: nil, alternative_path: nil, discard_drafts: false, allow_draft: false, previous_version: nil, locale: nil, unpublished_at: nil, redirects: nil)
162
+ params = {
163
+ type: type,
164
+ }
165
+
166
+ params[:explanation] = explanation if explanation
167
+ params[:alternative_path] = alternative_path if alternative_path
168
+ params[:previous_version] = previous_version if previous_version
169
+ params[:discard_drafts] = discard_drafts if discard_drafts
170
+ params[:allow_draft] = allow_draft if allow_draft
171
+ params[:locale] = locale if locale
172
+ params[:unpublished_at] = unpublished_at.utc.iso8601 if unpublished_at
173
+ params[:redirects] = redirects if redirects
174
+
175
+ post_json(unpublish_url(content_id), params)
176
+ end
177
+
178
+ # Discard a draft
179
+ #
180
+ # Deletes the draft content item.
181
+ #
182
+ # @param options [Hash]
183
+ # @option options [String] locale The language, defaults to 'en' in publishing-api.
184
+ # @option options [Integer] previous_version used to ensure the request is discarding the latest lock version of the draft
185
+ #
186
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_iddiscard-draft
187
+ def discard_draft(content_id, options = {})
188
+ optional_keys = %i[locale previous_version]
189
+
190
+ params = merge_optional_keys({}, options, optional_keys)
191
+
192
+ post_json(discard_url(content_id), params)
193
+ end
194
+
195
+ # Get the link set for the given content_id.
196
+ #
197
+ # Given a Content ID, it fetchs the existing link set and their version.
198
+ #
199
+ # @param content_id [String]
200
+ #
201
+ # @return [GdsApi::Response] A response containing `links` and `version`.
202
+ #
203
+ # @example
204
+ #
205
+ # publishing_api.get_links("a-content-id")
206
+ # # => {
207
+ # "content_id" => "a-content-id",
208
+ # "links" => [
209
+ # "organisation" => "organisation-content-id",
210
+ # "document_collection" => "document-collection-content-id"
211
+ # ],
212
+ # "version" => 17
213
+ # }
214
+ #
215
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2linkscontent_id
216
+ def get_links(content_id)
217
+ get_json(links_url(content_id))
218
+ end
219
+
220
+ # Returns an array of changes to links.
221
+ #
222
+ # The link changes can be filtered by link_type, source content_id,
223
+ # target content_id and user. A maximum of 250 changes will be
224
+ # returned.
225
+ #
226
+ # @param link_types [Array] Array of link_types to filter by.
227
+ # @param source_content_ids [Array] Array of source content ids to filter by.
228
+ # @param target_content_ids [Array] Array of target content ids to filter by.
229
+ # @param users [Array] User UIDs to filter by.
230
+ # @example
231
+ #
232
+ # publishing_api.get_links_changes(
233
+ # link_types: ['taxons'],
234
+ # target_content_ids: ['a544d48b-1e9e-47fb-b427-7a987c658c14']
235
+ # )
236
+ #
237
+ def get_links_changes(params)
238
+ get_json(links_changes_url(params))
239
+ end
240
+
241
+ # Get expanded links
242
+ #
243
+ # Return the expanded links of the item.
244
+ #
245
+ # @param content_id [UUID]
246
+ # @param locale [String] Locale with which to generate the expanded links. Unless this is specified, the default locale (`en`) in the Publishing API will be used.
247
+ # @param with_drafts [Bool] Whether links to draft-only editions are returned, defaulting to `true`.
248
+ # @param generate [Bool] Whether to require publishing-api to generate the expanded links, which may be slow. Defaults to `false`.
249
+ #
250
+ # @example
251
+ #
252
+ # publishing_api.get_expanded_links("8157589b-65e2-4df6-92ba-2c91d80006c0", with_drafts: false).to_h
253
+ #
254
+ # #=> {
255
+ # "generated" => "2017-08-01T10:42:49Z",
256
+ # "expanded_links" => {
257
+ # "organisations" => [
258
+ # {
259
+ # "content_id" => "21aa83a2-a47f-4189-a252-b02f8c322012",
260
+ # ... (and more attributes)
261
+ # }
262
+ # ]
263
+ # }
264
+ # }
265
+ #
266
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2expanded-linkscontent_id
267
+ def get_expanded_links(content_id, locale: nil, with_drafts: true, generate: false)
268
+ params = {}
269
+ params[:with_drafts] = "false" unless with_drafts
270
+ params[:generate] = "true" if generate
271
+ params[:locale] = locale if locale
272
+ query = query_string(params)
273
+ validate_content_id(content_id)
274
+ get_json("#{endpoint}/v2/expanded-links/#{content_id}#{query}")
275
+ end
276
+
277
+ # Patch the links of a content item
278
+ #
279
+ # @param content_id [UUID]
280
+ # @param params [Hash]
281
+ # @option params [Hash] links A "links hash"
282
+ # @option params [Integer] previous_version The previous version (returned by `get_links`). If this version is not the current version, the publishing-api will reject the change and return 409 Conflict. (optional)
283
+ # @option params [Boolean] bulk_publishing Set to true to indicate that this is part of a mass-republish. Allows the publishing-api to prioritise human-initiated publishing (optional, default false)
284
+ # @example
285
+ #
286
+ # publishing_api.patch_links(
287
+ # '86963c13-1f57-4005-b119-e7cf3cb92ecf',
288
+ # links: {
289
+ # topics: ['d6e1527d-d0c0-40d5-9603-b9f3e6866b8a'],
290
+ # mainstream_browse_pages: ['d6e1527d-d0c0-40d5-9603-b9f3e6866b8a'],
291
+ # },
292
+ # previous_version: 10,
293
+ # bulk_publishing: true
294
+ # )
295
+ #
296
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#patch-v2linkscontent_id
297
+ def patch_links(content_id, params)
298
+ payload = {
299
+ links: params.fetch(:links),
300
+ }
301
+
302
+ payload = merge_optional_keys(payload, params, %i[previous_version bulk_publishing])
303
+
304
+ patch_json(links_url(content_id), payload)
305
+ end
306
+
307
+ # Get a list of content items from the Publishing API.
308
+ #
309
+ # The only required key in the params hash is `document_type`. These will be used to filter down the content items being returned by the API. Other allowed options can be seen from the link below.
310
+ #
311
+ # @param params [Hash] At minimum, this hash has to include the `document_type` of the content items we wish to see. All other optional keys are documented above.
312
+ #
313
+ # @example
314
+ #
315
+ # publishing_api.get_content_items(
316
+ # document_type: 'taxon',
317
+ # q: 'Driving',
318
+ # page: 1,
319
+ # per_page: 50,
320
+ # publishing_app: 'content-tagger',
321
+ # fields: ['title', 'description', 'public_updated_at'],
322
+ # locale: 'en',
323
+ # order: '-public_updated_at'
324
+ # )
325
+ #
326
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2content
327
+ def get_content_items(params)
328
+ query = query_string(params)
329
+ get_json("#{endpoint}/v2/content#{query}")
330
+ end
331
+
332
+ # Returns an Enumerator of content items for the provided
333
+ # query string parameters.
334
+ #
335
+ # @param params [Hash]
336
+ #
337
+ # @return [Enumerator] an enumerator of content items
338
+ #
339
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2content
340
+ def get_content_items_enum(params)
341
+ Enumerator.new do |yielder|
342
+ (1..Float::INFINITY).each do |index|
343
+ merged_params = params.merge(page: index)
344
+ page = get_content_items(merged_params).to_h
345
+ results = page.fetch("results", [])
346
+ results.each do |result|
347
+ yielder << result
348
+ end
349
+ break if page.fetch("pages") <= index
350
+ end
351
+ end
352
+ end
353
+
354
+ # FIXME: Add documentation
355
+ #
356
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2linkables
357
+ def get_linkables(document_type: nil)
358
+ if document_type.nil?
359
+ raise ArgumentError.new("Please provide a `document_type`")
360
+ end
361
+
362
+ get_json("#{endpoint}/v2/linkables?document_type=#{document_type}")
363
+ end
364
+
365
+ # FIXME: Add documentation
366
+ #
367
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2linkedcontent_id
368
+ def get_linked_items(content_id, params = {})
369
+ query = query_string(params)
370
+ validate_content_id(content_id)
371
+ get_json("#{endpoint}/v2/linked/#{content_id}#{query}")
372
+ end
373
+
374
+ # Returns a paginated list of editions for the provided query string
375
+ # parameters.
376
+ #
377
+ # @param params [Hash]
378
+ #
379
+ # @return [GdsApi::Response] a paginated list of editions
380
+ #
381
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2editions
382
+ def get_editions(params = {})
383
+ get_json(get_editions_url(params))
384
+ end
385
+
386
+ # Returns an Enumerator of Response objects for each page of results of
387
+ # editions for the provided query string parameters.
388
+ #
389
+ # @param params [Hash]
390
+ #
391
+ # @return [Enumerator] an enumerator of editions responses
392
+ #
393
+ # @see https://github.com/alphagov/publishing-api/blob/master/doc/api.md#get-v2editions
394
+ def get_paged_editions(params = {})
395
+ Enumerator.new do |yielder|
396
+ next_link = get_editions_url(params)
397
+ while next_link
398
+ yielder.yield begin
399
+ response = get_json(next_link)
400
+ end
401
+ next_link_info = response["links"].select { |link| link["rel"] == "next" }.first
402
+ next_link = next_link_info && next_link_info["href"]
403
+ end
404
+ end
405
+ end
406
+
407
+ # Returns a mapping of content_ids => links hashes
408
+ #
409
+ # @param content_ids [Array]
410
+ #
411
+ # @return [Hash] a mapping of content_id => links
412
+ #
413
+ # @example
414
+ #
415
+ # publishing_api.get_links_for_content_ids([
416
+ # "e1067450-7d13-45ff-ada4-5e3dd4025fb7",
417
+ # "72ed754c-4c82-415f-914a-ab6760454cb4"
418
+ # ])
419
+ #
420
+ # #=> {
421
+ # "e1067450-7d13-45ff-ada4-5e3dd4025fb7" => {
422
+ # links: {
423
+ # taxons: ["13bba81c-b2b1-4b13-a3de-b24748977198"]},
424
+ # ... (and more attributes)
425
+ # version: 10},
426
+ # "72ed754c-4c82-415f-914a-ab6760454cb4" => { ..etc }
427
+ # }
428
+ #
429
+ def get_links_for_content_ids(content_ids)
430
+ post_json("#{endpoint}/v2/links/by-content-id", content_ids: content_ids).to_hash
431
+ end
432
+
433
+ # Reserves a path for a publishing application
434
+ #
435
+ # Returns success or failure only.
436
+ #
437
+ # @param payload [Hash]
438
+ # @option payload [Hash] publishing_app The publishing application, like `content-tagger`
439
+ #
440
+ # @see https://docs.publishing.service.gov.uk/apis/publishing-api/api.html#put-pathsbase_path
441
+ def put_path(base_path, payload)
442
+ url = "#{endpoint}/paths#{base_path}"
443
+ put_json(url, payload)
444
+ end
445
+
446
+ def unreserve_path(base_path, publishing_app)
447
+ payload = { publishing_app: publishing_app }
448
+ delete_json(unreserve_url(base_path), payload)
449
+ end
450
+
5
451
  # Create a publishing intent for a base_path.
6
452
  #
7
453
  # @param base_path [String]
@@ -33,12 +479,48 @@ class GdsApi::PublishingApi < GdsApi::Base
33
479
  e
34
480
  end
35
481
 
36
- def unreserve_path(base_path, publishing_app)
37
- payload = { publishing_app: publishing_app }
38
- delete_json(unreserve_url(base_path), payload)
482
+ private
483
+
484
+ def content_url(content_id, params = {})
485
+ validate_content_id(content_id)
486
+ query = query_string(params)
487
+ "#{endpoint}/v2/content/#{content_id}#{query}"
39
488
  end
40
489
 
41
- private
490
+ def links_url(content_id)
491
+ validate_content_id(content_id)
492
+ "#{endpoint}/v2/links/#{content_id}"
493
+ end
494
+
495
+ def links_changes_url(params = {})
496
+ query = query_string(params)
497
+ "#{endpoint}/v2/links/changes#{query}"
498
+ end
499
+
500
+ def publish_url(content_id)
501
+ validate_content_id(content_id)
502
+ "#{endpoint}/v2/content/#{content_id}/publish"
503
+ end
504
+
505
+ def republish_url(content_id)
506
+ validate_content_id(content_id)
507
+ "#{endpoint}/v2/content/#{content_id}/republish"
508
+ end
509
+
510
+ def unpublish_url(content_id)
511
+ validate_content_id(content_id)
512
+ "#{endpoint}/v2/content/#{content_id}/unpublish"
513
+ end
514
+
515
+ def discard_url(content_id)
516
+ validate_content_id(content_id)
517
+ "#{endpoint}/v2/content/#{content_id}/discard-draft"
518
+ end
519
+
520
+ def get_editions_url(params)
521
+ query = query_string(params)
522
+ "#{endpoint}/v2/editions#{query}"
523
+ end
42
524
 
43
525
  def unreserve_url(base_path)
44
526
  "#{endpoint}/paths#{base_path}"
@@ -51,4 +533,14 @@ private
51
533
  def paths_url(base_path)
52
534
  "#{endpoint}/paths#{base_path}"
53
535
  end
536
+
537
+ def merge_optional_keys(params, options, optional_keys)
538
+ optional_keys.each_with_object(params) do |optional_key, hash|
539
+ hash.merge!(optional_key => options[optional_key]) if options[optional_key]
540
+ end
541
+ end
542
+
543
+ def validate_content_id(content_id)
544
+ raise ArgumentError, "content_id cannot be nil" unless content_id
545
+ end
54
546
  end