Class: Telapi::InboundXml

Inherits:
Object
  • Object
show all
Defined in:
lib/telapi/inbound_xml.rb

Overview

Wraps TelAPI InboundXML functionality See http://www.telapi.com/docs/api/inboundxml/voice/introduction/

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ InboundXml

Internally Nokogiri builder is being used to construct responses. See http://nokogiri.org/Nokogiri/XML/Builder.html

Pass in a block of options:

Telapi::InboundXml.new do Say('Hello.', :loop => 3, :voice => 'man') Say('Hello, my name is Jane.', :voice => 'woman') Say('Now I will not stop talking.', :loop => 0) end

Then calling #response produces the following output:

Hello. Hello, my name is Jane. Now I will not stop talking.


26
27
28
29
# File 'lib/telapi/inbound_xml.rb', line 26

def initialize(&block)
  @xml = Nokogiri::XML::Builder.new
  @xml.Response &block
end

Instance Method Details

#responseObject

Returns xml



32
33
34
# File 'lib/telapi/inbound_xml.rb', line 32

def response
  @xml.to_xml
end