twilio 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -1
- data/Rakefile +2 -1
- data/VERSION.yml +1 -1
- data/lib/twilio.rb +1 -0
- data/lib/twilio/sms.rb +21 -0
- data/lib/twilio/verb.rb +72 -46
- data/test/fixtures/xml/sms.xml +14 -0
- data/test/fixtures/xml/sms_messages.xml +29 -0
- data/test/fixtures/xml/sms_new.xml +14 -0
- data/test/twilio/sms_test.rb +23 -0
- data/test/twilio/verb_test.rb +57 -48
- data/twilio.gemspec +10 -3
- metadata +11 -3
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -5,9 +5,10 @@ begin
|
|
5
5
|
Jeweler::Tasks.new do |gem|
|
6
6
|
gem.name = "twilio"
|
7
7
|
gem.summary = %Q{Twilio API Client}
|
8
|
+
gem.description = %Q{Twilio API wrapper}
|
8
9
|
gem.email = "github@webficient.com"
|
9
10
|
gem.homepage = "http://github.com/webficient/twilio"
|
10
|
-
gem.authors = ["Phil Misiowiec", "Alex K Wolfe"]
|
11
|
+
gem.authors = ["Phil Misiowiec", "Jonathan Rudenberg", "Alex K Wolfe", "Kyle Daigle"]
|
11
12
|
gem.add_dependency 'builder', '>= 2.1.2'
|
12
13
|
gem.add_dependency 'httparty', '>= 0.4.3'
|
13
14
|
end
|
data/VERSION.yml
CHANGED
data/lib/twilio.rb
CHANGED
data/lib/twilio/sms.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Twilio
|
2
|
+
# An SMS message resource represents an Inbound or Outbound SMS message. When someone sends a text message from
|
3
|
+
# or to your application, either via the REST API, or during a call via the verb, an SMS message resource is created.
|
4
|
+
class Sms < TwilioObject
|
5
|
+
# Example:
|
6
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
7
|
+
# Twilio::Sms.message(CALLER_ID, user_number, 'This is my simple SMS message')
|
8
|
+
def message(from, to, body)
|
9
|
+
Twilio.post("/SMS/Messages", :body => {:From => from, :To => to, :Body => body})
|
10
|
+
end
|
11
|
+
|
12
|
+
def list(optional = {})
|
13
|
+
Twilio.get("/SMS/Messages", :query => optional)
|
14
|
+
end
|
15
|
+
|
16
|
+
def get(sms_message_sid)
|
17
|
+
Twilio.get("/SMS/Messages/#{sms_message_sid}")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/twilio/verb.rb
CHANGED
@@ -15,28 +15,28 @@ module Twilio
|
|
15
15
|
# }
|
16
16
|
# verb.response
|
17
17
|
class Verb
|
18
|
-
|
18
|
+
|
19
19
|
attr_reader :response
|
20
|
-
|
20
|
+
|
21
21
|
class << self
|
22
22
|
def method_missing(method_id, *args) #:nodoc:
|
23
23
|
v = Verb.new
|
24
24
|
v.send(method_id, *args)
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def initialize(&block)
|
29
29
|
@xml = Builder::XmlMarkup.new
|
30
30
|
@xml.instruct!
|
31
|
-
|
31
|
+
|
32
32
|
if block_given?
|
33
33
|
@chain = true
|
34
34
|
@response = @xml.Response { block.call(self) }
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
38
|
-
# The Say verb converts text to speech that is read back to the caller.
|
39
|
-
# Say is useful for dynamic text that is difficult to prerecord.
|
37
|
+
|
38
|
+
# The Say verb converts text to speech that is read back to the caller.
|
39
|
+
# Say is useful for dynamic text that is difficult to prerecord.
|
40
40
|
#
|
41
41
|
# Examples:
|
42
42
|
# Twilio::Verb.say 'The time is 9:35 PM.'
|
@@ -47,7 +47,7 @@ module Twilio
|
|
47
47
|
#
|
48
48
|
# Twilio::Verb.say 'Your PIN is 1234', :loop => 4
|
49
49
|
# Twilio::Verb.say 'Your PIN is 1 2 3 4', :loop => 4
|
50
|
-
#
|
50
|
+
#
|
51
51
|
# If you need a longer pause between each loop, instead of explicitly calling the Pause
|
52
52
|
# verb within a block, you can set the convenient pause option:
|
53
53
|
#
|
@@ -69,7 +69,7 @@ module Twilio
|
|
69
69
|
raise ArgumentError, 'say expects String or Hash argument'
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
output {
|
74
74
|
if options[:pause]
|
75
75
|
loop_with_pause(options[:loop], @xml) do
|
@@ -80,8 +80,8 @@ module Twilio
|
|
80
80
|
end
|
81
81
|
}
|
82
82
|
end
|
83
|
-
|
84
|
-
# The Play verb plays an audio URL back to the caller.
|
83
|
+
|
84
|
+
# The Play verb plays an audio URL back to the caller.
|
85
85
|
# Examples:
|
86
86
|
# Twilio::Verb.play 'http://foo.com/cowbell.mp3'
|
87
87
|
# Twilio::Verb.play 'http://foo.com/cowbell.mp3', :loop => 3
|
@@ -113,13 +113,13 @@ module Twilio
|
|
113
113
|
end
|
114
114
|
else
|
115
115
|
@xml.Play(options[:audio_url], :loop => options[:loop])
|
116
|
-
end
|
116
|
+
end
|
117
117
|
}
|
118
118
|
end
|
119
|
-
|
120
|
-
# The Gather verb collects digits entered by a caller into their telephone keypad.
|
121
|
-
# When the caller is done entering data, Twilio submits that data to a provided URL,
|
122
|
-
# as either a HTTP GET or POST request, just like a web browser submits data from an HTML form.
|
119
|
+
|
120
|
+
# The Gather verb collects digits entered by a caller into their telephone keypad.
|
121
|
+
# When the caller is done entering data, Twilio submits that data to a provided URL,
|
122
|
+
# as either a HTTP GET or POST request, just like a web browser submits data from an HTML form.
|
123
123
|
#
|
124
124
|
# Options (see http://www.twilio.com/docs/api_reference/TwiML/gather) are passed in as a hash
|
125
125
|
#
|
@@ -140,18 +140,18 @@ module Twilio
|
|
140
140
|
# verb.response # represents the final xml output
|
141
141
|
def gather(*args, &block)
|
142
142
|
options = args.shift || {}
|
143
|
-
output {
|
143
|
+
output {
|
144
144
|
if block_given?
|
145
145
|
@xml.Gather(options) { block.call}
|
146
146
|
else
|
147
|
-
@xml.Gather(options)
|
147
|
+
@xml.Gather(options)
|
148
148
|
end
|
149
149
|
}
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
#play, say, pause
|
153
|
-
|
154
|
-
# The Record verb records the caller's voice and returns a URL that links to a file
|
153
|
+
|
154
|
+
# The Record verb records the caller's voice and returns a URL that links to a file
|
155
155
|
# containing the audio recording.
|
156
156
|
#
|
157
157
|
# Options (see http://www.twilio.com/docs/api_reference/TwiML/record) are passed in as a hash
|
@@ -165,15 +165,15 @@ module Twilio
|
|
165
165
|
options = args.shift
|
166
166
|
output { @xml.Record(options) }
|
167
167
|
end
|
168
|
-
|
169
|
-
# The Dial verb connects the current caller to an another phone. If the called party picks up,
|
170
|
-
# the two parties are connected and can communicate until one hangs up. If the called party does
|
168
|
+
|
169
|
+
# The Dial verb connects the current caller to an another phone. If the called party picks up,
|
170
|
+
# the two parties are connected and can communicate until one hangs up. If the called party does
|
171
171
|
# not pick up, if a busy signal is received, or the number doesn't exist, the dial verb will finish.
|
172
172
|
#
|
173
|
-
# If an action verb is provided, Twilio will submit the outcome of the call attempt to the action URL.
|
173
|
+
# If an action verb is provided, Twilio will submit the outcome of the call attempt to the action URL.
|
174
174
|
# If no action is provided, Dial will fall through to the next verb in the document.
|
175
175
|
#
|
176
|
-
# Note: this is different than the behavior of Record and Gather. Dial does not submit back to the
|
176
|
+
# Note: this is different than the behavior of Record and Gather. Dial does not submit back to the
|
177
177
|
# current document URL if no action is provided.
|
178
178
|
#
|
179
179
|
# Options (see http://www.twilio.com/docs/api_reference/TwiML/dial) are passed in as a hash
|
@@ -206,16 +206,16 @@ module Twilio
|
|
206
206
|
raise ArgumentError, 'dial expects String or Hash argument'
|
207
207
|
end
|
208
208
|
end
|
209
|
-
|
210
|
-
output {
|
209
|
+
|
210
|
+
output {
|
211
211
|
if block_given?
|
212
212
|
@xml.Dial(options) { block.call }
|
213
213
|
else
|
214
|
-
@xml.Dial(number_to_dial, options)
|
214
|
+
@xml.Dial(number_to_dial, options)
|
215
215
|
end
|
216
216
|
}
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
219
|
# The <Dial> verb's <Conference> noun allows you to connect to a conference room.
|
220
220
|
# Much like how the <Number> noun allows you to connect to another phone number,
|
221
221
|
# the <Conference> noun allows you to connect to a named conference room and talk
|
@@ -243,12 +243,12 @@ module Twilio
|
|
243
243
|
raise ArgumentError, 'conference expects String or Hash argument'
|
244
244
|
end
|
245
245
|
end
|
246
|
-
|
246
|
+
|
247
247
|
output { @xml.Conference(conference_name, options)}
|
248
248
|
end
|
249
|
-
|
250
|
-
# The Pause (secondary) verb waits silently for a number of seconds.
|
251
|
-
# It is normally chained with other verbs.
|
249
|
+
|
250
|
+
# The Pause (secondary) verb waits silently for a number of seconds.
|
251
|
+
# It is normally chained with other verbs.
|
252
252
|
#
|
253
253
|
# Options (see http://www.twilio.com/docs/api_reference/TwiML/pause) are passed in as a hash
|
254
254
|
#
|
@@ -263,7 +263,7 @@ module Twilio
|
|
263
263
|
options = args.shift
|
264
264
|
output { @xml.Pause(options) }
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
# The Redirect (secondary) verb transfers control to a different URL.
|
268
268
|
# It is normally chained with other verbs.
|
269
269
|
#
|
@@ -288,12 +288,38 @@ module Twilio
|
|
288
288
|
raise ArgumentError, 'dial expects String or Hash argument'
|
289
289
|
end
|
290
290
|
end
|
291
|
-
|
291
|
+
|
292
292
|
output { @xml.Redirect(redirect_to_url, options) }
|
293
293
|
end
|
294
|
-
|
295
|
-
# The
|
296
|
-
#
|
294
|
+
|
295
|
+
# The <Sms> verb sends a SMS message to a phone number.
|
296
|
+
#
|
297
|
+
# Options (see http://www.twilio.com/docs/api/2008-08-01/twiml/sms/sms) ars passed in as a hash
|
298
|
+
#
|
299
|
+
# Examples:
|
300
|
+
# verb = Twilio::Verb.new { |v|
|
301
|
+
# v.sms 'Meet at South Street'
|
302
|
+
# }
|
303
|
+
#
|
304
|
+
def sms(*args)
|
305
|
+
message = ''
|
306
|
+
options = {}
|
307
|
+
args.each do |arg|
|
308
|
+
case arg
|
309
|
+
when String
|
310
|
+
message = arg
|
311
|
+
when Hash
|
312
|
+
options.merge!(arg)
|
313
|
+
else
|
314
|
+
raise ArgumentError, 'sms expects STring or Hash argument'
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
output { @xml.Sms(message, options) }
|
319
|
+
end
|
320
|
+
|
321
|
+
# The Hangup (secondary) verb ends the call.
|
322
|
+
#
|
297
323
|
# Examples:
|
298
324
|
# If your response is only a hangup:
|
299
325
|
#
|
@@ -309,7 +335,7 @@ module Twilio
|
|
309
335
|
def hangup
|
310
336
|
output { @xml.Hangup }
|
311
337
|
end
|
312
|
-
|
338
|
+
|
313
339
|
# The Number element specifies a phone number. The number element has two optional attributes: sendDigits and url.
|
314
340
|
# Number elements can only be nested in Dial verbs
|
315
341
|
def number(*args)
|
@@ -325,18 +351,18 @@ module Twilio
|
|
325
351
|
raise ArgumentError, 'dial expects String or Hash argument'
|
326
352
|
end
|
327
353
|
end
|
328
|
-
|
354
|
+
|
329
355
|
output { @xml.Number(number_to_dial, options) }
|
330
356
|
end
|
331
|
-
|
357
|
+
|
332
358
|
private
|
333
|
-
|
359
|
+
|
334
360
|
def output
|
335
361
|
@chain ? yield : @xml.Response { yield }
|
336
|
-
end
|
337
|
-
|
362
|
+
end
|
363
|
+
|
338
364
|
def loop_with_pause(loop_count, xml, &verb_action)
|
339
|
-
last_iteration = loop_count-1
|
365
|
+
last_iteration = loop_count-1
|
340
366
|
loop_count.times do |i|
|
341
367
|
yield verb_action
|
342
368
|
xml.Pause unless i == last_iteration
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<SMSMessage>
|
3
|
+
<Sid>SM872fb94e3b358913777cdb313f25b46f</Sid>
|
4
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:08 -0700</DateCreated>
|
5
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:10 -0700</DateUpdated>
|
6
|
+
<DateSent>Sun, 04 Oct 2009 03:48:10 -0700</DateSent>
|
7
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
8
|
+
<To>4158675309</To>
|
9
|
+
<From>6505551212</From>
|
10
|
+
<Body>Hi there Jenny! Why didn't you call me back?</Body>
|
11
|
+
<Status>sent</Status>
|
12
|
+
<Flags>2</Flags>
|
13
|
+
</SMSMessage>
|
14
|
+
</TwilioResponse>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<SMSMessages page="0" numpages="2" pagesize="50" total="69" start="0"
|
3
|
+
end="49">
|
4
|
+
<SMSMessage>
|
5
|
+
<Sid>SM872fb94e3b358913777cdb313f25b46f</Sid>
|
6
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:08 -0700</DateCreated>
|
7
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:10 -0700</DateUpdated>
|
8
|
+
<DateSent>Sun, 04 Oct 2009 03:48:10 -0700</DateSent>
|
9
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
10
|
+
<To>4158675309</To>
|
11
|
+
<From>6505551212</From>
|
12
|
+
<Body>Hi there Jenny! Want to grab dinner?</Body>
|
13
|
+
<Status>sent</Status>
|
14
|
+
<Flags>2</Flags>
|
15
|
+
</SMSMessage>
|
16
|
+
<SMSMessage>
|
17
|
+
<Sid>SM47dfd824add482e1fee25ee3ce216113</Sid>
|
18
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:07 -0700</DateCreated>
|
19
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:07 -0700</DateUpdated>
|
20
|
+
<DateSent>Sun, 04 Oct 2009 03:48:07 -0700</DateSent>
|
21
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
22
|
+
<To>6505551212</To>
|
23
|
+
<From>4158675309</From>
|
24
|
+
<Body>The judge said you can't text me anymore.</Body>
|
25
|
+
<Status>sent</Status>
|
26
|
+
<Flags>1</Flags>
|
27
|
+
</SMSMessage>
|
28
|
+
</SMSMessages>
|
29
|
+
</TwilioResponse>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<SMSMessage>
|
3
|
+
<Sid>SM872fb94e3b358913777cdb313f25b46f</Sid>
|
4
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:08 -0700</DateCreated>
|
5
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:10 -0700</DateUpdated>
|
6
|
+
<DateSent>Sun, 04 Oct 2009 03:48:10 -0700</DateSent>
|
7
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
8
|
+
<To>5558675309</To>
|
9
|
+
<From>4155551212</From>
|
10
|
+
<Body>Hi Jenny! Want to grab dinner?</Body>
|
11
|
+
<Status>sent</Status>
|
12
|
+
<Flags>2</Flags>
|
13
|
+
</SMSMessage>
|
14
|
+
</TwilioResponse>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class SmsTest < Test::Unit::TestCase #:nodoc: all
|
4
|
+
context "A call" do
|
5
|
+
setup do
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
7
|
+
end
|
8
|
+
|
9
|
+
should "be messaged" do
|
10
|
+
assert_equal stub_response(:post, :sms_new, :resource => 'SMS/Messages'),
|
11
|
+
Twilio::Sms.message('4155551212', '5558675309', 'Hi Jenny! Want to grab dinner?')
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable as a list" do
|
15
|
+
assert_equal stub_response(:get, :sms_messages, :resource => 'SMS/Messages'), Twilio::Sms.list
|
16
|
+
end
|
17
|
+
|
18
|
+
should "retrieve an individual sms" do
|
19
|
+
assert_equal stub_response(:get, :sms, :resource => 'SMS/Messages/SM872fb94e3b358913777cdb313f25b46f'),
|
20
|
+
Twilio::Sms.get('SM872fb94e3b358913777cdb313f25b46f')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test/twilio/verb_test.rb
CHANGED
@@ -3,30 +3,30 @@ 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_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say>},
|
6
|
+
assert_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say>},
|
7
7
|
Twilio::Verb.say('hi')
|
8
8
|
end
|
9
9
|
|
10
10
|
should "say 'hi' with female voice" do
|
11
|
-
assert_match %r{<Say( loop="1"| language="en"| voice="woman"){3}>hi</Say>},
|
11
|
+
assert_match %r{<Say( loop="1"| language="en"| voice="woman"){3}>hi</Say>},
|
12
12
|
Twilio::Verb.say('hi', :voice => 'woman')
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
should "say 'hola' in Spanish with female voice" do
|
16
16
|
assert_match %r{<Say( loop="1"| language="es"| voice="woman"){3}>hola</Say>},
|
17
17
|
Twilio::Verb.say('hola', :voice => 'woman', :language => 'es')
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
should "say 'hi' three times" do
|
21
|
-
assert_match %r{<Say( loop="3"| language="en"| voice="man"){3}>hi</Say>},
|
21
|
+
assert_match %r{<Say( loop="3"| language="en"| voice="man"){3}>hi</Say>},
|
22
22
|
Twilio::Verb.say('hi', :loop => 3)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
should "say 'hi' three times with pause" do
|
26
26
|
assert_match %r{<Say( language="en"| voice="man"){2}>hi</Say><Pause/><Say( language="en"| voice="man"){2}>hi</Say><Pause/><Say( language="en"| voice="man"){2}>hi</Say>},
|
27
27
|
Twilio::Verb.say('hi', :loop => 3, :pause => true)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
should "say 'hi' with pause and say 'bye'" do
|
31
31
|
verb = Twilio::Verb.new { |v|
|
32
32
|
v.say 'hi', :loop => 1
|
@@ -35,7 +35,7 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
35
35
|
}
|
36
36
|
assert_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say><Pause></Pause><Say( loop="1"| language="en"| voice="man"){3}>bye</Say>}, verb.response
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
should "say 'hi' with 2 second pause and say 'bye'" do
|
40
40
|
verb = Twilio::Verb.new { |v|
|
41
41
|
v.say 'hi'
|
@@ -44,53 +44,53 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
44
44
|
}
|
45
45
|
assert_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say><Pause length="2"/><Say( loop="1"| language="en"| voice="man"){3}>bye</Say>}, verb.response
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
should "play mp3 response" do
|
49
49
|
assert_equal verb_response(:play_mp3), Twilio::Verb.play('http://foo.com/cowbell.mp3')
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
should "play mp3 response two times" do
|
53
53
|
assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
should "play mp3 response two times with pause" do
|
57
|
-
assert_equal verb_response(:play_mp3_two_times_with_pause),
|
57
|
+
assert_equal verb_response(:play_mp3_two_times_with_pause),
|
58
58
|
Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2, :pause => true)
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
should "gather" do
|
62
62
|
assert_equal verb_response(:gather), Twilio::Verb.gather
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
should "gather with action" do
|
66
66
|
assert_equal verb_response(:gather_with_action), Twilio::Verb.gather(:action => 'http://foobar.com')
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
should "gather with GET method" do
|
70
70
|
assert_equal verb_response(:gather_with_get_method), Twilio::Verb.gather(:method => 'GET')
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
should "gather with timeout" do
|
74
74
|
assert_equal verb_response(:gather_with_timeout), Twilio::Verb.gather(:timeout => 10)
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
should "gather with finish key" do
|
78
78
|
assert_equal verb_response(:gather_with_finish_key), Twilio::Verb.gather(:finishOnKey => '*')
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
should "gather with num digits" do
|
82
82
|
assert_equal verb_response(:gather_with_num_digits), Twilio::Verb.gather(:numDigits => 5)
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
should "gather with all options set" do
|
86
|
-
verb_response = Twilio::Verb.gather :action => 'http://foobar.com',
|
87
|
-
:finishOnKey => '*',
|
88
|
-
:method => 'GET',
|
86
|
+
verb_response = Twilio::Verb.gather :action => 'http://foobar.com',
|
87
|
+
:finishOnKey => '*',
|
88
|
+
:method => 'GET',
|
89
89
|
:numDigits => 5,
|
90
|
-
:timeout => 10
|
90
|
+
:timeout => 10
|
91
91
|
assert_match %r{<Gather( finishOnKey="\*"| action="http://foobar.com"| method="GET"| numDigits="5"| timeout="10"){5}/>}, verb_response
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
should "gather and say instructions" do
|
95
95
|
verb = Twilio::Verb.new { |v|
|
96
96
|
v.gather {
|
@@ -100,7 +100,7 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
100
100
|
}
|
101
101
|
assert_match %r{<Gather><Say( loop="1"| language="en"| voice="man"){3}>Please enter your account number followed by the pound sign</Say></Gather><Say( loop="1"| language="en"| voice="man"){3}>We didn't receive any input. Goodbye!</Say>}, verb.response
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
should "gather with timeout and say instructions" do
|
105
105
|
verb = Twilio::Verb.new { |v|
|
106
106
|
v.gather(:timeout => 10) {
|
@@ -110,69 +110,69 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
110
110
|
}
|
111
111
|
assert_match %r{<Gather timeout="10"><Say( loop="1"| language="en"| voice="man"){3}>Please enter your account number followed by the pound sign</Say></Gather><Say( loop="1"| language="en"| voice="man"){3}>We didn't receive any input. Goodbye!</Say>}, verb.response
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
should "record" do
|
115
115
|
assert_equal verb_response(:record), Twilio::Verb.record
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
should "record with action" do
|
119
119
|
assert_equal verb_response(:record_with_action), Twilio::Verb.record(:action => 'http://foobar.com')
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
should "record with GET method" do
|
123
123
|
assert_equal verb_response(:record_with_get_method), Twilio::Verb.record(:method => 'GET')
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
should "record with timeout" do
|
127
127
|
assert_equal verb_response(:record_with_timeout), Twilio::Verb.record(:timeout => 10)
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
should "record with finish key" do
|
131
131
|
assert_equal verb_response(:record_with_finish_key), Twilio::Verb.record(:finishOnKey => '*')
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
should "record with max length" do
|
135
|
-
assert_equal verb_response(:record_with_max_length), Twilio::Verb.record(:maxLength => 1800)
|
135
|
+
assert_equal verb_response(:record_with_max_length), Twilio::Verb.record(:maxLength => 1800)
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
should "record with transcribe" do
|
139
139
|
assert_match %r{<Record( transcribe="true"| transcribeCallback="/handle_transcribe"){2}/>},
|
140
140
|
Twilio::Verb.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
should "dial" do
|
144
144
|
assert_equal verb_response(:dial), Twilio::Verb.dial('415-123-4567')
|
145
145
|
end
|
146
|
-
|
146
|
+
|
147
147
|
should "dial with action" do
|
148
148
|
assert_equal verb_response(:dial_with_action), Twilio::Verb.dial('415-123-4567', :action => 'http://foobar.com')
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
should "dial with GET method" do
|
152
152
|
assert_equal verb_response(:dial_with_get_method), Twilio::Verb.dial('415-123-4567', :method => 'GET')
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
should "dial with timeout" do
|
156
156
|
assert_equal verb_response(:dial_with_timeout), Twilio::Verb.dial('415-123-4567', :timeout => 10)
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
should "dial with hangup on star" do
|
160
160
|
assert_equal verb_response(:dial_with_hangup_on_star), Twilio::Verb.dial('415-123-4567', :hangupOnStar => true)
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
should "dial with time limit" do
|
164
164
|
assert_equal verb_response(:dial_with_time_limit), Twilio::Verb.dial('415-123-4567', :timeLimit => 3600)
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
should "dial with caller id" do
|
168
168
|
assert_equal verb_response(:dial_with_caller_id), Twilio::Verb.dial('415-123-4567', :callerId => '858-987-6543')
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
should "dial with timeout and caller id" do
|
172
172
|
assert_match %r{<Dial( timeout="10"| callerId="858-987-6543"){2}>415-123-4567</Dial>},
|
173
173
|
Twilio::Verb.dial('415-123-4567', :timeout => 10, :callerId => '858-987-6543')
|
174
174
|
end
|
175
|
-
|
175
|
+
|
176
176
|
should "dial with redirect" do
|
177
177
|
verb = Twilio::Verb.new { |v|
|
178
178
|
v.dial '415-123-4567'
|
@@ -180,7 +180,7 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
180
180
|
}
|
181
181
|
assert_equal verb_response(:dial_with_redirect), verb.response
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
should "dial with number and send digits" do
|
185
185
|
verb = Twilio::Verb.new { |v|
|
186
186
|
v.dial {
|
@@ -189,7 +189,7 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
189
189
|
}
|
190
190
|
assert_equal verb_response(:dial_with_number_and_send_digits), verb.response
|
191
191
|
end
|
192
|
-
|
192
|
+
|
193
193
|
should "dial multiple numbers" do
|
194
194
|
verb = Twilio::Verb.new { |v|
|
195
195
|
v.dial {
|
@@ -200,7 +200,7 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
200
200
|
}
|
201
201
|
assert_equal verb_response(:dial_multiple_numbers), verb.response
|
202
202
|
end
|
203
|
-
|
203
|
+
|
204
204
|
should "dial a conference" do
|
205
205
|
verb = Twilio::Verb.new { |v|
|
206
206
|
v.dial {
|
@@ -209,7 +209,7 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
209
209
|
}
|
210
210
|
assert_equal verb_response(:dial_conference), verb.response
|
211
211
|
end
|
212
|
-
|
212
|
+
|
213
213
|
should "dial a muted conference" do
|
214
214
|
verb = Twilio::Verb.new { |v|
|
215
215
|
v.dial {
|
@@ -218,11 +218,11 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
218
218
|
}
|
219
219
|
assert_equal verb_response(:dial_muted_conference), verb.response
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
should "hangup" do
|
223
223
|
assert_equal verb_response(:hangup), Twilio::Verb.hangup
|
224
224
|
end
|
225
|
-
|
225
|
+
|
226
226
|
should "say hi and hangup" do
|
227
227
|
verb = Twilio::Verb.new { |v|
|
228
228
|
v.say 'hi'
|
@@ -231,5 +231,14 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
|
|
231
231
|
assert_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say><Hangup/>},
|
232
232
|
verb.response
|
233
233
|
end
|
234
|
+
|
235
|
+
should "send a simple SMS message" do
|
236
|
+
verb = Twilio::Verb.new { |v|
|
237
|
+
v.sms 'Join us at the bar', :to => "8005554321", :from => "9006661111", :action => "/smsService", :method => "GET"
|
238
|
+
}
|
239
|
+
|
240
|
+
assert_match %r{<Sms( to="8005554321"| from="9006661111"| action="/smsService"| method="GET"){4}>Join us at the bar</Sms>},
|
241
|
+
verb.response
|
242
|
+
end
|
234
243
|
end
|
235
244
|
end
|
data/twilio.gemspec
CHANGED
@@ -5,11 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{twilio}
|
8
|
-
s.version = "2.
|
8
|
+
s.version = "2.7.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Phil Misiowiec", "Alex K Wolfe"]
|
12
|
-
s.date = %q{2010-02-
|
11
|
+
s.authors = ["Phil Misiowiec", "Jonathan Rudenberg", "Alex K Wolfe", "Kyle Daigle"]
|
12
|
+
s.date = %q{2010-02-12}
|
13
|
+
s.description = %q{Twilio API wrapper}
|
13
14
|
s.email = %q{github@webficient.com}
|
14
15
|
s.extra_rdoc_files = [
|
15
16
|
"LICENSE",
|
@@ -31,6 +32,7 @@ Gem::Specification.new do |s|
|
|
31
32
|
"lib/twilio/notification.rb",
|
32
33
|
"lib/twilio/outgoing_caller_id.rb",
|
33
34
|
"lib/twilio/recording.rb",
|
35
|
+
"lib/twilio/sms.rb",
|
34
36
|
"lib/twilio/toll_free_phone_number.rb",
|
35
37
|
"lib/twilio/twilio_object.rb",
|
36
38
|
"lib/twilio/verb.rb",
|
@@ -54,6 +56,9 @@ Gem::Specification.new do |s|
|
|
54
56
|
"test/fixtures/xml/outgoing_caller_ids.xml",
|
55
57
|
"test/fixtures/xml/recording.xml",
|
56
58
|
"test/fixtures/xml/recordings.xml",
|
59
|
+
"test/fixtures/xml/sms.xml",
|
60
|
+
"test/fixtures/xml/sms_messages.xml",
|
61
|
+
"test/fixtures/xml/sms_new.xml",
|
57
62
|
"test/fixtures/xml/transcription.xml",
|
58
63
|
"test/fixtures/xml/transcriptions.xml",
|
59
64
|
"test/fixtures/yml/verb_responses.yml",
|
@@ -67,6 +72,7 @@ Gem::Specification.new do |s|
|
|
67
72
|
"test/twilio/notification_test.rb",
|
68
73
|
"test/twilio/outgoing_caller_id_test.rb",
|
69
74
|
"test/twilio/recording_test.rb",
|
75
|
+
"test/twilio/sms_test.rb",
|
70
76
|
"test/twilio/toll_free_phone_number_test.rb",
|
71
77
|
"test/twilio/verb_test.rb",
|
72
78
|
"twilio.gemspec"
|
@@ -87,6 +93,7 @@ Gem::Specification.new do |s|
|
|
87
93
|
"test/twilio/notification_test.rb",
|
88
94
|
"test/twilio/outgoing_caller_id_test.rb",
|
89
95
|
"test/twilio/recording_test.rb",
|
96
|
+
"test/twilio/sms_test.rb",
|
90
97
|
"test/twilio/toll_free_phone_number_test.rb",
|
91
98
|
"test/twilio/verb_test.rb"
|
92
99
|
]
|
metadata
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twilio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Misiowiec
|
8
|
+
- Jonathan Rudenberg
|
8
9
|
- Alex K Wolfe
|
10
|
+
- Kyle Daigle
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
14
|
|
13
|
-
date: 2010-02-
|
15
|
+
date: 2010-02-12 00:00:00 -08:00
|
14
16
|
default_executable:
|
15
17
|
dependencies:
|
16
18
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +35,7 @@ dependencies:
|
|
33
35
|
- !ruby/object:Gem::Version
|
34
36
|
version: 0.4.3
|
35
37
|
version:
|
36
|
-
description:
|
38
|
+
description: Twilio API wrapper
|
37
39
|
email: github@webficient.com
|
38
40
|
executables: []
|
39
41
|
|
@@ -58,6 +60,7 @@ files:
|
|
58
60
|
- lib/twilio/notification.rb
|
59
61
|
- lib/twilio/outgoing_caller_id.rb
|
60
62
|
- lib/twilio/recording.rb
|
63
|
+
- lib/twilio/sms.rb
|
61
64
|
- lib/twilio/toll_free_phone_number.rb
|
62
65
|
- lib/twilio/twilio_object.rb
|
63
66
|
- lib/twilio/verb.rb
|
@@ -81,6 +84,9 @@ files:
|
|
81
84
|
- test/fixtures/xml/outgoing_caller_ids.xml
|
82
85
|
- test/fixtures/xml/recording.xml
|
83
86
|
- test/fixtures/xml/recordings.xml
|
87
|
+
- test/fixtures/xml/sms.xml
|
88
|
+
- test/fixtures/xml/sms_messages.xml
|
89
|
+
- test/fixtures/xml/sms_new.xml
|
84
90
|
- test/fixtures/xml/transcription.xml
|
85
91
|
- test/fixtures/xml/transcriptions.xml
|
86
92
|
- test/fixtures/yml/verb_responses.yml
|
@@ -94,6 +100,7 @@ files:
|
|
94
100
|
- test/twilio/notification_test.rb
|
95
101
|
- test/twilio/outgoing_caller_id_test.rb
|
96
102
|
- test/twilio/recording_test.rb
|
103
|
+
- test/twilio/sms_test.rb
|
97
104
|
- test/twilio/toll_free_phone_number_test.rb
|
98
105
|
- test/twilio/verb_test.rb
|
99
106
|
- twilio.gemspec
|
@@ -136,5 +143,6 @@ test_files:
|
|
136
143
|
- test/twilio/notification_test.rb
|
137
144
|
- test/twilio/outgoing_caller_id_test.rb
|
138
145
|
- test/twilio/recording_test.rb
|
146
|
+
- test/twilio/sms_test.rb
|
139
147
|
- test/twilio/toll_free_phone_number_test.rb
|
140
148
|
- test/twilio/verb_test.rb
|