fetch.rb 658 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Freshdesk::Ticket::Fetch < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Freshdesk::Requester
  4. uses :resource
  5. # Fetch additional data such as attachments which is not included
  6. # in the ticket list endpoint.
  7. def process
  8. resource.merge!(fetch_ticket)
  9. end
  10. private
  11. def fetch_ticket
  12. response = request(
  13. api_path: "tickets/#{resource['id']}",
  14. )
  15. JSON.parse(response.body)
  16. rescue => e
  17. logger.error "Error when fetching ticket data for ticket #{resource['id']}"
  18. logger.error e
  19. {}
  20. end
  21. end