Class: Contentful::Scheduler::Tasks::Unpublish

Inherits:
Object
  • Object
show all
Defined in:
lib/contentful/scheduler/tasks/unpublish.rb

Class Method Summary collapse

Class Method Details

.perform(space_id, entry_id, token) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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