class GdsApi::PublishingApiV2

def unpublish(content_id, type:, explanation: nil, alternative_path: nil, discard_drafts: false, allow_draft: false, previous_version: nil, locale: nil)

Other tags:
    See: https://github.com/alphagov/publishing-api/blob/master/doc/publishing-api-syntactic-usage.md#post-v2contentcontent_idunpublish -

Parameters:
  • locale (String) -- (optional) The content item locale.
  • previous_version (Integer) -- (optional) A lock version number for optimistic locking.
  • discard_drafts (Boolean) -- (optional) Whether to discard drafts on that item. Defaults to false.
  • alternative_path (String) -- (optional) Alternative path to show on the page or redirect to.
  • explanation (String) -- (optional) Text to show on the page.
  • type (String) -- Either 'withdrawal', 'gone' or 'redirect'.
  • content_id (UUID) --
def unpublish(content_id, type:, explanation: nil, alternative_path: nil, discard_drafts: false, allow_draft: false, previous_version: nil, locale: nil)
  params = {
    type: type
  }
  params.merge!(explanation: explanation) if explanation
  params.merge!(alternative_path: alternative_path) if alternative_path
  params.merge!(previous_version: previous_version) if previous_version
  params.merge!(discard_drafts: discard_drafts) if discard_drafts
  params.merge!(allow_draft: allow_draft) if allow_draft
  params.merge!(locale: locale) if locale
  post_json!(unpublish_url(content_id), params)
end