Class: Killbill::Zendesk::UserUpdaterInitializer
- Inherits:
-
Object
- Object
- Killbill::Zendesk::UserUpdaterInitializer
- Includes:
- Singleton
- Defined in:
- lib/zendesk/user_updater_initializer.rb
Instance Attribute Summary collapse
-
#updater ⇒ Object
readonly
Returns the value of attribute updater.
Instance Method Summary collapse
Instance Attribute Details
#updater ⇒ Object (readonly)
Returns the value of attribute updater.
5 6 7 |
# File 'lib/zendesk/user_updater_initializer.rb', line 5 def updater @updater end |
Instance Method Details
#initialize!(conf_dir, kb_apis, logger) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zendesk/user_updater_initializer.rb', line 7 def initialize!(conf_dir, kb_apis, logger) # Parse the config file begin @config = YAML.load_file("#{conf_dir}/zendesk.yml") rescue Errno::ENOENT logger.warn "Unable to find the config file #{conf_dir}/zendesk.yml" return end logger.log_level = Logger::DEBUG if (@config[:logger] || {})[:debug] client = ZendeskAPI::Client.new do |config| config.url = "https://#{@config[:zendesk][:subdomain]}.zendesk.com/api/v2" config.username = @config[:zendesk][:username] config.password = @config[:zendesk][:password] config.token = @config[:zendesk][:token] # Not yet available? #config.access_token = @config[:zendesk][:access_token] config.retry = true if @config[:zendesk][:retry] config.logger = logger end if defined?(JRUBY_VERSION) # See https://github.com/jruby/activerecord-jdbc-adapter/issues/302 require 'jdbc/mysql' Jdbc::MySQL.load_driver(:require) if Jdbc::MySQL.respond_to?(:load_driver) end ActiveRecord::Base.establish_connection(@config[:database]) ActiveRecord::Base.logger = logger @updater = UserUpdater.new(client, kb_apis, logger) end |
#initialized? ⇒ Boolean
43 44 45 |
# File 'lib/zendesk/user_updater_initializer.rb', line 43 def initialized? !@updater.nil? end |