history_factory.rb 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Import
  3. module OTRS
  4. module HistoryFactory
  5. extend Import::Factory
  6. extend self
  7. def skip?(record, *_args)
  8. return true if !determine_class(record)
  9. false
  10. end
  11. def backend_class(record, *_args)
  12. "Import::OTRS::History::#{determine_class(record)}".constantize
  13. end
  14. private
  15. def determine_class(history)
  16. check_supported(history) || check_article(history)
  17. end
  18. def supported_types
  19. %w[NewTicket StateUpdate Move PriorityUpdate]
  20. end
  21. def check_supported(history)
  22. return if supported_types.exclude?(history['HistoryType'])
  23. history['HistoryType']
  24. end
  25. def check_article(history)
  26. return if !history['ArticleID']
  27. return if history['ArticleID'].to_i.zero?
  28. 'Article'
  29. end
  30. end
  31. end
  32. end