class Contentful::Scheduler::Tasks::Unpublish

Public Class Methods

perform(space_id, entry_id, token) click to toggle source
# File lib/contentful/scheduler/tasks/unpublish.rb, line 12
        def self.perform(space_id, entry_id, token)

=begin
 We wont unpublish linked items as they could have been used somewhere else
 even though we enable these commentted code Contentful handles this situtation
 ethically.
          logger = Logger.new(STDOUT)

          client = Contentful::Client.new(
              space: space_id,
              access_token: ::Contentful::Scheduler.config[:spaces][space_id][:delivery_token]
          )
=end

          clientManagement = ::Contentful::Management::Client.new(
              token,
              raise_errors: true,
              application_name: 'contentful.scheduler',
              application_version: Contentful::Scheduler::VERSION
          )

=begin
          linked_entries = client.entries(links_to_entry: entry_id)

          if !linked_entries.raw["includes"].nil? && !linked_entries.raw["includes"]["Entry"].nil?
            linked_entries_ids = Taskshelper.extract_element_ids(linked_entries.raw["includes"]["Entry"])
            logger.info("Linked enteries for entry_id ==>> #{entry_id} are ==>> #{linked_entries_ids}")
            linked_entries_ids.each do |id|
              logger.info"Unpublishing linked entry with id #{id}"
              clientManagement.entries.find(space_id, id).unpublish
            end
          end
=end

          clientManagement.entries.find(space_id, entry_id).unpublish
        end