base.rb 832 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Kayako::Post::Channel::Base
  3. attr_reader :resource
  4. def initialize(resource)
  5. @resource = resource
  6. end
  7. def mapping
  8. {
  9. message_id: resource['id'],
  10. internal: internal?,
  11. from: from,
  12. type_id: article_type_id,
  13. }
  14. end
  15. def article_type_id
  16. return if article_type_name.nil?
  17. ::Ticket::Article::Type.select(:id).find_by(name: article_type_name).id
  18. end
  19. private
  20. def internal?
  21. false
  22. end
  23. def original_post
  24. resource['original']
  25. end
  26. def article_type_name
  27. raise NotImplementedError
  28. end
  29. def identify_key
  30. raise NotImplementedError
  31. end
  32. def from
  33. return if resource['identity'].nil?
  34. resource['identity'][identify_key]
  35. end
  36. end