mapping.rb 888 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Freshdesk::Contact::Mapping < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Common::Mapping::Mixin::ProvideMapped
  4. uses :resource, :id_map
  5. def process
  6. provide_mapped do
  7. {
  8. firstname: resource['name'],
  9. lastname: '', # makes sure name guessing is triggered for updating existing users.
  10. active: !resource['deleted'],
  11. organization_id: organization_id,
  12. email: resource['email'],
  13. mobile: resource['mobile'],
  14. phone: resource['phone'],
  15. group_ids: [],
  16. role_ids: ::Role.where(name: 'Customer').pluck(:id),
  17. }
  18. end
  19. end
  20. private
  21. def organization_id
  22. id_map.dig('Organization', resource['company_id'])
  23. end
  24. end