Class: Telephony::AgentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Telephony::AgentsController
- Defined in:
- app/controllers/telephony/agents_controller.rb
Instance Method Summary collapse
- #index ⇒ Object
- #show_by_csr_id ⇒ Object
- #status ⇒ Object
- #terminate_active_call ⇒ Object
- #update ⇒ Object
Instance Method Details
#index ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/telephony/agents_controller.rb', line 40 def index agents = Agent.all_transferable_for_csr_id params[:csr_id] render :json => agents end |
#show_by_csr_id ⇒ Object
5 6 7 8 |
# File 'app/controllers/telephony/agents_controller.rb', line 5 def show_by_csr_id agent = Agent.find_by_csr_id params[:csr_id] render json: agent.as_json(only: [:id, :csr_id, :name], methods: :active_conversation_id) end |
#status ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/telephony/agents_controller.rb', line 31 def status agent = Agent.find_by_csr_id params[:id] agent.with_lock do agent.fire_events params[:event] end render :json => { :csr_id => agent.csr_id, :status => agent.status } end |
#terminate_active_call ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/telephony/agents_controller.rb', line 10 def terminate_active_call agent = Agent.find_by_csr_id params[:id] if agent agent.with_lock { agent.terminate_active_call } render :json => {} else render status: :bad_request, json: { errors: 'Csr Id invalid' } end end |
#update ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/telephony/agents_controller.rb', line 21 def update agent = Agent. params if agent.valid? render status: :ok, json: { conversation_id: agent.active_conversation_id } else render status: :bad_request, json: { errors: agent.errors. } end end |