webficient-twilio 2.2.0 → 2.3.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/README.rdoc +5 -8
- data/VERSION.yml +1 -1
- data/lib/twilio/account.rb +2 -2
- data/lib/twilio/call.rb +8 -9
- data/lib/twilio/connection.rb +13 -6
- data/lib/twilio/incoming_phone_number.rb +5 -2
- data/lib/twilio/local_phone_number.rb +6 -3
- data/lib/twilio/notification.rb +6 -3
- data/lib/twilio/outgoing_caller_id.rb +9 -6
- data/lib/twilio/recording.rb +7 -4
- data/lib/twilio/toll_free_phone_number.rb +5 -2
- data/lib/twilio/twilio_object.rb +9 -4
- data/test/fixtures/yml/verb_responses.yml +1 -1
- data/test/twilio/account_test.rb +17 -5
- data/test/twilio/call_test.rb +22 -9
- data/test/twilio/connection_test.rb +11 -0
- data/test/twilio/incoming_phone_number_test.rb +20 -7
- data/test/twilio/local_phone_number_test.rb +17 -5
- data/test/twilio/notification_test.rb +19 -7
- data/test/twilio/outgoing_caller_id_test.rb +19 -10
- data/test/twilio/recording_test.rb +19 -8
- data/test/twilio/toll_free_phone_number_test.rb +17 -5
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -8,17 +8,14 @@ For an overview of the Twilio Gem and a sample use case, check out http://www.we
|
|
8
8
|
|
9
9
|
== Calling the Twilio REST API
|
10
10
|
|
11
|
-
First
|
11
|
+
First set your credentials by calling the connect method:
|
12
12
|
|
13
|
-
|
13
|
+
Twilio.connect('my_twilio_sid', 'my_auth_token')
|
14
14
|
|
15
|
-
Now
|
15
|
+
Now call any of the Twilio classes:
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
recording = Twilio::Recording.new(c)
|
21
|
-
recording.list
|
17
|
+
Twilio::Call.make('1234567890', '9876543210', 'http://mysite.com/connected_call')
|
18
|
+
Twilio::Recording.list
|
22
19
|
|
23
20
|
== Responding to Twilio
|
24
21
|
|
data/VERSION.yml
CHANGED
data/lib/twilio/account.rb
CHANGED
@@ -2,11 +2,11 @@ module Twilio
|
|
2
2
|
# The Account resource represents your Twilio Account.
|
3
3
|
class Account < TwilioObject
|
4
4
|
def get
|
5
|
-
|
5
|
+
Twilio.get('')
|
6
6
|
end
|
7
7
|
|
8
8
|
def update_name(name)
|
9
|
-
|
9
|
+
Twilio.put('', :body => {:FriendlyName => name})
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
data/lib/twilio/call.rb
CHANGED
@@ -4,31 +4,30 @@ module Twilio
|
|
4
4
|
# initiates the call, either via the REST API, or during a call via the Dial Verb.
|
5
5
|
class Call < TwilioObject
|
6
6
|
# Example:
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# response = call.make(CALLER_ID, user_number, 'http://myapp.com/twilio_response_handler')
|
7
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
8
|
+
# Twilio::Call.make(CALLER_ID, user_number, 'http://myapp.com/twilio_response_handler')
|
10
9
|
def make(caller, called, url, optional = {})
|
11
|
-
|
10
|
+
Twilio.post("/Calls", :body => {:Caller => caller, :Called => called, :Url => url}.merge(optional))
|
12
11
|
end
|
13
12
|
|
14
13
|
def list(optional = {})
|
15
|
-
|
14
|
+
Twilio.get("/Calls", :query => optional)
|
16
15
|
end
|
17
16
|
|
18
17
|
def get(call_sid)
|
19
|
-
|
18
|
+
Twilio.get("/Calls/#{call_sid}")
|
20
19
|
end
|
21
20
|
|
22
21
|
def segments(call_sid, call_segment_sid = nil)
|
23
|
-
|
22
|
+
Twilio.get("/Calls/#{call_sid}/Segments#{ '/' + call_segment_sid if call_segment_sid }")
|
24
23
|
end
|
25
24
|
|
26
25
|
def recordings(call_sid)
|
27
|
-
|
26
|
+
Twilio.get("/Calls/#{call_sid}/Recordings")
|
28
27
|
end
|
29
28
|
|
30
29
|
def notifications(call_sid)
|
31
|
-
|
30
|
+
Twilio.get("/Calls/#{call_sid}/Notifications")
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
data/lib/twilio/connection.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
module Twilio
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
2
|
+
include HTTParty
|
3
|
+
TWILIO_URL = "https://api.twilio.com/2008-08-01/Accounts"
|
4
|
+
|
5
|
+
# The connect method caches your Twilio account id and authentication token
|
6
|
+
# Example:
|
7
|
+
# Twilio.connect('AC309475e5fede1b49e100272a8640f438', '3a2630a909aadbf60266234756fb15a0')
|
8
|
+
def self.connect(account_sid, auth_token)
|
9
|
+
self.base_uri "#{TWILIO_URL}/#{account_sid}"
|
10
|
+
self.basic_auth account_sid, auth_token
|
11
|
+
end
|
12
|
+
|
13
|
+
# DEPRECATED - use Twilio.connect
|
8
14
|
class Connection
|
9
15
|
include HTTParty
|
10
16
|
TWILIO_URL = "https://api.twilio.com/2008-08-01/Accounts"
|
@@ -14,4 +20,5 @@ module Twilio
|
|
14
20
|
self.class.basic_auth account_sid, auth_token
|
15
21
|
end
|
16
22
|
end
|
23
|
+
|
17
24
|
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module Twilio
|
2
2
|
# An IncomingPhoneNumber resource represents a phone number given to you by
|
3
3
|
# Twilio to receive incoming phone calls.
|
4
|
+
# Example:
|
5
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
+
# Twilio::IncomingPhoneNumber.list
|
4
7
|
class IncomingPhoneNumber < TwilioObject
|
5
8
|
def list(optional = {})
|
6
|
-
|
9
|
+
Twilio.get("/IncomingPhoneNumbers", :query => optional)
|
7
10
|
end
|
8
11
|
|
9
12
|
def get(incoming_sid)
|
10
|
-
|
13
|
+
Twilio.get("/IncomingPhoneNumbers/#{incoming_sid}")
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Twilio
|
2
2
|
# This sub-resource represents only Local phone numbers, or in other words, not toll-free numbers.
|
3
|
-
# Also allows you to request a new local phone number be added to your account.
|
3
|
+
# Also allows you to request a new local phone number be added to your account.
|
4
|
+
# Example:
|
5
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
+
# Twilio::LocalPhoneNumber.list
|
4
7
|
class LocalPhoneNumber < TwilioObject
|
5
8
|
def create(url, area_code = nil, method = 'POST', friendly_name = nil)
|
6
|
-
|
9
|
+
Twilio.post("/IncomingPhoneNumbers/Local", :body => {
|
7
10
|
:Url => url,
|
8
11
|
:AreaCode => area_code,
|
9
12
|
:Method => method,
|
@@ -12,7 +15,7 @@ module Twilio
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def list
|
15
|
-
|
18
|
+
Twilio.get("/IncomingPhoneNumbers/Local")
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/twilio/notification.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
module Twilio
|
2
2
|
# A Notification represenents a log entry made by Twilio in the course of handling
|
3
3
|
# your calls or using the REST API.
|
4
|
+
# Example:
|
5
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
+
# Twilio::Notification.list
|
4
7
|
class Notification < TwilioObject
|
5
8
|
def list(optional = {})
|
6
|
-
|
9
|
+
Twilio.get('/Notifications', :query => optional)
|
7
10
|
end
|
8
11
|
|
9
12
|
def get(notification_sid)
|
10
|
-
|
13
|
+
Twilio.get("/Notifications/#{notification_sid}")
|
11
14
|
end
|
12
15
|
|
13
16
|
def delete(notification_sid)
|
14
|
-
|
17
|
+
Twilio.delete("/Notifications/#{notification_sid}")
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Twilio
|
2
2
|
# An OutgoingCallerId resource represents an outgoing Caller ID that you have
|
3
|
-
# registered with Twilio for use when making an outgoing call or using the Dial Verb.
|
3
|
+
# registered with Twilio for use when making an outgoing call or using the Dial Verb.
|
4
|
+
# Example:
|
5
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
+
# Twilio::OutgoingCallerId.list
|
4
7
|
class OutgoingCallerId < TwilioObject
|
5
8
|
def create(phone_number, friendly_name = phone_number, call_delay = 0)
|
6
|
-
|
9
|
+
Twilio.post("/OutgoingCallerIds", :body => {
|
7
10
|
:PhoneNumber => phone_number,
|
8
11
|
:FriendlyName => friendly_name,
|
9
12
|
:CallDelay => call_delay
|
@@ -11,19 +14,19 @@ module Twilio
|
|
11
14
|
end
|
12
15
|
|
13
16
|
def list(optional = {})
|
14
|
-
|
17
|
+
Twilio.get("/OutgoingCallerIds", :query => optional)
|
15
18
|
end
|
16
19
|
|
17
20
|
def get(callerid_sid)
|
18
|
-
|
21
|
+
Twilio.get("/OutgoingCallerIds/#{callerid_sid}")
|
19
22
|
end
|
20
23
|
|
21
24
|
def update_name(callerid_sid, name)
|
22
|
-
|
25
|
+
Twilio.put("/OutgoingCallerIds/#{callerid_sid}", :body => {:FriendlyName => name})
|
23
26
|
end
|
24
27
|
|
25
28
|
def delete(callerid_sid)
|
26
|
-
|
29
|
+
Twilio.delete("/OutgoingCallerIds/#{callerid_sid}")
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
data/lib/twilio/recording.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
module Twilio
|
2
2
|
# Recordings are generated when you use the Record Verb. Those recordings are
|
3
3
|
# hosted on Twilio's REST API for you to access.
|
4
|
+
# Example:
|
5
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
+
# Twilio::Recording.list
|
4
7
|
class Recording < TwilioObject
|
5
8
|
def list(optional = {})
|
6
|
-
|
9
|
+
Twilio.get("/Recordings", :query => optional)
|
7
10
|
end
|
8
11
|
|
9
12
|
def get(recording_sid)
|
10
|
-
|
13
|
+
Twilio.get("/Recordings/#{recording_sid}")
|
11
14
|
end
|
12
15
|
|
13
16
|
def delete(recording_sid)
|
14
|
-
|
17
|
+
Twilio.delete("/Recordings/#{recording_sid}")
|
15
18
|
end
|
16
19
|
|
17
20
|
def transcriptions(recording_sid, transcription_sid = nil)
|
18
|
-
|
21
|
+
Twilio.get("/Recordings/#{recording_sid}/Transcriptions#{ '/' + transcription_sid if transcription_sid }")
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Twilio
|
2
2
|
# This sub-resource represents only Toll Free phone numbers, or in other words, not local numbers.
|
3
3
|
# Also allows you to request a new toll free phone number be added to your account.
|
4
|
+
# Example:
|
5
|
+
# Twilio.connect('my_twilio_sid', 'my_auth_token')
|
6
|
+
# Twilio::TollFreePhoneNumber.list
|
4
7
|
class TollFreePhoneNumber < TwilioObject
|
5
8
|
def create(url, area_code = nil, method = 'POST', friendly_name = nil)
|
6
|
-
|
9
|
+
Twilio.post("/IncomingPhoneNumbers/TollFree", :body => {
|
7
10
|
:Url => url,
|
8
11
|
:AreaCode => area_code,
|
9
12
|
:Method => method,
|
@@ -12,7 +15,7 @@ module Twilio
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def list
|
15
|
-
|
18
|
+
Twilio.get("/IncomingPhoneNumbers/TollFree")
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/twilio/twilio_object.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module Twilio
|
2
|
-
class TwilioObject #:nodoc: all
|
3
|
-
include HTTParty
|
4
|
-
|
2
|
+
class TwilioObject #:nodoc: all
|
5
3
|
attr_reader :connection
|
6
4
|
|
7
|
-
def initialize(connection)
|
5
|
+
def initialize(connection = nil)
|
8
6
|
@connection = connection
|
9
7
|
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def method_missing(method_id, *args) #:nodoc:
|
11
|
+
o = self.new
|
12
|
+
o.send(method_id, *args)
|
13
|
+
end
|
14
|
+
end
|
10
15
|
end
|
11
16
|
end
|
@@ -53,7 +53,7 @@ gather_with_num_digits:
|
|
53
53
|
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather numDigits="5"/></Response>
|
54
54
|
|
55
55
|
gather_with_all_options_set:
|
56
|
-
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather action="http://foobar.com"
|
56
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather finishOnKey="*" action="http://foobar.com" method="GET" numDigits="5" timeout="10"/></Response>
|
57
57
|
|
58
58
|
gather_and_say_instructions:
|
59
59
|
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather><Say loop="1" language="en" voice="man">Please enter your account number followed by the pound sign</Say></Gather><Say loop="1" language="en" voice="man">We didn't receive any input. Goodbye!</Say></Response>
|
data/test/twilio/account_test.rb
CHANGED
@@ -3,21 +3,33 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class AccountTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "An account" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@account = Twilio::Account.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable" do
|
11
10
|
fake_response = fixture(:account)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url, :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::Account.get, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be able to update name" do
|
17
16
|
fake_response = fixture(:account_renamed)
|
18
17
|
FakeWeb.register_uri(:put, twilio_url, :string => fake_response)
|
19
|
-
|
20
|
-
assert_equal response, fake_response
|
18
|
+
assert_equal Twilio::Account.update_name('Bubba'), fake_response
|
21
19
|
end
|
20
|
+
|
21
|
+
context "using deprecated API" do
|
22
|
+
setup do
|
23
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
24
|
+
@account = Twilio::Account.new(@connection)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be retrievable" do
|
28
|
+
fake_response = fixture(:account)
|
29
|
+
FakeWeb.register_uri(:get, twilio_url, :string => fake_response)
|
30
|
+
assert_equal @account.get, fake_response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|
data/test/twilio/call_test.rb
CHANGED
@@ -3,26 +3,25 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class CallTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "A call" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@call = Twilio::Call.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable as a list" do
|
11
10
|
fake_response = fixture(:calls)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url('Calls'), :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::Call.list, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be retrievable individually" do
|
17
16
|
fake_response = fixture(:call)
|
18
17
|
FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868'), :string => fake_response)
|
19
|
-
assert_equal
|
18
|
+
assert_equal Twilio::Call.get('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
|
20
19
|
end
|
21
20
|
|
22
21
|
should "be made" do
|
23
22
|
fake_response = fixture(:call_new)
|
24
23
|
FakeWeb.register_uri(:post, twilio_url('Calls'), :string => fake_response)
|
25
|
-
response =
|
24
|
+
response = Twilio::Call.make('4158675309', '4155551212', 'http://test.local/call_handler')
|
26
25
|
assert_equal response, fake_response
|
27
26
|
end
|
28
27
|
|
@@ -30,13 +29,13 @@ class CallTest < Test::Unit::TestCase #:nodoc: all
|
|
30
29
|
should "returns a list of Call resources that were segments created in the same call" do
|
31
30
|
fake_response = fixture(:calls)
|
32
31
|
FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments'), :string => fake_response)
|
33
|
-
assert_equal
|
32
|
+
assert_equal Twilio::Call.segments('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
|
34
33
|
end
|
35
34
|
|
36
35
|
should "returns a single Call resource for the CallSid and CallSegmentSid provided" do
|
37
36
|
fake_response = fixture(:calls)
|
38
37
|
FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments/abc123'), :string => fake_response)
|
39
|
-
assert_equal
|
38
|
+
assert_equal Twilio::Call.segments('CA42ed11f93dc08b952027ffbc406d0868', 'abc123'), fake_response
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
@@ -44,7 +43,7 @@ class CallTest < Test::Unit::TestCase #:nodoc: all
|
|
44
43
|
should "returns a list of recordings that were generated during the call" do
|
45
44
|
fake_response = fixture(:recordings)
|
46
45
|
FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Recordings'), :string => fake_response)
|
47
|
-
assert_equal
|
46
|
+
assert_equal Twilio::Call.recordings('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
@@ -52,8 +51,22 @@ class CallTest < Test::Unit::TestCase #:nodoc: all
|
|
52
51
|
should "description" do
|
53
52
|
fake_response = fixture(:notifications)
|
54
53
|
FakeWeb.register_uri(:get, twilio_url('Calls/CA42ed11f93dc08b952027ffbc406d0868/Notifications'), :string => fake_response)
|
55
|
-
assert_equal
|
54
|
+
assert_equal Twilio::Call.notifications('CA42ed11f93dc08b952027ffbc406d0868'), fake_response
|
56
55
|
end
|
57
56
|
end
|
57
|
+
|
58
|
+
context "using deprecated API" do
|
59
|
+
setup do
|
60
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
61
|
+
@call = Twilio::Call.new(@connection)
|
62
|
+
end
|
63
|
+
|
64
|
+
should "be made" do
|
65
|
+
fake_response = fixture(:call_new)
|
66
|
+
FakeWeb.register_uri(:post, twilio_url('Calls'), :string => fake_response)
|
67
|
+
assert_equal @call.make('4158675309', '4155551212', 'http://test.local/call_handler'), fake_response
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
58
71
|
end
|
59
72
|
end
|
@@ -11,5 +11,16 @@ class ConnectionTest < Test::Unit::TestCase #:nodoc: all
|
|
11
11
|
assert_equal "#{Twilio::Connection::TWILIO_URL}/mysid", @connection.class.base_uri
|
12
12
|
end
|
13
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
|
+
|
14
25
|
end
|
15
26
|
end
|
@@ -3,20 +3,33 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class IncomingPhoneNumberTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "An incoming phone number" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@incoming = Twilio::IncomingPhoneNumber.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
9
|
+
should "be retrievable individually" do
|
10
|
+
fake_response = fixture(:incoming_phone_number)
|
11
|
+
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
|
12
|
+
assert_equal Twilio::IncomingPhoneNumber.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
|
13
|
+
end
|
14
|
+
|
10
15
|
should "be retrievable as a list" do
|
11
16
|
fake_response = fixture(:incoming_phone_numbers)
|
12
17
|
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers'), :string => fake_response)
|
13
|
-
assert_equal
|
18
|
+
assert_equal Twilio::IncomingPhoneNumber.list, fake_response
|
14
19
|
end
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
21
|
+
context "using deprecated API" do
|
22
|
+
setup do
|
23
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
24
|
+
@incoming = Twilio::IncomingPhoneNumber.new(@connection)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be retrievable individually" do
|
28
|
+
fake_response = fixture(:incoming_phone_number)
|
29
|
+
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
|
30
|
+
assert_equal @incoming.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
|
31
|
+
end
|
20
32
|
end
|
33
|
+
|
21
34
|
end
|
22
35
|
end
|
@@ -3,21 +3,33 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class LocalPhoneNumberTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "A local phone number" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@local = Twilio::LocalPhoneNumber.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable as a list" do
|
11
10
|
fake_response = fixture(:incoming_phone_numbers)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/Local'), :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::LocalPhoneNumber.list, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be created" do
|
17
16
|
fake_response = fixture(:incoming_phone_number)
|
18
17
|
FakeWeb.register_uri(:post, twilio_url('IncomingPhoneNumbers/Local'), :string => fake_response)
|
19
|
-
|
20
|
-
assert_equal response, fake_response
|
18
|
+
assert_equal Twilio::LocalPhoneNumber.create('http://test.local/call_handler'), fake_response
|
21
19
|
end
|
20
|
+
|
21
|
+
context "using deprecated API" do
|
22
|
+
setup do
|
23
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
24
|
+
@local = Twilio::LocalPhoneNumber.new(@connection)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be retrievable as a list" do
|
28
|
+
fake_response = fixture(:incoming_phone_numbers)
|
29
|
+
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/Local'), :string => fake_response)
|
30
|
+
assert_equal @local.list, fake_response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|
@@ -3,26 +3,38 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class NotificationTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "A recording" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@notification = Twilio::Notification.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable as a list" do
|
11
10
|
fake_response = fixture(:notifications)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url('Notifications'), :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::Notification.list, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be retrievable individually" do
|
17
16
|
fake_response = fixture(:notification)
|
18
17
|
FakeWeb.register_uri(:get, twilio_url('Notifications/NO1fb7086ceb85caed2265f17d7bf7981c'), :string => fake_response)
|
19
|
-
assert_equal
|
18
|
+
assert_equal Twilio::Notification.get('NO1fb7086ceb85caed2265f17d7bf7981c'), fake_response
|
20
19
|
end
|
21
20
|
|
22
21
|
should "be deleted" do
|
23
22
|
FakeWeb.register_uri(:delete, twilio_url('Notifications/NO1fb7086ceb85caed2265f17d7bf7981c'), :status => [ 204, "HTTPNoContent" ])
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
assert Twilio::Notification.delete('NO1fb7086ceb85caed2265f17d7bf7981c')
|
24
|
+
end
|
25
|
+
|
26
|
+
context "using deprecated API" do
|
27
|
+
setup do
|
28
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
29
|
+
@notification = Twilio::Notification.new(@connection)
|
30
|
+
end
|
31
|
+
|
32
|
+
should "be retrievable as a list" do
|
33
|
+
fake_response = fixture(:notifications)
|
34
|
+
FakeWeb.register_uri(:get, twilio_url('Notifications'), :string => fake_response)
|
35
|
+
assert_equal @notification.list, fake_response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
27
39
|
end
|
28
40
|
end
|
@@ -3,40 +3,49 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class OutgoingCallerIdTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "An outgoing caller id" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@caller_id = Twilio::OutgoingCallerId.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable as a list" do
|
11
10
|
fake_response = fixture(:outgoing_caller_ids)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url('OutgoingCallerIds'), :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::OutgoingCallerId.list, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be retrievable individually" do
|
17
16
|
fake_response = fixture(:outgoing_caller_id)
|
18
17
|
FakeWeb.register_uri(:get, twilio_url('OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
|
19
|
-
assert_equal
|
18
|
+
assert_equal Twilio::OutgoingCallerId.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
|
20
19
|
end
|
21
20
|
|
22
21
|
should "be created" do
|
23
22
|
fake_response = fixture(:outgoing_caller_id_new)
|
24
23
|
FakeWeb.register_uri(:post, twilio_url('OutgoingCallerIds'), :string => fake_response)
|
25
|
-
|
26
|
-
assert_equal response, fake_response
|
24
|
+
assert_equal Twilio::OutgoingCallerId.create('4158675309', 'My Home Phone'), fake_response
|
27
25
|
end
|
28
26
|
|
29
27
|
should "be able to update name" do
|
30
28
|
fake_response = fixture(:outgoing_caller_id)
|
31
29
|
FakeWeb.register_uri(:put, twilio_url('OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
|
32
|
-
|
33
|
-
assert_equal response, fake_response
|
30
|
+
assert_equal Twilio::OutgoingCallerId.update_name('PNe536dfda7c6184afab78d980cb8cdf43', 'My office line'), fake_response
|
34
31
|
end
|
35
32
|
|
36
33
|
should "be deleted" do
|
37
34
|
FakeWeb.register_uri(:delete, twilio_url('OutgoingCallerIds/PNe536dfda7c6184afab78d980cb8cdf43'), :status => [ 204, "HTTPNoContent" ])
|
38
|
-
|
39
|
-
|
35
|
+
assert Twilio::OutgoingCallerId.delete('PNe536dfda7c6184afab78d980cb8cdf43')
|
36
|
+
end
|
37
|
+
|
38
|
+
context "using deprecated API" do
|
39
|
+
setup do
|
40
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
41
|
+
@caller_id = Twilio::OutgoingCallerId.new(@connection)
|
42
|
+
end
|
43
|
+
|
44
|
+
should "be retrievable as a list" do
|
45
|
+
fake_response = fixture(:outgoing_caller_ids)
|
46
|
+
FakeWeb.register_uri(:get, twilio_url('OutgoingCallerIds'), :string => fake_response)
|
47
|
+
assert_equal @caller_id.list, fake_response
|
48
|
+
end
|
40
49
|
end
|
41
50
|
end
|
42
51
|
end
|
@@ -3,39 +3,50 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class RecordingTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "A recording" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@recording = Twilio::Recording.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable as a list" do
|
11
10
|
fake_response = fixture(:recordings)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url('Recordings'), :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::Recording.list, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be retrievable individually" do
|
17
16
|
fake_response = fixture(:recording)
|
18
17
|
FakeWeb.register_uri(:get, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f'), :string => fake_response)
|
19
|
-
assert_equal
|
18
|
+
assert_equal Twilio::Recording.get('RE41331862605f3d662488fdafda2e175f'), fake_response
|
20
19
|
end
|
21
20
|
|
22
21
|
should "be deleted" do
|
23
22
|
FakeWeb.register_uri(:delete, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f'), :status => [ 204, "HTTPNoContent" ])
|
24
|
-
|
25
|
-
assert response
|
23
|
+
assert Twilio::Recording.delete('RE41331862605f3d662488fdafda2e175f')
|
26
24
|
end
|
27
25
|
|
28
26
|
context "with transcriptions" do
|
29
27
|
should "be retrievable as a list" do
|
30
28
|
fake_response = fixture(:transcriptions)
|
31
29
|
FakeWeb.register_uri(:get, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f/Transcriptions'), :string => fake_response)
|
32
|
-
assert_equal
|
30
|
+
assert_equal Twilio::Recording.transcriptions('RE41331862605f3d662488fdafda2e175f'), fake_response
|
33
31
|
end
|
34
32
|
|
35
33
|
should "be retrievable individually" do
|
36
34
|
fake_response = fixture(:transcription)
|
37
35
|
FakeWeb.register_uri(:get, twilio_url('Recordings/RE41331862605f3d662488fdafda2e175f/Transcriptions/TRbdece5b75f2cd8f6ef38e0a10f5c4447'), :string => fake_response)
|
38
|
-
assert_equal
|
36
|
+
assert_equal Twilio::Recording.transcriptions('RE41331862605f3d662488fdafda2e175f', 'TRbdece5b75f2cd8f6ef38e0a10f5c4447'), fake_response
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "using deprecated API" do
|
41
|
+
setup do
|
42
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
43
|
+
@recording = Twilio::Recording.new(@connection)
|
44
|
+
end
|
45
|
+
|
46
|
+
should "be retrievable as a list" do
|
47
|
+
fake_response = fixture(:recordings)
|
48
|
+
FakeWeb.register_uri(:get, twilio_url('Recordings'), :string => fake_response)
|
49
|
+
assert_equal @recording.list, fake_response
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
@@ -3,21 +3,33 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
class TollFreePhoneNumberTest < Test::Unit::TestCase #:nodoc: all
|
4
4
|
context "A toll free phone number" do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
@toll_free = Twilio::TollFreePhoneNumber.new(@connection)
|
6
|
+
Twilio.connect('mysid', 'mytoken')
|
8
7
|
end
|
9
8
|
|
10
9
|
should "be retrievable as a list" do
|
11
10
|
fake_response = fixture(:incoming_phone_numbers)
|
12
11
|
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/TollFree'), :string => fake_response)
|
13
|
-
assert_equal
|
12
|
+
assert_equal Twilio::TollFreePhoneNumber.list, fake_response
|
14
13
|
end
|
15
14
|
|
16
15
|
should "be created" do
|
17
16
|
fake_response = fixture(:incoming_phone_number)
|
18
17
|
FakeWeb.register_uri(:post, twilio_url('IncomingPhoneNumbers/TollFree'), :string => fake_response)
|
19
|
-
|
20
|
-
assert_equal response, fake_response
|
18
|
+
assert_equal Twilio::TollFreePhoneNumber.create('http://test.local/call_handler'), fake_response
|
21
19
|
end
|
20
|
+
|
21
|
+
context "using deprecated API" do
|
22
|
+
setup do
|
23
|
+
@connection = Twilio::Connection.new('mysid', 'mytoken')
|
24
|
+
@toll_free = Twilio::TollFreePhoneNumber.new(@connection)
|
25
|
+
end
|
26
|
+
|
27
|
+
should "be retrievable as a list" do
|
28
|
+
fake_response = fixture(:incoming_phone_numbers)
|
29
|
+
FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/TollFree'), :string => fake_response)
|
30
|
+
assert_equal @toll_free.list, fake_response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|