default_language.rb 787 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Kayako::DefaultLanguage < Sequencer::Unit::Base
  3. include ::Sequencer::Unit::Import::Kayako::Requester
  4. provides :default_language
  5. def process
  6. state.provide(:default_language, default_language)
  7. end
  8. private
  9. def default_language
  10. settings = fetch_settings
  11. default_language_setting = settings.detect { |item| item['name'] == 'default_language' }
  12. default_language_setting['value'] || 'en-us'
  13. end
  14. def fetch_settings
  15. response = request(
  16. api_path: 'settings'
  17. )
  18. body = JSON.parse(response.body)
  19. body['data']
  20. rescue => e
  21. logger.error 'Error when fetching settings for default language'
  22. logger.error e
  23. nil
  24. end
  25. end