trabajo-afectivo/lib/sequencer/unit/import/kayako/default_language.rb

44 lines
1 KiB
Ruby
Raw Permalink Normal View History

2022-01-01 13:38:12 +00:00
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
class Sequencer
class Unit
module Import
module Kayako
class DefaultLanguage < Sequencer::Unit::Base
include ::Sequencer::Unit::Import::Kayako::Requester
provides :default_language
def process
state.provide(:default_language, default_language)
end
private
def default_language
settings = fetch_settings
default_language_setting = settings.detect { |item| item['name'] == 'default_language' }
default_language_setting['value'] || 'en-us'
end
def fetch_settings
response = request(
api_path: 'settings'
)
body = JSON.parse(response.body)
body['data']
rescue => e
logger.error 'Error when fetching settings for default language'
logger.error e
nil
end
end
end
end
end
end