twilio 2.9.0 → 3.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/.gitignore +4 -1
- data/CHANGELOG.rdoc +27 -0
- data/Gemfile +4 -0
- data/README.rdoc +16 -6
- data/Rakefile +6 -46
- data/lib/twilio.rb +21 -6
- data/lib/twilio/account.rb +1 -1
- data/lib/twilio/available_phone_numbers.rb +56 -0
- data/lib/twilio/call.rb +4 -4
- data/lib/twilio/conference.rb +6 -6
- data/lib/twilio/incoming_phone_number.rb +16 -2
- data/lib/twilio/notification.rb +2 -2
- data/lib/twilio/outgoing_caller_id.rb +5 -4
- data/lib/twilio/recording.rb +2 -2
- data/lib/twilio/sms.rb +2 -2
- data/lib/twilio/twilio_object.rb +8 -5
- data/lib/twilio/version.rb +3 -0
- data/spec/fixtures/xml/account.xml +23 -0
- data/{test → spec}/fixtures/xml/account_renamed.xml +0 -0
- data/spec/fixtures/xml/available_phone_numbers_local.xml +26 -0
- data/spec/fixtures/xml/available_phone_numbers_local_search.xml +15 -0
- data/spec/fixtures/xml/available_phone_numbers_toll_free.xml +14 -0
- data/spec/fixtures/xml/available_phone_numbers_toll_free_search.xml +10 -0
- data/{test → spec}/fixtures/xml/call.xml +0 -0
- data/{test → spec}/fixtures/xml/call_new.xml +0 -0
- data/{test → spec}/fixtures/xml/call_redirected.xml +0 -0
- data/{test → spec}/fixtures/xml/calls.xml +0 -0
- data/{test → spec}/fixtures/xml/conference.xml +1 -1
- data/{test → spec}/fixtures/xml/conference_participant.xml +0 -0
- data/{test → spec}/fixtures/xml/conference_participant_muted.xml +0 -0
- data/{test → spec}/fixtures/xml/conference_participants.xml +0 -0
- data/{test → spec}/fixtures/xml/conferences.xml +0 -0
- data/{test → spec}/fixtures/xml/incoming_phone_number.xml +0 -0
- data/{test → spec}/fixtures/xml/incoming_phone_numbers.xml +0 -0
- data/{test → spec}/fixtures/xml/notification.xml +0 -0
- data/{test → spec}/fixtures/xml/notifications.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_id.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_id_new.xml +0 -0
- data/{test → spec}/fixtures/xml/outgoing_caller_ids.xml +0 -0
- data/{test → spec}/fixtures/xml/recording.xml +0 -0
- data/{test → spec}/fixtures/xml/recordings.xml +0 -0
- data/{test → spec}/fixtures/xml/sms.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_messages.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_new.xml +0 -0
- data/{test → spec}/fixtures/xml/sms_new_with_callback.xml +0 -0
- data/{test → spec}/fixtures/xml/transcription.xml +0 -0
- data/{test → spec}/fixtures/xml/transcriptions.xml +0 -0
- data/{test → spec}/fixtures/yml/verb_responses.yml +0 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/twilio_helpers.rb +52 -0
- data/spec/twilio/account_spec.rb +21 -0
- data/spec/twilio/available_phone_numbers_spec.rb +53 -0
- data/spec/twilio/call_spec.rb +64 -0
- data/spec/twilio/conference_spec.rb +58 -0
- data/spec/twilio/incoming_phone_number_spec.rb +42 -0
- data/spec/twilio/live_connection_spec.rb +21 -0
- data/spec/twilio/notification_spec.rb +29 -0
- data/spec/twilio/outgoing_caller_id_spec.rb +43 -0
- data/spec/twilio/recording_spec.rb +44 -0
- data/spec/twilio/sms_spec.rb +36 -0
- data/spec/twilio/verb_spec.rb +235 -0
- data/twilio.gemspec +23 -111
- metadata +164 -82
- data/VERSION.yml +0 -5
- data/lib/twilio/connection.rb +0 -24
- data/lib/twilio/local_phone_number.rb +0 -26
- data/lib/twilio/toll_free_phone_number.rb +0 -26
- data/test/fixtures/xml/account.xml +0 -11
- data/test/test_helper.rb +0 -33
- data/test/twilio/account_test.rb +0 -28
- data/test/twilio/call_test.rb +0 -66
- data/test/twilio/conference_test.rb +0 -46
- data/test/twilio/connection_test.rb +0 -25
- data/test/twilio/incoming_phone_number_test.rb +0 -31
- data/test/twilio/local_phone_number_test.rb +0 -37
- data/test/twilio/notification_test.rb +0 -35
- data/test/twilio/outgoing_caller_id_test.rb +0 -45
- data/test/twilio/recording_test.rb +0 -47
- data/test/twilio/sms_test.rb +0 -27
- data/test/twilio/toll_free_phone_number_test.rb +0 -38
- data/test/twilio/verb_test.rb +0 -244
data/test/twilio/account_test.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class AccountTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "An account" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable" do
|
10
|
-
assert_equal stub_response(:get, :account), Twilio::Account.get
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be able to update name" do
|
14
|
-
assert_equal stub_response(:put, :account_renamed), Twilio::Account.update_name('Bubba')
|
15
|
-
end
|
16
|
-
|
17
|
-
context "using deprecated API" do
|
18
|
-
setup do
|
19
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
20
|
-
@account = Twilio::Account.new(@connection)
|
21
|
-
end
|
22
|
-
|
23
|
-
should "be retrievable" do
|
24
|
-
assert_equal stub_response(:get, :account), @account.get
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
data/test/twilio/call_test.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class CallTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A call" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :calls, :resource => 'Calls'), Twilio::Call.list
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be retrievable individually" do
|
14
|
-
assert_equal stub_response(:get, :call, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868'),
|
15
|
-
Twilio::Call.get('CA42ed11f93dc08b952027ffbc406d0868')
|
16
|
-
end
|
17
|
-
|
18
|
-
should "be made" do
|
19
|
-
assert_equal stub_response(:post, :call_new, :resource => 'Calls'),
|
20
|
-
Twilio::Call.make('4158675309', '4155551212', 'http://test.local/call_handler')
|
21
|
-
end
|
22
|
-
|
23
|
-
should "be redirected" do
|
24
|
-
assert_equal stub_response(:post, :call_redirected, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868'),
|
25
|
-
Twilio::Call.redirect('CA42ed11f93dc08b952027ffbc406d0868', 'http://www.myapp.com/myhandler.php')
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with segments" do
|
29
|
-
should "returns a list of Call resources that were segments created in the same call" do
|
30
|
-
assert_equal stub_response(:get, :calls, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments'),
|
31
|
-
Twilio::Call.segments('CA42ed11f93dc08b952027ffbc406d0868')
|
32
|
-
end
|
33
|
-
|
34
|
-
should "returns a single Call resource for the CallSid and CallSegmentSid provided" do
|
35
|
-
assert_equal stub_response(:get, :calls, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments/abc123'),
|
36
|
-
Twilio::Call.segments('CA42ed11f93dc08b952027ffbc406d0868', 'abc123')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with recordings" do
|
41
|
-
should "returns a list of recordings that were generated during the call" do
|
42
|
-
assert_equal stub_response(:get, :recordings, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868/Recordings'),
|
43
|
-
Twilio::Call.recordings('CA42ed11f93dc08b952027ffbc406d0868')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context "with notifications" do
|
48
|
-
should "description" do
|
49
|
-
assert_equal stub_response(:get, :notifications, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868/Notifications'),
|
50
|
-
Twilio::Call.notifications('CA42ed11f93dc08b952027ffbc406d0868')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "using deprecated API" do
|
55
|
-
setup do
|
56
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
57
|
-
@call = Twilio::Call.new(@connection)
|
58
|
-
end
|
59
|
-
|
60
|
-
should "be made" do
|
61
|
-
assert_equal stub_response(:post, :call_new, :resource => 'Calls'),
|
62
|
-
@call.make('4158675309', '4155551212', 'http://test.local/call_handler')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ConferenceTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A conference" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :conferences, :resource => 'Conferences'), Twilio::Conference.list
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be retrievable individually" do
|
14
|
-
assert_equal stub_response(:get, :conference, :resource => 'Conferences/CFd0a50bbe038c437e87f6c82db8f37f21'),
|
15
|
-
Twilio::Conference.get('CFd0a50bbe038c437e87f6c82db8f37f21')
|
16
|
-
end
|
17
|
-
|
18
|
-
context "participant" do
|
19
|
-
should "be retrievable as a list" do
|
20
|
-
assert_equal stub_response(:get, :conference_participants, :resource => 'Conferences/CF9f2ead1ae43cdabeab102fa30d938378/Participants'),
|
21
|
-
Twilio::Conference.participants('CF9f2ead1ae43cdabeab102fa30d938378')
|
22
|
-
end
|
23
|
-
|
24
|
-
should "be retrievable individually" do
|
25
|
-
assert_equal stub_response(:get, :conference_participant, :resource => 'Conferences/CF9f2ead1ae43cdabeab102fa30d938378/Participants/CA9ae8e040497c0598481c2031a154919e'),
|
26
|
-
Twilio::Conference.participant('CF9f2ead1ae43cdabeab102fa30d938378', 'CA9ae8e040497c0598481c2031a154919e')
|
27
|
-
end
|
28
|
-
|
29
|
-
should "be muted" do
|
30
|
-
assert_equal stub_response(:post, :conference_participant_muted, :resource => 'Conferences/CF9f2ead1ae43cdabeab102fa30d938378/Participants/CA9ae8e040497c0598481c2031a154919e'),
|
31
|
-
Twilio::Conference.mute_participant('CF9f2ead1ae43cdabeab102fa30d938378', 'CA9ae8e040497c0598481c2031a154919e')
|
32
|
-
end
|
33
|
-
|
34
|
-
should "be unmuted" do
|
35
|
-
assert_equal stub_response(:post, :conference_participant, :resource => 'Conferences/CF9f2ead1ae43cdabeab102fa30d938378/Participants/CA9ae8e040497c0598481c2031a154919e'),
|
36
|
-
Twilio::Conference.unmute_participant('CF9f2ead1ae43cdabeab102fa30d938378', 'CA9ae8e040497c0598481c2031a154919e')
|
37
|
-
end
|
38
|
-
|
39
|
-
should "be kicked" do
|
40
|
-
stub_response(:delete, :conference_participant, :resource => 'Conferences/CF9f2ead1ae43cdabeab102fa30d938378/Participants/CA9ae8e040497c0598481c2031a154919e',
|
41
|
-
:status => [ 204, "HTTPNoContent" ])
|
42
|
-
assert Twilio::Conference.kick_participant('CF9f2ead1ae43cdabeab102fa30d938378', 'CA9ae8e040497c0598481c2031a154919e')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ConnectionTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A Twilio connection" do
|
5
|
-
setup do
|
6
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
context "when initializing" do
|
10
|
-
should "have correct url" do
|
11
|
-
assert_equal "#{Twilio::Connection::TWILIO_URL}/mysid", @connection.class.base_uri
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "when invoked as class method" do
|
16
|
-
setup do
|
17
|
-
Twilio.connect('mysid', 'mytoken')
|
18
|
-
end
|
19
|
-
|
20
|
-
should "have correct url" do
|
21
|
-
assert_equal "#{Twilio::TWILIO_URL}/mysid", Twilio.base_uri
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class IncomingPhoneNumberTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "An incoming phone number" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable individually" do
|
10
|
-
assert_equal stub_response(:get, :incoming_phone_number, :resource => 'IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'),
|
11
|
-
Twilio::IncomingPhoneNumber.get('PNe536dfda7c6184afab78d980cb8cdf43')
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be retrievable as a list" do
|
15
|
-
assert_equal stub_response(:get, :incoming_phone_numbers, :resource => 'IncomingPhoneNumbers'),
|
16
|
-
Twilio::IncomingPhoneNumber.list
|
17
|
-
end
|
18
|
-
|
19
|
-
context "using deprecated API" do
|
20
|
-
setup do
|
21
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
22
|
-
@incoming = Twilio::IncomingPhoneNumber.new(@connection)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "be retrievable individually" do
|
26
|
-
assert_equal stub_response(:get, :incoming_phone_number, :resource => 'IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'),
|
27
|
-
@incoming.get('PNe536dfda7c6184afab78d980cb8cdf43')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class LocalPhoneNumberTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A local phone number" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :incoming_phone_numbers, :resource => 'IncomingPhoneNumbers/Local'),
|
11
|
-
Twilio::LocalPhoneNumber.list
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be created" do
|
15
|
-
assert_equal stub_response(:post, :incoming_phone_number, :resource => 'IncomingPhoneNumbers/Local'),
|
16
|
-
Twilio::LocalPhoneNumber.create('http://test.local/call_handler')
|
17
|
-
end
|
18
|
-
|
19
|
-
should "be deleted" do
|
20
|
-
stub_response(:delete, :incoming_phone_number, { :resource => 'IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43',
|
21
|
-
:status => [ 204, "HTTPNoContent" ] })
|
22
|
-
assert Twilio::LocalPhoneNumber.delete('PNe536dfda7c6184afab78d980cb8cdf43')
|
23
|
-
end
|
24
|
-
|
25
|
-
context "using deprecated API" do
|
26
|
-
setup do
|
27
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
28
|
-
@local = Twilio::LocalPhoneNumber.new(@connection)
|
29
|
-
end
|
30
|
-
|
31
|
-
should "be retrievable as a list" do
|
32
|
-
assert_equal stub_response(:get, :incoming_phone_numbers, :resource => 'IncomingPhoneNumbers/Local'),
|
33
|
-
@local.list
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class NotificationTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A recording" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :notifications, :resource => 'Notifications'), Twilio::Notification.list
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be retrievable individually" do
|
14
|
-
assert_equal stub_response(:get, :notification, :resource => 'Notifications/NO1fb7086ceb85caed2265f17d7bf7981c'),
|
15
|
-
Twilio::Notification.get('NO1fb7086ceb85caed2265f17d7bf7981c')
|
16
|
-
end
|
17
|
-
|
18
|
-
should "be deleted" do
|
19
|
-
stub_response(:delete, :notification, { :resource => 'Notifications/NO1fb7086ceb85caed2265f17d7bf7981c',
|
20
|
-
:status => [ 204, "HTTPNoContent" ] })
|
21
|
-
assert Twilio::Notification.delete('NO1fb7086ceb85caed2265f17d7bf7981c')
|
22
|
-
end
|
23
|
-
|
24
|
-
context "using deprecated API" do
|
25
|
-
setup do
|
26
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
27
|
-
@notification = Twilio::Notification.new(@connection)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "be retrievable as a list" do
|
31
|
-
assert_equal stub_response(:get, :notifications, :resource => 'Notifications'), @notification.list
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class OutgoingCallerIdTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "An outgoing caller id" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :outgoing_caller_ids, :resource => 'OutgoingCallerIds'), Twilio::OutgoingCallerId.list
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be retrievable individually" do
|
14
|
-
assert_equal stub_response(:get, :outgoing_caller_id, :resource => 'OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'),
|
15
|
-
Twilio::OutgoingCallerId.get('PNe536dfda7c6184afab78d980cb8cdf43')
|
16
|
-
end
|
17
|
-
|
18
|
-
should "be created" do
|
19
|
-
assert_equal stub_response(:post, :outgoing_caller_id_new, :resource => 'OutgoingCallerIds'),
|
20
|
-
Twilio::OutgoingCallerId.create('4158675309', 'My Home Phone')
|
21
|
-
end
|
22
|
-
|
23
|
-
should "be able to update name" do
|
24
|
-
assert_equal stub_response(:put, :outgoing_caller_id, :resource => 'OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'),
|
25
|
-
Twilio::OutgoingCallerId.update_name('PNe536dfda7c6184afab78d980cb8cdf43', 'My office line')
|
26
|
-
end
|
27
|
-
|
28
|
-
should "be deleted" do
|
29
|
-
stub_response(:delete, :outgoing_caller_id, :resource => 'OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43',
|
30
|
-
:status => [ 204, "HTTPNoContent" ])
|
31
|
-
assert Twilio::OutgoingCallerId.delete('PNe536dfda7c6184afab78d980cb8cdf43')
|
32
|
-
end
|
33
|
-
|
34
|
-
context "using deprecated API" do
|
35
|
-
setup do
|
36
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
37
|
-
@caller_id = Twilio::OutgoingCallerId.new(@connection)
|
38
|
-
end
|
39
|
-
|
40
|
-
should "be retrievable as a list" do
|
41
|
-
assert_equal stub_response(:get, :outgoing_caller_ids, :resource => 'OutgoingCallerIds'), @caller_id.list
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RecordingTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A recording" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :recordings, :resource => 'Recordings'), Twilio::Recording.list
|
11
|
-
end
|
12
|
-
|
13
|
-
should "be retrievable individually" do
|
14
|
-
assert_equal stub_response(:get, :recording, :resource => 'Recordings/RE41331862605f3d662488fdafda2e175f'),
|
15
|
-
Twilio::Recording.get('RE41331862605f3d662488fdafda2e175f')
|
16
|
-
end
|
17
|
-
|
18
|
-
should "be deleted" do
|
19
|
-
stub_response(:delete, :recording, :resource => 'Recordings/RE41331862605f3d662488fdafda2e175f',
|
20
|
-
:status => [ 204, "HTTPNoContent" ])
|
21
|
-
assert Twilio::Recording.delete('RE41331862605f3d662488fdafda2e175f')
|
22
|
-
end
|
23
|
-
|
24
|
-
context "with transcriptions" do
|
25
|
-
should "be retrievable as a list" do
|
26
|
-
assert_equal stub_response(:get, :transcriptions, :resource => 'Recordings/RE41331862605f3d662488fdafda2e175f/Transcriptions'),
|
27
|
-
Twilio::Recording.transcriptions('RE41331862605f3d662488fdafda2e175f')
|
28
|
-
end
|
29
|
-
|
30
|
-
should "be retrievable individually" do
|
31
|
-
assert_equal stub_response(:get, :transcription, :resource => 'Recordings/RE41331862605f3d662488fdafda2e175f/Transcriptions/TRbdece5b75f2cd8f6ef38e0a10f5c4447'),
|
32
|
-
Twilio::Recording.transcriptions('RE41331862605f3d662488fdafda2e175f', 'TRbdece5b75f2cd8f6ef38e0a10f5c4447')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "using deprecated API" do
|
37
|
-
setup do
|
38
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
39
|
-
@recording = Twilio::Recording.new(@connection)
|
40
|
-
end
|
41
|
-
|
42
|
-
should "be retrievable as a list" do
|
43
|
-
assert_equal stub_response(:get, :recordings, :resource => 'Recordings'), @recording.list
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/test/twilio/sms_test.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require '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
|
-
should "be messaged with a callback URL" do
|
14
|
-
assert_equal stub_response(:post, :sms_new_with_callback, :resource => 'SMS/Messages'),
|
15
|
-
Twilio::Sms.message('4155551212', '5558675309', 'Hi Jenny! Want to grab dinner?', 'http://example.com/callback')
|
16
|
-
end
|
17
|
-
|
18
|
-
should "be retrievable as a list" do
|
19
|
-
assert_equal stub_response(:get, :sms_messages, :resource => 'SMS/Messages'), Twilio::Sms.list
|
20
|
-
end
|
21
|
-
|
22
|
-
should "retrieve an individual sms" do
|
23
|
-
assert_equal stub_response(:get, :sms, :resource => 'SMS/Messages/SM872fb94e3b358913777cdb313f25b46f'),
|
24
|
-
Twilio::Sms.get('SM872fb94e3b358913777cdb313f25b46f')
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class TollFreePhoneNumberTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A toll free phone number" do
|
5
|
-
setup do
|
6
|
-
Twilio.connect('mysid', 'mytoken')
|
7
|
-
end
|
8
|
-
|
9
|
-
should "be retrievable as a list" do
|
10
|
-
assert_equal stub_response(:get, :incoming_phone_numbers, :resource => 'IncomingPhoneNumbers/TollFree'),
|
11
|
-
Twilio::TollFreePhoneNumber.list
|
12
|
-
end
|
13
|
-
|
14
|
-
should "be created" do
|
15
|
-
assert_equal stub_response(:post, :incoming_phone_number, :resource => 'IncomingPhoneNumbers/TollFree'),
|
16
|
-
Twilio::TollFreePhoneNumber.create('http://test.local/call_handler')
|
17
|
-
end
|
18
|
-
|
19
|
-
should "be deleted" do
|
20
|
-
stub_response(:delete, :incoming_phone_number, { :resource => 'IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43',
|
21
|
-
:status => [ 204, "HTTPNoContent" ] })
|
22
|
-
assert Twilio::TollFreePhoneNumber.delete('PNe536dfda7c6184afab78d980cb8cdf43')
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
context "using deprecated API" do
|
27
|
-
setup do
|
28
|
-
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
29
|
-
@toll_free = Twilio::TollFreePhoneNumber.new(@connection)
|
30
|
-
end
|
31
|
-
|
32
|
-
should "be retrievable as a list" do
|
33
|
-
assert_equal stub_response(:get, :incoming_phone_numbers, :resource => 'IncomingPhoneNumbers/TollFree'),
|
34
|
-
@toll_free.list
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/test/twilio/verb_test.rb
DELETED
@@ -1,244 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class VerbTest < Test::Unit::TestCase #:nodoc: all
|
4
|
-
context "A Twilio Verb" do
|
5
|
-
should "say 'hi'" do
|
6
|
-
assert_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say>},
|
7
|
-
Twilio::Verb.say('hi')
|
8
|
-
end
|
9
|
-
|
10
|
-
should "say 'hi' with female voice" do
|
11
|
-
assert_match %r{<Say( loop="1"| language="en"| voice="woman"){3}>hi</Say>},
|
12
|
-
Twilio::Verb.say('hi', :voice => 'woman')
|
13
|
-
end
|
14
|
-
|
15
|
-
should "say 'hola' in Spanish with female voice" do
|
16
|
-
assert_match %r{<Say( loop="1"| language="es"| voice="woman"){3}>hola</Say>},
|
17
|
-
Twilio::Verb.say('hola', :voice => 'woman', :language => 'es')
|
18
|
-
end
|
19
|
-
|
20
|
-
should "say 'hi' three times" do
|
21
|
-
assert_match %r{<Say( loop="3"| language="en"| voice="man"){3}>hi</Say>},
|
22
|
-
Twilio::Verb.say('hi', :loop => 3)
|
23
|
-
end
|
24
|
-
|
25
|
-
should "say 'hi' three times with pause" do
|
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
|
-
Twilio::Verb.say('hi', :loop => 3, :pause => true)
|
28
|
-
end
|
29
|
-
|
30
|
-
should "say 'hi' with pause and say 'bye'" do
|
31
|
-
verb = Twilio::Verb.new { |v|
|
32
|
-
v.say 'hi', :loop => 1
|
33
|
-
v.pause
|
34
|
-
v.say 'bye'
|
35
|
-
}
|
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
|
-
end
|
38
|
-
|
39
|
-
should "say 'hi' with 2 second pause and say 'bye'" do
|
40
|
-
verb = Twilio::Verb.new { |v|
|
41
|
-
v.say 'hi'
|
42
|
-
v.pause :length => 2
|
43
|
-
v.say 'bye'
|
44
|
-
}
|
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
|
-
end
|
47
|
-
|
48
|
-
should "play mp3 response" do
|
49
|
-
assert_equal verb_response(:play_mp3), Twilio::Verb.play('http://foo.com/cowbell.mp3')
|
50
|
-
end
|
51
|
-
|
52
|
-
should "play mp3 response two times" do
|
53
|
-
assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2)
|
54
|
-
end
|
55
|
-
|
56
|
-
should "play mp3 response two times with pause" do
|
57
|
-
assert_equal verb_response(:play_mp3_two_times_with_pause),
|
58
|
-
Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2, :pause => true)
|
59
|
-
end
|
60
|
-
|
61
|
-
should "gather" do
|
62
|
-
assert_equal verb_response(:gather), Twilio::Verb.gather
|
63
|
-
end
|
64
|
-
|
65
|
-
should "gather with action" do
|
66
|
-
assert_equal verb_response(:gather_with_action), Twilio::Verb.gather(:action => 'http://foobar.com')
|
67
|
-
end
|
68
|
-
|
69
|
-
should "gather with GET method" do
|
70
|
-
assert_equal verb_response(:gather_with_get_method), Twilio::Verb.gather(:method => 'GET')
|
71
|
-
end
|
72
|
-
|
73
|
-
should "gather with timeout" do
|
74
|
-
assert_equal verb_response(:gather_with_timeout), Twilio::Verb.gather(:timeout => 10)
|
75
|
-
end
|
76
|
-
|
77
|
-
should "gather with finish key" do
|
78
|
-
assert_equal verb_response(:gather_with_finish_key), Twilio::Verb.gather(:finishOnKey => '*')
|
79
|
-
end
|
80
|
-
|
81
|
-
should "gather with num digits" do
|
82
|
-
assert_equal verb_response(:gather_with_num_digits), Twilio::Verb.gather(:numDigits => 5)
|
83
|
-
end
|
84
|
-
|
85
|
-
should "gather with all options set" do
|
86
|
-
verb_response = Twilio::Verb.gather :action => 'http://foobar.com',
|
87
|
-
:finishOnKey => '*',
|
88
|
-
:method => 'GET',
|
89
|
-
:numDigits => 5,
|
90
|
-
:timeout => 10
|
91
|
-
assert_match %r{<Gather( finishOnKey="\*"| action="http://foobar.com"| method="GET"| numDigits="5"| timeout="10"){5}/>}, verb_response
|
92
|
-
end
|
93
|
-
|
94
|
-
should "gather and say instructions" do
|
95
|
-
verb = Twilio::Verb.new { |v|
|
96
|
-
v.gather {
|
97
|
-
v.say 'Please enter your account number followed by the pound sign'
|
98
|
-
}
|
99
|
-
v.say "We didn't receive any input. Goodbye!"
|
100
|
-
}
|
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
|
-
end
|
103
|
-
|
104
|
-
should "gather with timeout and say instructions" do
|
105
|
-
verb = Twilio::Verb.new { |v|
|
106
|
-
v.gather(:timeout => 10) {
|
107
|
-
v.say 'Please enter your account number followed by the pound sign'
|
108
|
-
}
|
109
|
-
v.say "We didn't receive any input. Goodbye!"
|
110
|
-
}
|
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
|
-
end
|
113
|
-
|
114
|
-
should "record" do
|
115
|
-
assert_equal verb_response(:record), Twilio::Verb.record
|
116
|
-
end
|
117
|
-
|
118
|
-
should "record with action" do
|
119
|
-
assert_equal verb_response(:record_with_action), Twilio::Verb.record(:action => 'http://foobar.com')
|
120
|
-
end
|
121
|
-
|
122
|
-
should "record with GET method" do
|
123
|
-
assert_equal verb_response(:record_with_get_method), Twilio::Verb.record(:method => 'GET')
|
124
|
-
end
|
125
|
-
|
126
|
-
should "record with timeout" do
|
127
|
-
assert_equal verb_response(:record_with_timeout), Twilio::Verb.record(:timeout => 10)
|
128
|
-
end
|
129
|
-
|
130
|
-
should "record with finish key" do
|
131
|
-
assert_equal verb_response(:record_with_finish_key), Twilio::Verb.record(:finishOnKey => '*')
|
132
|
-
end
|
133
|
-
|
134
|
-
should "record with max length" do
|
135
|
-
assert_equal verb_response(:record_with_max_length), Twilio::Verb.record(:maxLength => 1800)
|
136
|
-
end
|
137
|
-
|
138
|
-
should "record with transcribe" do
|
139
|
-
assert_match %r{<Record( transcribe="true"| transcribeCallback="/handle_transcribe"){2}/>},
|
140
|
-
Twilio::Verb.record(:transcribe => true, :transcribeCallback => '/handle_transcribe')
|
141
|
-
end
|
142
|
-
|
143
|
-
should "dial" do
|
144
|
-
assert_equal verb_response(:dial), Twilio::Verb.dial('415-123-4567')
|
145
|
-
end
|
146
|
-
|
147
|
-
should "dial with action" do
|
148
|
-
assert_equal verb_response(:dial_with_action), Twilio::Verb.dial('415-123-4567', :action => 'http://foobar.com')
|
149
|
-
end
|
150
|
-
|
151
|
-
should "dial with GET method" do
|
152
|
-
assert_equal verb_response(:dial_with_get_method), Twilio::Verb.dial('415-123-4567', :method => 'GET')
|
153
|
-
end
|
154
|
-
|
155
|
-
should "dial with timeout" do
|
156
|
-
assert_equal verb_response(:dial_with_timeout), Twilio::Verb.dial('415-123-4567', :timeout => 10)
|
157
|
-
end
|
158
|
-
|
159
|
-
should "dial with hangup on star" do
|
160
|
-
assert_equal verb_response(:dial_with_hangup_on_star), Twilio::Verb.dial('415-123-4567', :hangupOnStar => true)
|
161
|
-
end
|
162
|
-
|
163
|
-
should "dial with time limit" do
|
164
|
-
assert_equal verb_response(:dial_with_time_limit), Twilio::Verb.dial('415-123-4567', :timeLimit => 3600)
|
165
|
-
end
|
166
|
-
|
167
|
-
should "dial with caller id" do
|
168
|
-
assert_equal verb_response(:dial_with_caller_id), Twilio::Verb.dial('415-123-4567', :callerId => '858-987-6543')
|
169
|
-
end
|
170
|
-
|
171
|
-
should "dial with timeout and caller id" do
|
172
|
-
assert_match %r{<Dial( timeout="10"| callerId="858-987-6543"){2}>415-123-4567</Dial>},
|
173
|
-
Twilio::Verb.dial('415-123-4567', :timeout => 10, :callerId => '858-987-6543')
|
174
|
-
end
|
175
|
-
|
176
|
-
should "dial with redirect" do
|
177
|
-
verb = Twilio::Verb.new { |v|
|
178
|
-
v.dial '415-123-4567'
|
179
|
-
v.redirect 'http://www.foo.com/nextInstructions'
|
180
|
-
}
|
181
|
-
assert_equal verb_response(:dial_with_redirect), verb.response
|
182
|
-
end
|
183
|
-
|
184
|
-
should "dial with number and send digits" do
|
185
|
-
verb = Twilio::Verb.new { |v|
|
186
|
-
v.dial {
|
187
|
-
v.number('415-123-4567', :sendDigits => 'wwww1928')
|
188
|
-
}
|
189
|
-
}
|
190
|
-
assert_equal verb_response(:dial_with_number_and_send_digits), verb.response
|
191
|
-
end
|
192
|
-
|
193
|
-
should "dial multiple numbers" do
|
194
|
-
verb = Twilio::Verb.new { |v|
|
195
|
-
v.dial {
|
196
|
-
v.number '415-123-4567'
|
197
|
-
v.number '415-123-4568'
|
198
|
-
v.number '415-123-4569'
|
199
|
-
}
|
200
|
-
}
|
201
|
-
assert_equal verb_response(:dial_multiple_numbers), verb.response
|
202
|
-
end
|
203
|
-
|
204
|
-
should "dial a conference" do
|
205
|
-
verb = Twilio::Verb.new { |v|
|
206
|
-
v.dial {
|
207
|
-
v.conference 'MyRoom'
|
208
|
-
}
|
209
|
-
}
|
210
|
-
assert_equal verb_response(:dial_conference), verb.response
|
211
|
-
end
|
212
|
-
|
213
|
-
should "dial a muted conference" do
|
214
|
-
verb = Twilio::Verb.new { |v|
|
215
|
-
v.dial {
|
216
|
-
v.conference 'MyRoom', :mute => :true
|
217
|
-
}
|
218
|
-
}
|
219
|
-
assert_equal verb_response(:dial_muted_conference), verb.response
|
220
|
-
end
|
221
|
-
|
222
|
-
should "hangup" do
|
223
|
-
assert_equal verb_response(:hangup), Twilio::Verb.hangup
|
224
|
-
end
|
225
|
-
|
226
|
-
should "say hi and hangup" do
|
227
|
-
verb = Twilio::Verb.new { |v|
|
228
|
-
v.say 'hi'
|
229
|
-
v.hangup
|
230
|
-
}
|
231
|
-
assert_match %r{<Say( loop="1"| language="en"| voice="man"){3}>hi</Say><Hangup/>},
|
232
|
-
verb.response
|
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
|
243
|
-
end
|
244
|
-
end
|