cti_controller.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class CtiController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  4. # list current caller log
  5. # GET /api/v1/cti/log
  6. def index
  7. backends = [
  8. {
  9. name: __('CTI (generic)'),
  10. enabled: Setting.get('cti_integration'),
  11. url: '#system/integration/cti',
  12. },
  13. {
  14. name: 'sipgate.io',
  15. enabled: Setting.get('sipgate_integration'),
  16. url: '#system/integration/sipgate',
  17. },
  18. {
  19. name: __('Placetel'),
  20. enabled: Setting.get('placetel_integration'),
  21. url: '#system/integration/placetel',
  22. }
  23. ]
  24. result = Cti::Log.log(current_user)
  25. result[:backends] = backends
  26. render json: result
  27. end
  28. # set caller log to done
  29. # POST /api/v1/cti/done/:id
  30. def done
  31. log = Cti::Log.find(params['id'])
  32. log.done = params['done']
  33. log.save!
  34. render json: {}
  35. end
  36. # sets for all given ids the caller log to done
  37. # POST /api/v1/cti/done/bulk
  38. def done_bulk
  39. log_ids = params['ids'] || []
  40. log_ids.each do |log_id|
  41. log = Cti::Log.find(log_id)
  42. log.done = true
  43. log.save!
  44. end
  45. render json: {}
  46. end
  47. end