webficient-twilio 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/lib/twilio/verb.rb +152 -167
- data/test/fixtures/yml/verb_responses.yml +7 -1
- data/test/twilio/verb_test.rb +38 -30
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/twilio/verb.rb
CHANGED
@@ -1,186 +1,171 @@
|
|
1
1
|
module Twilio
|
2
2
|
# Twilio Verbs enable your application to respond to Twilio requests (to your app) with XML responses.
|
3
|
-
#
|
4
|
-
# In addition to the 5 verbs supported by Twilio (say, play, gather, record, dial),
|
5
|
-
# this class also implements dynamic interfaces that allow you to combine useful
|
6
|
-
# operations into a single call. See below methods for examples.
|
3
|
+
# There are 5 primary verbs (say, play, gather, record, dial) and 3 secondary (hangup, pause, redirect).
|
7
4
|
class Verb
|
8
|
-
class << self
|
9
|
-
# The Say verb converts text to speech that is read back to the caller.
|
10
|
-
# Say is useful for dynamic text that is difficult to prerecord.
|
11
|
-
#
|
12
|
-
# Examples:
|
13
|
-
# Twilio::Verb.say('The time is 9:35 PM.')
|
14
|
-
# Twilio::Verb.say_3_times('The time is 9:35 PM.')
|
15
|
-
#
|
16
|
-
# With numbers, 12345 will be spoken as "twelve thousand three hundred forty five" while
|
17
|
-
# 1 2 3 4 5 will be spoken as "one two three four five."
|
18
|
-
#
|
19
|
-
# Twilio::Verb.say_4_times('Your PIN is 1234')
|
20
|
-
# Twilio::Verb.say_4_times('Your PIN is 1 2 3 4')
|
21
|
-
#
|
22
|
-
# If you need a longer pause between each loop, use the pause form:
|
23
|
-
#
|
24
|
-
# Twilio::Verb.say_4_times_with_pause('Your PIN is 1 2 3 4')
|
25
|
-
#
|
26
|
-
# Options (see http://www.twilio.com/docs/api_reference/TwiML/say) are passed in as a hash:
|
27
|
-
#
|
28
|
-
# Twilio::Verb.say('The time is 9:35 PM.', :voice => 'woman')
|
29
|
-
# Twilio::Verb.say('The time is 9:35 PM.', {:voice => 'woman', :language => 'es'})
|
30
|
-
def say(*args, &block)
|
31
|
-
options = {:voice => 'man', :language => 'en', :loop => 1}
|
32
|
-
args.each do |arg|
|
33
|
-
case arg
|
34
|
-
when String
|
35
|
-
options[:text_to_speak] = arg
|
36
|
-
when Hash
|
37
|
-
options.merge!(arg)
|
38
|
-
else
|
39
|
-
raise ArgumentError, 'say expects String or Hash argument'
|
40
|
-
end
|
41
|
-
end
|
42
5
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
if options[:pause]
|
47
|
-
loop_with_pause(options[:loop], xml) do
|
48
|
-
xml.Say(options[:text_to_speak], :voice => options[:voice], :language => options[:language])
|
49
|
-
end
|
50
|
-
else
|
51
|
-
xml.Say(options[:text_to_speak], :voice => options[:voice], :language => options[:language], :loop => options[:loop])
|
52
|
-
end
|
53
|
-
}
|
54
|
-
end
|
6
|
+
def initialize(&block)
|
7
|
+
@xml = Builder::XmlMarkup.new
|
8
|
+
@xml.instruct!
|
55
9
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
10
|
+
block.call(self) if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
# The Say verb converts text to speech that is read back to the caller.
|
14
|
+
# Say is useful for dynamic text that is difficult to prerecord.
|
15
|
+
#
|
16
|
+
# Examples:
|
17
|
+
# Twilio::Verb.new.say('The time is 9:35 PM.')
|
18
|
+
# Twilio::Verb.new.say('The time is 9:35 PM.', :loop => 3)
|
19
|
+
#
|
20
|
+
# With numbers, 12345 will be spoken as "twelve thousand three hundred forty five" while
|
21
|
+
# 1 2 3 4 5 will be spoken as "one two three four five."
|
22
|
+
#
|
23
|
+
# Twilio::Verb.new.say('Your PIN is 1234', :loop => 4)
|
24
|
+
# Twilio::Verb.new.say('Your PIN is 1 2 3 4', :loop => 4)
|
25
|
+
#
|
26
|
+
# If you need a longer pause between each loop, set the pause option:
|
27
|
+
#
|
28
|
+
# Twilio::Verb.new.say('Your PIN is 1 2 3 4', :loop => 4, :pause => true)
|
29
|
+
#
|
30
|
+
# Options (see http://www.twilio.com/docs/api_reference/TwiML/say) are passed in as a hash:
|
31
|
+
#
|
32
|
+
# Twilio::Verb.new.say('The time is 9:35 PM.', :voice => 'woman')
|
33
|
+
# Twilio::Verb.new.say('The time is 9:35 PM.', {:voice => 'woman', :language => 'es'})
|
34
|
+
def say(*args, &block)
|
35
|
+
options = {:voice => 'man', :language => 'en', :loop => 1}
|
36
|
+
args.each do |arg|
|
37
|
+
case arg
|
38
|
+
when String
|
39
|
+
options[:text_to_speak] = arg
|
40
|
+
when Hash
|
41
|
+
options.merge!(arg)
|
42
|
+
else
|
43
|
+
raise ArgumentError, 'say expects String or Hash argument'
|
79
44
|
end
|
80
|
-
|
81
|
-
xml = Builder::XmlMarkup.new
|
82
|
-
xml.instruct!
|
83
|
-
xml.Response {
|
84
|
-
if options[:pause]
|
85
|
-
loop_with_pause(options[:loop], xml) do
|
86
|
-
xml.Play(options[:audio_url])
|
87
|
-
end
|
88
|
-
else
|
89
|
-
xml.Play(options[:audio_url], :loop => options[:loop])
|
90
|
-
end
|
91
|
-
}
|
92
|
-
end
|
93
|
-
|
94
|
-
# The Gather verb collects digits entered by a caller into their telephone keypad.
|
95
|
-
# When the caller is done entering data, Twilio submits that data to a provided URL,
|
96
|
-
# as either a HTTP GET or POST request, just like a web browser submits data from an HTML form.
|
97
|
-
#
|
98
|
-
# Options (see http://www.twilio.com/docs/api_reference/TwiML/gather) are passed in as a hash
|
99
|
-
#
|
100
|
-
# Examples:
|
101
|
-
# Twilio::Verb.gather
|
102
|
-
# Twilio::Verb.gather(:action => 'http://foobar.com')
|
103
|
-
# Twilio::Verb.gather(:finishOnKey => '*')
|
104
|
-
# Twilio::Verb.gather(:action => 'http://foobar.com', :finishOnKey => '*')
|
105
|
-
def gather(*args, &block)
|
106
|
-
options = args.shift
|
107
|
-
xml = Builder::XmlMarkup.new
|
108
|
-
xml.instruct!
|
109
|
-
xml.Response { xml.Gather(options) }
|
110
45
|
end
|
111
46
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
#
|
117
|
-
# Examples:
|
118
|
-
# Twilio::Verb.record
|
119
|
-
# Twilio::Verb.record(:action => 'http://foobar.com')
|
120
|
-
# Twilio::Verb.record(:finishOnKey => '*')
|
121
|
-
# Twilio::Verb.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
|
122
|
-
def record(*args, &block)
|
123
|
-
options = args.shift
|
124
|
-
xml = Builder::XmlMarkup.new
|
125
|
-
xml.instruct!
|
126
|
-
xml.Response { xml.Record(options) }
|
127
|
-
end
|
128
|
-
|
129
|
-
# The Dial verb connects the current caller to an another phone. If the called party picks up,
|
130
|
-
# the two parties are connected and can communicate until one hangs up. If the called party does
|
131
|
-
# not pick up, if a busy signal is received, or the number doesn't exist, the dial verb will finish.
|
132
|
-
#
|
133
|
-
# If an action verb is provided, Twilio will submit the outcome of the call attempt to the action URL.
|
134
|
-
# If no action is provided, Dial will fall through to the next verb in the document.
|
135
|
-
#
|
136
|
-
# Note: this is different than the behavior of Record and Gather. Dial does not submit back to the
|
137
|
-
# current document URL if no action is provided.
|
138
|
-
#
|
139
|
-
# Options (see http://www.twilio.com/docs/api_reference/TwiML/dial) are passed in as a hash
|
140
|
-
#
|
141
|
-
# Examples:
|
142
|
-
# Twilio::Verb.dial('415-123-4567')
|
143
|
-
# Twilio::Verb.dial('415-123-4567', :action => 'http://foobar.com')
|
144
|
-
# Twilio::Verb.dial('415-123-4567', {:timeout => 10, :callerId => '858-987-6543'})
|
145
|
-
def dial(*args, &block)
|
146
|
-
number_to_dial = ''
|
147
|
-
options = {}
|
148
|
-
args.each do |arg|
|
149
|
-
case arg
|
150
|
-
when String
|
151
|
-
number_to_dial = arg
|
152
|
-
when Hash
|
153
|
-
options.merge!(arg)
|
154
|
-
else
|
155
|
-
raise ArgumentError, 'dial expects String or Hash argument'
|
47
|
+
response {
|
48
|
+
if options[:pause]
|
49
|
+
loop_with_pause(options[:loop], @xml) do
|
50
|
+
@xml.Say(options[:text_to_speak], :voice => options[:voice], :language => options[:language])
|
156
51
|
end
|
52
|
+
else
|
53
|
+
@xml.Say(options[:text_to_speak], :voice => options[:voice], :language => options[:language], :loop => options[:loop])
|
54
|
+
end
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# The Play verb plays an audio URL back to the caller.
|
59
|
+
# Examples:
|
60
|
+
# Twilio::Verb.new.play('http://foo.com/cowbell.mp3')
|
61
|
+
# Twilio::Verb.new.play('http://foo.com/cowbell.mp3', :loop => 3)
|
62
|
+
#
|
63
|
+
# If you need a longer pause between each loop, set the pause option:
|
64
|
+
#
|
65
|
+
# Twilio::Verb.new.play('http://foo.com/cowbell.mp3', :loop => 3, :pause => true)
|
66
|
+
#
|
67
|
+
# Options (see http://www.twilio.com/docs/api_reference/TwiML/play) are passed in as a hash,
|
68
|
+
# but only 'loop' is currently supported.
|
69
|
+
def play(*args, &block)
|
70
|
+
options = {:loop => 1}
|
71
|
+
args.each do |arg|
|
72
|
+
case arg
|
73
|
+
when String
|
74
|
+
options[:audio_url] = arg
|
75
|
+
when Hash
|
76
|
+
options.merge!(arg)
|
77
|
+
else
|
78
|
+
raise ArgumentError, 'play expects String or Hash argument'
|
157
79
|
end
|
158
|
-
|
159
|
-
xml = Builder::XmlMarkup.new
|
160
|
-
xml.instruct!
|
161
|
-
xml.Response { xml.Dial(number_to_dial, options) }
|
162
80
|
end
|
163
81
|
|
164
|
-
|
165
|
-
if
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
self.send(verb, args.first, { :loop => Integer(how_many_times), :pause => pause})
|
82
|
+
response {
|
83
|
+
if options[:pause]
|
84
|
+
loop_with_pause(options[:loop], @xml) do
|
85
|
+
@xml.Play(options[:audio_url])
|
86
|
+
end
|
170
87
|
else
|
171
|
-
|
88
|
+
@xml.Play(options[:audio_url], :loop => options[:loop])
|
89
|
+
end
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
# The Gather verb collects digits entered by a caller into their telephone keypad.
|
94
|
+
# When the caller is done entering data, Twilio submits that data to a provided URL,
|
95
|
+
# as either a HTTP GET or POST request, just like a web browser submits data from an HTML form.
|
96
|
+
#
|
97
|
+
# Options (see http://www.twilio.com/docs/api_reference/TwiML/gather) are passed in as a hash
|
98
|
+
#
|
99
|
+
# Examples:
|
100
|
+
# Twilio::Verb.new.gather
|
101
|
+
# Twilio::Verb.new.gather(:action => 'http://foobar.com')
|
102
|
+
# Twilio::Verb.new.gather(:finishOnKey => '*')
|
103
|
+
# Twilio::Verb.new.gather(:action => 'http://foobar.com', :finishOnKey => '*')
|
104
|
+
def gather(*args, &block)
|
105
|
+
options = args.shift
|
106
|
+
response { @xml.Gather(options) }
|
107
|
+
end
|
108
|
+
|
109
|
+
# The Record verb records the caller's voice and returns a URL that links to a file
|
110
|
+
# containing the audio recording.
|
111
|
+
#
|
112
|
+
# Options (see http://www.twilio.com/docs/api_reference/TwiML/record) are passed in as a hash
|
113
|
+
#
|
114
|
+
# Examples:
|
115
|
+
# Twilio::Verb.new.record
|
116
|
+
# Twilio::Verb.new.record(:action => 'http://foobar.com')
|
117
|
+
# Twilio::Verb.new.record(:finishOnKey => '*')
|
118
|
+
# Twilio::Verb.new.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
|
119
|
+
def record(*args, &block)
|
120
|
+
options = args.shift
|
121
|
+
response { @xml.Record(options) }
|
122
|
+
end
|
123
|
+
|
124
|
+
# The Dial verb connects the current caller to an another phone. If the called party picks up,
|
125
|
+
# the two parties are connected and can communicate until one hangs up. If the called party does
|
126
|
+
# not pick up, if a busy signal is received, or the number doesn't exist, the dial verb will finish.
|
127
|
+
#
|
128
|
+
# If an action verb is provided, Twilio will submit the outcome of the call attempt to the action URL.
|
129
|
+
# If no action is provided, Dial will fall through to the next verb in the document.
|
130
|
+
#
|
131
|
+
# Note: this is different than the behavior of Record and Gather. Dial does not submit back to the
|
132
|
+
# current document URL if no action is provided.
|
133
|
+
#
|
134
|
+
# Options (see http://www.twilio.com/docs/api_reference/TwiML/dial) are passed in as a hash
|
135
|
+
#
|
136
|
+
# Examples:
|
137
|
+
# Twilio::Verb.new.dial('415-123-4567')
|
138
|
+
# Twilio::Verb.new.dial('415-123-4567', :action => 'http://foobar.com')
|
139
|
+
# Twilio::Verb.new.dial('415-123-4567', {:timeout => 10, :callerId => '858-987-6543'})
|
140
|
+
def dial(*args, &block)
|
141
|
+
number_to_dial = ''
|
142
|
+
options = {}
|
143
|
+
args.each do |arg|
|
144
|
+
case arg
|
145
|
+
when String
|
146
|
+
number_to_dial = arg
|
147
|
+
when Hash
|
148
|
+
options.merge!(arg)
|
149
|
+
else
|
150
|
+
raise ArgumentError, 'dial expects String or Hash argument'
|
172
151
|
end
|
173
152
|
end
|
174
|
-
|
175
|
-
private
|
176
153
|
|
177
|
-
|
178
|
-
last_iteration = loop_count-1
|
179
|
-
loop_count.times do |i|
|
180
|
-
yield verb_action
|
181
|
-
xml.Pause unless i == last_iteration
|
182
|
-
end
|
183
|
-
end
|
154
|
+
response { @xml.Dial(number_to_dial, options) }
|
184
155
|
end
|
156
|
+
|
157
|
+
private
|
158
|
+
|
159
|
+
def response
|
160
|
+
@xml.Response { yield }
|
161
|
+
end
|
162
|
+
|
163
|
+
def loop_with_pause(loop_count, xml, &verb_action)
|
164
|
+
last_iteration = loop_count-1
|
165
|
+
loop_count.times do |i|
|
166
|
+
yield verb_action
|
167
|
+
xml.Pause unless i == last_iteration
|
168
|
+
end
|
169
|
+
end
|
185
170
|
end
|
186
171
|
end
|
@@ -13,6 +13,12 @@ say_hi_three_times:
|
|
13
13
|
say_hi_three_times_with_pause:
|
14
14
|
response: <?xml version="1.0" encoding="UTF-8"?><Response><Say language="en" voice="man">hi</Say><Pause/><Say language="en" voice="man">hi</Say><Pause/><Say language="en" voice="man">hi</Say></Response>
|
15
15
|
|
16
|
+
say_hi_with_pause:
|
17
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Say loop="1" language="en" voice="man">hi</Say><Pause/></Response>
|
18
|
+
|
19
|
+
say_hi_with_pause_and_say_bye:
|
20
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Say loop="1" language="en" voice="man">hi</Say><Pause/><Say loop="1" language="en" voice="man">bye</Say></Response>
|
21
|
+
|
16
22
|
play_mp3:
|
17
23
|
response: <?xml version="1.0" encoding="UTF-8"?><Response><Play loop="1">http://foo.com/cowbell.mp3</Play></Response>
|
18
24
|
|
@@ -41,7 +47,7 @@ gather_with_num_digits:
|
|
41
47
|
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather numDigits="5"/></Response>
|
42
48
|
|
43
49
|
gather_with_all_options_set:
|
44
|
-
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather finishOnKey="*" method="GET" action="http://foobar.com"
|
50
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather finishOnKey="*" method="GET" action="http://foobar.com" timeout="10" numDigits="5"/></Response>
|
45
51
|
|
46
52
|
record:
|
47
53
|
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record></Record></Response>
|
data/test/twilio/verb_test.rb
CHANGED
@@ -3,123 +3,131 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class VerbTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "A Twilio Verb" do
|
5
5
|
should "say 'hi'" do
|
6
|
-
assert_equal verb_response(:say_hi), Twilio::Verb.say('hi')
|
6
|
+
assert_equal verb_response(:say_hi), Twilio::Verb.new.say('hi')
|
7
7
|
end
|
8
8
|
|
9
9
|
should "say 'hi' with female voice" do
|
10
|
-
assert_equal verb_response(:say_hi_with_female_voice), Twilio::Verb.say('hi', :voice => 'woman')
|
10
|
+
assert_equal verb_response(:say_hi_with_female_voice), Twilio::Verb.new.say('hi', :voice => 'woman')
|
11
11
|
end
|
12
12
|
|
13
13
|
should "say 'hola' in Spanish with female voice" do
|
14
|
-
assert_equal verb_response(:say_hi_in_spanish_with_female_voice), Twilio::Verb.say('hola', {:voice => 'woman', :language => 'es'})
|
14
|
+
assert_equal verb_response(:say_hi_in_spanish_with_female_voice), Twilio::Verb.new.say('hola', {:voice => 'woman', :language => 'es'})
|
15
15
|
end
|
16
16
|
|
17
17
|
should "say 'hi' three times" do
|
18
|
-
assert_equal verb_response(:say_hi_three_times), Twilio::Verb.
|
18
|
+
assert_equal verb_response(:say_hi_three_times), Twilio::Verb.new.say('hi', :loop => 3)
|
19
19
|
end
|
20
20
|
|
21
21
|
should "say 'hi' three times with pause" do
|
22
|
-
assert_equal verb_response(:say_hi_three_times_with_pause), Twilio::Verb.
|
22
|
+
assert_equal verb_response(:say_hi_three_times_with_pause), Twilio::Verb.new.say('hi', :loop => 3, :pause => true)
|
23
23
|
end
|
24
24
|
|
25
|
+
#should "say 'hi' with pause and say 'bye'" do
|
26
|
+
# verb = Twilio::Verb.new { |v|
|
27
|
+
# v.say('TESTING')
|
28
|
+
# puts v.say('BYE')
|
29
|
+
# }
|
30
|
+
# assert_equal verb_response(:say_hi_with_pause_and_say_bye), verb
|
31
|
+
#end
|
32
|
+
|
25
33
|
should "play mp3 response" do
|
26
|
-
assert_equal verb_response(:play_mp3), Twilio::Verb.play('http://foo.com/cowbell.mp3')
|
34
|
+
assert_equal verb_response(:play_mp3), Twilio::Verb.new.play('http://foo.com/cowbell.mp3')
|
27
35
|
end
|
28
36
|
|
29
37
|
should "play mp3 response two times" do
|
30
|
-
assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.
|
38
|
+
assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.new.play('http://foo.com/cowbell.mp3', :loop => 2)
|
31
39
|
end
|
32
40
|
|
33
41
|
should "play mp3 response two times with pause" do
|
34
|
-
assert_equal verb_response(:play_mp3_two_times_with_pause), Twilio::Verb.
|
42
|
+
assert_equal verb_response(:play_mp3_two_times_with_pause), Twilio::Verb.new.play('http://foo.com/cowbell.mp3', :loop => 2, :pause => true)
|
35
43
|
end
|
36
44
|
|
37
45
|
should "gather" do
|
38
|
-
assert_equal verb_response(:gather), Twilio::Verb.gather
|
46
|
+
assert_equal verb_response(:gather), Twilio::Verb.new.gather
|
39
47
|
end
|
40
48
|
|
41
49
|
should "gather with action" do
|
42
|
-
assert_equal verb_response(:gather_with_action), Twilio::Verb.gather(:action => 'http://foobar.com')
|
50
|
+
assert_equal verb_response(:gather_with_action), Twilio::Verb.new.gather(:action => 'http://foobar.com')
|
43
51
|
end
|
44
52
|
|
45
53
|
should "gather with GET method" do
|
46
|
-
assert_equal verb_response(:gather_with_get_method), Twilio::Verb.gather(:method => 'GET')
|
54
|
+
assert_equal verb_response(:gather_with_get_method), Twilio::Verb.new.gather(:method => 'GET')
|
47
55
|
end
|
48
56
|
|
49
57
|
should "gather with timeout" do
|
50
|
-
assert_equal verb_response(:gather_with_timeout), Twilio::Verb.gather(:timeout => 10)
|
58
|
+
assert_equal verb_response(:gather_with_timeout), Twilio::Verb.new.gather(:timeout => 10)
|
51
59
|
end
|
52
60
|
|
53
61
|
should "gather with finish key" do
|
54
|
-
assert_equal verb_response(:gather_with_finish_key), Twilio::Verb.gather(:finishOnKey => '*')
|
62
|
+
assert_equal verb_response(:gather_with_finish_key), Twilio::Verb.new.gather(:finishOnKey => '*')
|
55
63
|
end
|
56
64
|
|
57
65
|
should "gather with num digits" do
|
58
|
-
assert_equal verb_response(:gather_with_num_digits), Twilio::Verb.gather(:numDigits => 5)
|
66
|
+
assert_equal verb_response(:gather_with_num_digits), Twilio::Verb.new.gather(:numDigits => 5)
|
59
67
|
end
|
60
68
|
|
61
69
|
should "gather with all options set" do
|
62
|
-
assert_equal verb_response(:gather_with_all_options_set), Twilio::Verb.gather(:action => 'http://foobar.com', :method => 'GET', :timeout => 10, :finishOnKey => '*', :numDigits => 5)
|
70
|
+
assert_equal verb_response(:gather_with_all_options_set), Twilio::Verb.new.gather(:action => 'http://foobar.com', :method => 'GET', :timeout => 10, :finishOnKey => '*', :numDigits => 5)
|
63
71
|
end
|
64
72
|
|
65
73
|
should "record" do
|
66
|
-
assert_equal verb_response(:record), Twilio::Verb.record
|
74
|
+
assert_equal verb_response(:record), Twilio::Verb.new.record
|
67
75
|
end
|
68
76
|
|
69
77
|
should "record with action" do
|
70
|
-
assert_equal verb_response(:record_with_action), Twilio::Verb.record(:action => 'http://foobar.com')
|
78
|
+
assert_equal verb_response(:record_with_action), Twilio::Verb.new.record(:action => 'http://foobar.com')
|
71
79
|
end
|
72
80
|
|
73
81
|
should "record with GET method" do
|
74
|
-
assert_equal verb_response(:record_with_get_method), Twilio::Verb.record(:method => 'GET')
|
82
|
+
assert_equal verb_response(:record_with_get_method), Twilio::Verb.new.record(:method => 'GET')
|
75
83
|
end
|
76
84
|
|
77
85
|
should "record with timeout" do
|
78
|
-
assert_equal verb_response(:record_with_timeout), Twilio::Verb.record(:timeout => 10)
|
86
|
+
assert_equal verb_response(:record_with_timeout), Twilio::Verb.new.record(:timeout => 10)
|
79
87
|
end
|
80
88
|
|
81
89
|
should "record with finish key" do
|
82
|
-
assert_equal verb_response(:record_with_finish_key), Twilio::Verb.record(:finishOnKey => '*')
|
90
|
+
assert_equal verb_response(:record_with_finish_key), Twilio::Verb.new.record(:finishOnKey => '*')
|
83
91
|
end
|
84
92
|
|
85
93
|
should "record with max length" do
|
86
|
-
assert_equal verb_response(:record_with_max_length), Twilio::Verb.record(:maxLength => 1800)
|
94
|
+
assert_equal verb_response(:record_with_max_length), Twilio::Verb.new.record(:maxLength => 1800)
|
87
95
|
end
|
88
96
|
|
89
97
|
should "record with transcribe" do
|
90
|
-
assert_equal verb_response(:record_with_transcribe), Twilio::Verb.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
|
98
|
+
assert_equal verb_response(:record_with_transcribe), Twilio::Verb.new.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
|
91
99
|
end
|
92
100
|
|
93
101
|
should "dial" do
|
94
|
-
assert_equal verb_response(:dial), Twilio::Verb.dial('415-123-4567')
|
102
|
+
assert_equal verb_response(:dial), Twilio::Verb.new.dial('415-123-4567')
|
95
103
|
end
|
96
104
|
|
97
105
|
should "dial with action" do
|
98
|
-
assert_equal verb_response(:dial_with_action), Twilio::Verb.dial('415-123-4567', :action => 'http://foobar.com')
|
106
|
+
assert_equal verb_response(:dial_with_action), Twilio::Verb.new.dial('415-123-4567', :action => 'http://foobar.com')
|
99
107
|
end
|
100
108
|
|
101
109
|
should "dial with GET method" do
|
102
|
-
assert_equal verb_response(:dial_with_get_method), Twilio::Verb.dial('415-123-4567', :method => 'GET')
|
110
|
+
assert_equal verb_response(:dial_with_get_method), Twilio::Verb.new.dial('415-123-4567', :method => 'GET')
|
103
111
|
end
|
104
112
|
|
105
113
|
should "dial with timeout" do
|
106
|
-
assert_equal verb_response(:dial_with_timeout), Twilio::Verb.dial('415-123-4567', :timeout => 10)
|
114
|
+
assert_equal verb_response(:dial_with_timeout), Twilio::Verb.new.dial('415-123-4567', :timeout => 10)
|
107
115
|
end
|
108
116
|
|
109
117
|
should "dial with hangup on star" do
|
110
|
-
assert_equal verb_response(:dial_with_hangup_on_star), Twilio::Verb.dial('415-123-4567', :hangupOnStar => true)
|
118
|
+
assert_equal verb_response(:dial_with_hangup_on_star), Twilio::Verb.new.dial('415-123-4567', :hangupOnStar => true)
|
111
119
|
end
|
112
120
|
|
113
121
|
should "dial with time limit" do
|
114
|
-
assert_equal verb_response(:dial_with_time_limit), Twilio::Verb.dial('415-123-4567', :timeLimit => 3600)
|
122
|
+
assert_equal verb_response(:dial_with_time_limit), Twilio::Verb.new.dial('415-123-4567', :timeLimit => 3600)
|
115
123
|
end
|
116
124
|
|
117
125
|
should "dial with caller id" do
|
118
|
-
assert_equal verb_response(:dial_with_caller_id), Twilio::Verb.dial('415-123-4567', :callerId => '858-987-6543')
|
126
|
+
assert_equal verb_response(:dial_with_caller_id), Twilio::Verb.new.dial('415-123-4567', :callerId => '858-987-6543')
|
119
127
|
end
|
120
128
|
|
121
129
|
should "dial with timeout and caller id" do
|
122
|
-
assert_equal verb_response(:dial_with_timeout_and_caller_id), Twilio::Verb.dial('415-123-4567', {:timeout => 10, :callerId => '858-987-6543'})
|
130
|
+
assert_equal verb_response(:dial_with_timeout_and_caller_id), Twilio::Verb.new.dial('415-123-4567', {:timeout => 10, :callerId => '858-987-6543'})
|
123
131
|
end
|
124
132
|
end
|
125
133
|
|