2015-12-17 18:15:50 +00:00
|
|
|
require 'base64'
|
|
|
|
require 'zendesk_api'
|
|
|
|
|
|
|
|
module Import
|
|
|
|
end
|
|
|
|
module Import::Zendesk
|
2016-12-19 08:59:54 +00:00
|
|
|
extend Import::Helper
|
|
|
|
extend Import::Zendesk::Async
|
|
|
|
extend Import::Zendesk::ImportStats
|
2015-12-17 18:15:50 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
# rubocop:disable Style/ModuleFunction
|
|
|
|
extend self
|
2015-12-17 18:15:50 +00:00
|
|
|
|
|
|
|
def start
|
2016-12-19 08:59:54 +00:00
|
|
|
log 'Start import...'
|
2015-12-17 18:15:50 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
checks
|
2015-12-17 18:15:50 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
Import::Zendesk::GroupFactory.import(client.groups)
|
2015-12-17 18:15:50 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
Import::Zendesk::OrganizationFieldFactory.import(client.organization_fields)
|
|
|
|
Import::Zendesk::OrganizationFactory.import(client.organizations)
|
2015-12-17 18:15:50 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
Import::Zendesk::UserFieldFactory.import(client.user_fields)
|
|
|
|
Import::Zendesk::UserFactory.import(client.users)
|
2015-12-17 18:15:50 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
Import::Zendesk::TicketFieldFactory.import(client.ticket_fields)
|
|
|
|
Import::Zendesk::TicketFactory.import(client.tickets)
|
2015-12-17 18:15:50 +00:00
|
|
|
|
|
|
|
# TODO
|
|
|
|
Setting.set( 'system_init_done', true )
|
|
|
|
Setting.set( 'import_mode', false )
|
|
|
|
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2016-01-18 19:32:34 +00:00
|
|
|
def connection_test
|
2016-12-19 08:59:54 +00:00
|
|
|
Import::Zendesk::Requester.connection_test
|
2015-12-17 18:15:50 +00:00
|
|
|
end
|
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
private
|
2016-11-08 15:21:30 +00:00
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
def client
|
|
|
|
Import::Zendesk::Requester.client
|
2016-11-08 15:21:30 +00:00
|
|
|
end
|
|
|
|
|
2016-12-19 08:59:54 +00:00
|
|
|
def checks
|
|
|
|
check_import_mode
|
|
|
|
connection_test
|
2016-11-08 15:21:30 +00:00
|
|
|
end
|
2015-12-17 18:15:50 +00:00
|
|
|
end
|