history_factory.rb 858 B

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