identifier.rb 614 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Kayako::User::Identifier < Sequencer::Unit::Common::Provider::Named
  3. uses :resource
  4. private
  5. def identifier
  6. {
  7. email: primary_value('emails', 'email'),
  8. phone: primary_value('phones', 'number'),
  9. twitter: primary_value('twitter', 'screen_name'),
  10. facebook: primary_value('facebook', 'facebook_id'),
  11. }
  12. end
  13. def primary_value(type, field_name)
  14. primary_item = resource[type]&.detect { |item| item['is_primary'] }
  15. primary_item&.fetch(field_name)
  16. end
  17. end