2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2016-04-29 22:21:39 +00:00
|
|
|
|
|
|
|
class CtiController < ApplicationController
|
2020-03-19 09:39:51 +00:00
|
|
|
prepend_before_action { authentication_check && authorize! }
|
2016-04-29 22:21:39 +00:00
|
|
|
|
|
|
|
# list current caller log
|
2019-08-16 22:24:50 +00:00
|
|
|
# GET /api/v1/cti/log
|
2016-04-29 22:21:39 +00:00
|
|
|
def index
|
|
|
|
backends = [
|
2018-05-28 23:45:29 +00:00
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'CTI (generic)',
|
2018-05-28 23:45:29 +00:00
|
|
|
enabled: Setting.get('cti_integration'),
|
2018-12-19 17:31:51 +00:00
|
|
|
url: '#system/integration/cti',
|
2018-05-28 23:45:29 +00:00
|
|
|
},
|
2016-04-29 22:21:39 +00:00
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'sipgate.io',
|
2016-04-29 22:21:39 +00:00
|
|
|
enabled: Setting.get('sipgate_integration'),
|
2018-12-19 17:31:51 +00:00
|
|
|
url: '#system/integration/sipgate',
|
2018-10-15 09:47:59 +00:00
|
|
|
},
|
|
|
|
{
|
2018-12-19 17:31:51 +00:00
|
|
|
name: 'Placetel',
|
2018-10-15 09:47:59 +00:00
|
|
|
enabled: Setting.get('placetel_integration'),
|
2018-12-19 17:31:51 +00:00
|
|
|
url: '#system/integration/placetel',
|
2016-04-29 22:21:39 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-07-09 22:07:32 +00:00
|
|
|
result = Cti::Log.log(current_user)
|
2016-04-29 22:21:39 +00:00
|
|
|
result[:backends] = backends
|
|
|
|
render json: result
|
|
|
|
end
|
|
|
|
|
|
|
|
# set caller log to done
|
2019-08-16 22:24:50 +00:00
|
|
|
# POST /api/v1/cti/done/:id
|
2016-04-29 22:21:39 +00:00
|
|
|
def done
|
|
|
|
log = Cti::Log.find(params['id'])
|
|
|
|
log.done = params['done']
|
2017-10-02 10:31:59 +00:00
|
|
|
log.save!
|
2016-04-29 22:21:39 +00:00
|
|
|
render json: {}
|
|
|
|
end
|
|
|
|
|
2019-08-16 22:24:50 +00:00
|
|
|
# sets for all given ids the caller log to done
|
|
|
|
# POST /api/v1/cti/done/bulk
|
|
|
|
def done_bulk
|
|
|
|
|
|
|
|
log_ids = params['ids'] || []
|
|
|
|
log_ids.each do |log_id|
|
|
|
|
log = Cti::Log.find(log_id)
|
|
|
|
log.done = true
|
|
|
|
log.save!
|
|
|
|
end
|
|
|
|
render json: {}
|
|
|
|
end
|
|
|
|
|
2016-04-29 22:21:39 +00:00
|
|
|
end
|