Class: Twilio::Rails::Phone::Twiml::PromptResponseOperation

Inherits:
BaseOperation show all
Defined in:
app/operations/twilio/rails/phone/twiml/prompt_response_operation.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/operations/twilio/rails/phone/twiml/prompt_response_operation.rb', line 11

def execute
  return Twilio::Rails::Phone::Twiml::ErrorOperation.call(phone_call_id: phone_call.id, tree: tree) if phone_call.answering_machine?

  response = phone_call.responses.find(response_id)
  response = Twilio::Rails::Phone::UpdateResponseOperation.call(params: params, response_id: response.id, phone_call_id: phone_call.id)

  prompt = tree.prompts[response.prompt_handle]
  raise Twilio::Rails::Phone::InvalidTreeError, "cannot find #{ response.prompt_handle } in #{ tree.name }" unless prompt

  after = prompt.after
  after = Twilio::Rails::Phone::Tree::After.new(after.proc.call(response)) if after.proc

  Twilio::Rails::Phone::Twiml::AfterOperation.call(phone_call_id: phone_call.id, tree: tree, after: after)
end