class GdsApi::PublishingApiV2
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)
- See: https://github.com/alphagov/publishing-api/blob/master/doc/api.md#post-v2contentcontent_idunpublish -
Parameters:
-
redirects(Array) -- (optional) Required if no alternative_path is given. An array of redirect values, ie: { path:, type:, destination: } -
unpublished_at(Time) -- (optional) The time the content was withdrawn. Ignored for types other than withdrawn -
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, unpublished_at: nil, redirects: nil) params = { type: type } params[:explanation] = explanation if explanation params[:alternative_path] = alternative_path if alternative_path params[:previous_version] = previous_version if previous_version params[:discard_drafts] = discard_drafts if discard_drafts params[:allow_draft] = allow_draft if allow_draft params[:locale] = locale if locale params[:unpublished_at] = unpublished_at.utc.iso8601 if unpublished_at params[:redirects] = redirects if redirects post_json(unpublish_url(content_id), params) end