Class: Telephony::Providers::Twilio::InboundCallsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/telephony/providers/twilio/inbound_calls_controller.rb

Instance Method Summary collapse

Instance Method Details

#connectObject



30
31
32
33
34
35
36
# File 'app/controllers/telephony/providers/twilio/inbound_calls_controller.rb', line 30

def connect
  @call = Call.find_by_sid params[:CallSid]
  agent = Agent.find_by_csr_id params[:csr_id]
  @connecting_call = @call.conversation.calls.find_by_agent_id agent.id

  render template: '/telephony/providers/twilio/calls/connect'
end

#createObject



5
6
7
8
9
10
11
12
# File 'app/controllers/telephony/providers/twilio/inbound_calls_controller.rb', line 5

def create
  if Telephony::BlacklistedNumber.where(number: Telephony.americanize(params[:From])).exists?
    InboundConversationQueue.reject params
    render :reject
  else
    play_message
  end
end

#enqueueObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/telephony/providers/twilio/inbound_calls_controller.rb', line 17

def enqueue
  Conversation.find_inbound_with_lock(params[:id]) do |conversation|
    @call = conversation.calls.first

    if params[:CallStatus] == 'completed'
      @call.terminate!
      render template: 'telephony/providers/twilio/calls/whisper_tone'
    else
      conversation.enqueue!
    end
  end
end

#wait_musicObject



14
15
# File 'app/controllers/telephony/providers/twilio/inbound_calls_controller.rb', line 14

def wait_music
end