Class: Twilio::Rails::PhoneController

Inherits:
ApplicationController show all
Defined in:
app/controllers/twilio/rails/phone_controller.rb

Instance Method Summary collapse

Instance Method Details

#inboundObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/twilio/rails/phone_controller.rb', line 9

def inbound
  respond_to do |format|
    format.xml do
      begin
        phone_call = Twilio::Rails::Phone::CreateOperation.call(params: params_hash, tree: tree)
      rescue
        render xml: Twilio::Rails::Phone::Twiml::InvalidPhoneNumberOperation.call(tree: tree)
      else
        render xml: Twilio::Rails::Phone::Twiml::GreetingOperation.call(phone_call_id: phone_call.id, tree: tree)
      end
    end
  end
end

#outboundObject



23
24
25
26
27
28
29
30
# File 'app/controllers/twilio/rails/phone_controller.rb', line 23

def outbound
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      render xml: Twilio::Rails::Phone::Twiml::GreetingOperation.call(phone_call_id: phone_call.id, tree: tree)
    end
  end
end

#promptObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/twilio/rails/phone_controller.rb', line 32

def prompt
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      phone_call = Twilio::Rails::Phone::UpdateOperation.call(phone_call_id: phone_call.id, params: params_hash)
      render xml: Twilio::Rails::Phone::Twiml::PromptOperation.call(phone_call_id: phone_call.id, tree: tree, response_id: params[:response_id].to_i)
    end
  end
end

#prompt_responseObject



42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/twilio/rails/phone_controller.rb', line 42

def prompt_response
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      phone_call = Twilio::Rails::Phone::UpdateOperation.call(phone_call_id: phone_call.id, params: params_hash)
      Twilio::Rails::Phone::UpdateResponseOperation.call(phone_call_id: phone_call.id, response_id: params[:response_id].to_i, params: params_hash)
      render xml: Twilio::Rails::Phone::Twiml::PromptResponseOperation.call(phone_call_id: phone_call.id, tree: tree, response_id: params[:response_id].to_i, params: params_hash)
    end
  end
end

#receive_response_recordingObject



85
86
87
88
89
90
91
92
93
94
# File 'app/controllers/twilio/rails/phone_controller.rb', line 85

def receive_response_recording
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      Twilio::Rails::Phone::ReceiveRecordingOperation.call(phone_call_id: phone_call.id, response_id: params[:response_id].to_i, params: params_hash)

      head :ok
    end
  end
end

#statusObject



74
75
76
77
78
79
80
81
82
83
# File 'app/controllers/twilio/rails/phone_controller.rb', line 74

def status
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      phone_call = Twilio::Rails::Phone::UpdateOperation.call(phone_call_id: phone_call.id, params: params_hash)

      head :ok
    end
  end
end

#timeoutObject



53
54
55
56
57
58
59
60
61
# File 'app/controllers/twilio/rails/phone_controller.rb', line 53

def timeout
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      phone_call = Twilio::Rails::Phone::UpdateOperation.call(phone_call_id: phone_call.id, params: params_hash)
      render xml: Twilio::Rails::Phone::Twiml::TimeoutOperation.call(phone_call_id: phone_call.id, tree: tree, response_id: params[:response_id].to_i)
    end
  end
end

#transcribeObject



63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/twilio/rails/phone_controller.rb', line 63

def transcribe
  respond_to do |format|
    format.xml do
      phone_call = Twilio::Rails::Phone::FindOperation.call(params: params_hash)
      Twilio::Rails::Phone::UpdateResponseOperation.call(phone_call_id: phone_call.id, response_id: params[:response_id].to_i, params: params_hash)

      head :ok
    end
  end
end