twilio 1.4.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.
@@ -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
- @connection = Twilio::Connection.new('mysid', 'mytoken')
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 @incoming.list, fake_response
18
+ assert_equal Twilio::IncomingPhoneNumber.list, fake_response
14
19
  end
15
20
 
16
- should "be retrievable individually" do
17
- fake_response = fixture(:incoming_phone_number)
18
- FakeWeb.register_uri(:get, twilio_url('IncomingPhoneNumbers/PNe536dfda7c6184afab78d980cb8cdf43'), :string => fake_response)
19
- assert_equal @incoming.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
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
- @connection = Twilio::Connection.new('mysid', 'mytoken')
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 @local.list, fake_response
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
- response = @local.create('http://test.local/call_handler')
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
- @connection = Twilio::Connection.new('mysid', 'mytoken')
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 @notification.list, fake_response
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 @notification.get('NO1fb7086ceb85caed2265f17d7bf7981c'), fake_response
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
- response = @notification.delete('NO1fb7086ceb85caed2265f17d7bf7981c')
25
- assert response
26
- end
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
- @connection = Twilio::Connection.new('mysid', 'mytoken')
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 @caller_id.list, fake_response
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 @caller_id.get('PNe536dfda7c6184afab78d980cb8cdf43'), fake_response
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
- response = @caller_id.create('4158675309', 'My Home Phone')
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
- response = @caller_id.update_name('PNe536dfda7c6184afab78d980cb8cdf43', 'My office line')
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
- response = @caller_id.delete('PNe536dfda7c6184afab78d980cb8cdf43')
39
- assert response
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
- @connection = Twilio::Connection.new('mysid', 'mytoken')
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 @recording.list, fake_response
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 @recording.get('RE41331862605f3d662488fdafda2e175f'), fake_response
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
- response = @recording.delete('RE41331862605f3d662488fdafda2e175f')
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 @recording.transcriptions('RE41331862605f3d662488fdafda2e175f'), fake_response
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 @recording.transcriptions('RE41331862605f3d662488fdafda2e175f', 'TRbdece5b75f2cd8f6ef38e0a10f5c4447'), fake_response
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
- @connection = Twilio::Connection.new('mysid', 'mytoken')
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 @toll_free.list, fake_response
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
- response = @toll_free.create('http://test.local/call_handler')
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
@@ -15,11 +15,29 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
15
15
  end
16
16
 
17
17
  should "say 'hi' three times" do
18
- assert_equal verb_response(:say_hi_three_times), Twilio::Verb.say_3_times('hi')
18
+ assert_equal verb_response(:say_hi_three_times), Twilio::Verb.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.say_3_times_with_pause('hi')
22
+ assert_equal verb_response(:say_hi_three_times_with_pause), Twilio::Verb.say('hi', :loop => 3, :pause => true)
23
+ end
24
+
25
+ should "say 'hi' with pause and say 'bye'" do
26
+ verb = Twilio::Verb.new { |v|
27
+ v.say('hi', :loop => 1)
28
+ v.pause
29
+ v.say('bye')
30
+ }
31
+ assert_equal verb_response(:say_hi_with_pause_and_say_bye), verb.response
32
+ end
33
+
34
+ should "say 'hi' with 2 second pause and say 'bye'" do
35
+ verb = Twilio::Verb.new { |v|
36
+ v.say('hi')
37
+ v.pause(:length => 2)
38
+ v.say('bye')
39
+ }
40
+ assert_equal verb_response(:say_hi_with_2_second_pause_and_say_bye), verb.response
23
41
  end
24
42
 
25
43
  should "play mp3 response" do
@@ -27,11 +45,11 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
27
45
  end
28
46
 
29
47
  should "play mp3 response two times" do
30
- assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.play_2_times('http://foo.com/cowbell.mp3')
48
+ assert_equal verb_response(:play_mp3_two_times), Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2)
31
49
  end
32
50
 
33
51
  should "play mp3 response two times with pause" do
34
- assert_equal verb_response(:play_mp3_two_times_with_pause), Twilio::Verb.play_2_times_with_pause('http://foo.com/cowbell.mp3')
52
+ assert_equal verb_response(:play_mp3_two_times_with_pause), Twilio::Verb.play('http://foo.com/cowbell.mp3', :loop => 2, :pause => true)
35
53
  end
36
54
 
37
55
  should "gather" do
@@ -62,6 +80,26 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
62
80
  assert_equal verb_response(:gather_with_all_options_set), Twilio::Verb.gather(:action => 'http://foobar.com', :method => 'GET', :timeout => 10, :finishOnKey => '*', :numDigits => 5)
63
81
  end
64
82
 
83
+ should "gather and say instructions" do
84
+ verb = Twilio::Verb.new { |v|
85
+ v.gather {
86
+ v.say('Please enter your account number followed by the pound sign')
87
+ }
88
+ v.say("We didn't receive any input. Goodbye!")
89
+ }
90
+ assert_equal verb_response(:gather_and_say_instructions), verb.response
91
+ end
92
+
93
+ should "gather with timeout and say instructions" do
94
+ verb = Twilio::Verb.new { |v|
95
+ v.gather(:timeout => 10) {
96
+ v.say('Please enter your account number followed by the pound sign')
97
+ }
98
+ v.say("We didn't receive any input. Goodbye!")
99
+ }
100
+ assert_equal verb_response(:gather_with_timeout_and_say_instructions), verb.response
101
+ end
102
+
65
103
  should "record" do
66
104
  assert_equal verb_response(:record), Twilio::Verb.record
67
105
  end
@@ -121,6 +159,46 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
121
159
  should "dial with timeout and caller id" do
122
160
  assert_equal verb_response(:dial_with_timeout_and_caller_id), Twilio::Verb.dial('415-123-4567', {:timeout => 10, :callerId => '858-987-6543'})
123
161
  end
162
+
163
+ should "dial with redirect" do
164
+ verb = Twilio::Verb.new { |v|
165
+ v.dial('415-123-4567')
166
+ v.redirect('http://www.foo.com/nextInstructions')
167
+ }
168
+ assert_equal verb_response(:dial_with_redirect), verb.response
169
+ end
170
+
171
+ should "dial with number and send digits" do
172
+ verb = Twilio::Verb.new { |v|
173
+ v.dial {
174
+ v.number('415-123-4567', :sendDigits => 'wwww1928')
175
+ }
176
+ }
177
+ assert_equal verb_response(:dial_with_number_and_send_digits), verb.response
178
+ end
179
+
180
+ should "dial multiple numbers" do
181
+ verb = Twilio::Verb.new { |v|
182
+ v.dial {
183
+ v.number('415-123-4567')
184
+ v.number('415-123-4568')
185
+ v.number('415-123-4569')
186
+ }
187
+ }
188
+ assert_equal verb_response(:dial_multiple_numbers), verb.response
189
+ end
190
+
191
+ should "hangup" do
192
+ assert_equal verb_response(:hangup), Twilio::Verb.hangup
193
+ end
194
+
195
+ should "say hi and hangup" do
196
+ verb = Twilio::Verb.new { |v|
197
+ v.say('hi')
198
+ v.hangup
199
+ }
200
+ assert_equal verb_response(:say_hi_and_hangup), verb.response
201
+ end
124
202
  end
125
203
 
126
204
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Misiowiec
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-21 00:00:00 -07:00
12
+ date: 2009-06-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -88,6 +88,8 @@ files:
88
88
  - test/twilio/verb_test.rb
89
89
  has_rdoc: true
90
90
  homepage: http://github.com/webficient/twilio
91
+ licenses: []
92
+
91
93
  post_install_message:
92
94
  rdoc_options:
93
95
  - --charset=UTF-8
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
110
  requirements: []
109
111
 
110
112
  rubyforge_project:
111
- rubygems_version: 1.3.1
113
+ rubygems_version: 1.3.5
112
114
  signing_key:
113
115
  specification_version: 2
114
116
  summary: Twilio API Client