history_factory.rb 901 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. module Import
  2. module OTRS
  3. module HistoryFactory
  4. extend Import::Factory
  5. # rubocop:disable Style/ModuleFunction
  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.include?(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