Class: Twilio::Rails::Phone::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/twilio/rails/phone/tree.rb

Overview

Implementation class for a phone tree. See BaseTree for detailed documentation.

Defined Under Namespace

Classes: After, Gather, Message, MessageSet, Prompt

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tree_name) ⇒ Tree

Returns a new instance of Tree.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/twilio/rails/phone/tree.rb', line 10

def initialize(tree_name)
  @name = tree_name.to_s
  raise Twilio::Rails::Phone::InvalidTreeError, "tree name cannot be blank" unless name.present?

  @prompts = {}.with_indifferent_access
  @config = {}.with_indifferent_access

  # defaults
  @config[:voice] = "male"
  @config[:final_timeout_message] = "Goodbye."
  @config[:final_timeout_attempts] = 3
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/twilio/rails/phone/tree.rb', line 7

def config
  @config
end

#finished_callObject

Returns the value of attribute finished_call.



8
9
10
# File 'lib/twilio/rails/phone/tree.rb', line 8

def finished_call
  @finished_call
end

#greetingObject

Returns the value of attribute greeting.



8
9
10
# File 'lib/twilio/rails/phone/tree.rb', line 8

def greeting
  @greeting
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/twilio/rails/phone/tree.rb', line 7

def name
  @name
end

#promptsObject (readonly)

Returns the value of attribute prompts.



7
8
9
# File 'lib/twilio/rails/phone/tree.rb', line 7

def prompts
  @prompts
end

#unanswered_callObject

Returns the value of attribute unanswered_call.



8
9
10
# File 'lib/twilio/rails/phone/tree.rb', line 8

def unanswered_call
  @unanswered_call
end

Instance Method Details

#inbound_urlString

The fully qualified URL for the tree used by Twilio to be configured in the dashboard.

Returns:

  • (String)

    The inbound URL for the phone tree.



33
34
35
# File 'lib/twilio/rails/phone/tree.rb', line 33

def inbound_url
  "#{ ::Twilio::Rails.config.host }#{ ::Twilio::Rails::Engine.routes.url_helpers.phone_inbound_path(tree_name: name, format: :xml) }"
end

#outbound_urlString

The fully qualified URL for the tree used by Twilio to make outbound calls.

Returns:

  • (String)

    The outbound URL for the phone tree.



26
27
28
# File 'lib/twilio/rails/phone/tree.rb', line 26

def outbound_url
  "#{ ::Twilio::Rails.config.host }#{ ::Twilio::Rails::Engine.routes.url_helpers.phone_outbound_path(tree_name: name, format: :xml) }"
end