twilio 2.4.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -34,6 +34,16 @@ and you can nest multiple verbs inside a block:
34
34
  }
35
35
  verb.response
36
36
 
37
+ == Installation
38
+
39
+ sudo gem install twilio -s http://gemcutter.org
40
+
41
+ If you need to tweak the source code, clone this repository and do a rake build and rake install.
42
+
37
43
  == Copyright
38
44
 
39
45
  Copyright (c) 2009 Phil Misiowiec, Webficient LLC. See LICENSE for details.
46
+
47
+ == Contributors
48
+
49
+ Jonathan Rudenberg
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 4
3
- :patch: 1
2
+ :minor: 5
3
+ :patch: 0
4
4
  :major: 2
data/lib/twilio.rb CHANGED
@@ -33,4 +33,5 @@ require 'twilio/notification'
33
33
  require 'twilio/outgoing_caller_id'
34
34
  require 'twilio/recording'
35
35
  require 'twilio/toll_free_phone_number'
36
+ require 'twilio/conference'
36
37
  require 'twilio/verb'
data/lib/twilio/call.rb CHANGED
@@ -18,6 +18,10 @@ module Twilio
18
18
  Twilio.get("/Calls/#{call_sid}")
19
19
  end
20
20
 
21
+ def redirect(call_sid, new_url, url_action = 'POST')
22
+ Twilio.post("/Calls/#{call_sid}", :body => {:CurrentUrl => new_url, :CurrentMethod => url_action})
23
+ end
24
+
21
25
  def segments(call_sid, call_segment_sid = nil)
22
26
  Twilio.get("/Calls/#{call_sid}/Segments#{ '/' + call_segment_sid if call_segment_sid }")
23
27
  end
@@ -0,0 +1,35 @@
1
+ module Twilio
2
+ # The Conference REST resource allows you to query and manage the state of conferences.
3
+ # When a caller joins a conference via the Dial verb and Conference noun,
4
+ # a Conference Instance Resource is created to represent the conference room
5
+ # and a Participant Instance Resource is created to represent the caller who joined.
6
+ class Conference < TwilioObject
7
+ def list(optional = {})
8
+ Twilio.get("/Conferences", :query => optional)
9
+ end
10
+
11
+ def get(conference_sid)
12
+ Twilio.get("/Conferences/#{conference_sid}")
13
+ end
14
+
15
+ def participants(conference_sid, optional = {})
16
+ Twilio.get("/Conferences/#{conference_sid}/Participants", :query => optional)
17
+ end
18
+
19
+ def participant(conference_sid, call_sid)
20
+ Twilio.get("/Conferences/#{conference_sid}/Participants/#{call_sid}")
21
+ end
22
+
23
+ def mute_participant(conference_sid, call_sid)
24
+ Twilio.post("/Conferences/#{conference_sid}/Participants/#{call_sid}", :body => {:Muted => true})
25
+ end
26
+
27
+ def unmute_participant(conference_sid, call_sid)
28
+ Twilio.post("/Conferences/#{conference_sid}/Participants/#{call_sid}", :body => {:Muted => false})
29
+ end
30
+
31
+ def kick_participant(conference_sid, call_sid)
32
+ Twilio.delete("/Conferences/#{conference_sid}/Participants/#{call_sid}")
33
+ end
34
+ end
35
+ end
data/lib/twilio/verb.rb CHANGED
@@ -215,6 +215,37 @@ module Twilio
215
215
  end
216
216
  }
217
217
  end
218
+
219
+ # The <Dial> verb's <Conference> noun allows you to connect to a conference room.
220
+ # Much like how the <Number> noun allows you to connect to another phone number,
221
+ # the <Conference> noun allows you to connect to a named conference room and talk
222
+ # with the other callers who have also connected to that room.
223
+ #
224
+ # Options (see http://www.twilio.com/docs/api_reference/TwiML/conference) are passed in as a hash
225
+ #
226
+ # Examples:
227
+ # verb = Twilio::Verb.new {
228
+ # dial {
229
+ # conference 'MyRoom', :muted => true
230
+ # }
231
+ # }
232
+ # verb.response
233
+ def conference(*args)
234
+ conference_name = ''
235
+ options = {}
236
+ args.each do |arg|
237
+ case arg
238
+ when String
239
+ conference_name = arg
240
+ when Hash
241
+ options.merge!(arg)
242
+ else
243
+ raise ArgumentError, 'conference expects String or Hash argument'
244
+ end
245
+ end
246
+
247
+ output { @xml.Conference(conference_name, options)}
248
+ end
218
249
 
219
250
  # The Pause (secondary) verb waits silently for a number of seconds.
220
251
  # It is normally chained with other verbs.
@@ -0,0 +1,15 @@
1
+ <TwilioResponse>
2
+ <Call>
3
+ <Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
4
+ <CallSegmentSid/>
5
+ <AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
6
+ <Called>4155551234</Called>
7
+ <Caller>4158675309</Caller>
8
+ <PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
9
+ <Status>1</Status>
10
+ <StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
11
+ <EndTime/>
12
+ <Price/>
13
+ <Flags>1</Flags>
14
+ </Call>
15
+ </TwilioResponse>
@@ -0,0 +1,10 @@
1
+ <TwilioResponse>
2
+ <Conference>
3
+ <Sid>CFd0a50bbe038c437e87f6c82db8f37f21</Sid>
4
+ <AccountSid>mysid</AccountSid>
5
+ <FriendlyName>1234</FriendlyName>
6
+ <Status>2</Status>
7
+ <DateCreated>Thu, 03 Sep 2009 23:37:53 -0700</DateCreated>
8
+ <DateUpdated>Fri, 04 Sep 2009 00:35:02 -0700</DateUpdated>
9
+ </Conference>
10
+ </TwilioResponse>
@@ -0,0 +1,12 @@
1
+ <TwilioResponse>
2
+ <Participant>
3
+ <ConferenceSid>CF9f2ead1ae43cdabeab102fa30d938378</ConferenceSid>
4
+ <AccountSid>mysid</AccountSid>
5
+ <CallSid>CA9ae8e040497c0598481c2031a154919e</CallSid>
6
+ <Muted>false</Muted>
7
+ <StartConferenceOnEnter>true</StartConferenceOnEnter>
8
+ <EndConferenceOnExit>false</EndConferenceOnExit>
9
+ <DateCreated>Wed, 31 Dec 1969 16:33:29 -0800</DateCreated>
10
+ <DateUpdated>Wed, 31 Dec 1969 16:33:29 -0800</DateUpdated>
11
+ </Participant>
12
+ </TwilioResponse>
@@ -0,0 +1,12 @@
1
+ <TwilioResponse>
2
+ <Participant>
3
+ <ConferenceSid>CF9f2ead1ae43cdabeab102fa30d938378</ConferenceSid>
4
+ <AccountSid>mysid</AccountSid>
5
+ <CallSid>CA9ae8e040497c0598481c2031a154919e</CallSid>
6
+ <Muted>true</Muted>
7
+ <StartConferenceOnEnter>true</StartConferenceOnEnter>
8
+ <EndConferenceOnExit>false</EndConferenceOnExit>
9
+ <DateCreated>Wed, 31 Dec 1969 16:33:29 -0800</DateCreated>
10
+ <DateUpdated>Wed, 31 Dec 1969 16:33:29 -0800</DateUpdated>
11
+ </Participant>
12
+ </TwilioResponse>
@@ -0,0 +1,24 @@
1
+ <TwilioResponse>
2
+ <Participants page="0" numpages="1" pagesize="50" total="2" start="0" end="1">
3
+ <Participant>
4
+ <ConferenceSid>CF9f2ead1ae43cdabeab102fa30d938378</ConferenceSid>
5
+ <AccountSid>mysid</AccountSid>
6
+ <CallSid>CA9ae8e040497c0598481c2031a154919e</CallSid>
7
+ <Muted>false</Muted>
8
+ <StartConferenceOnEnter>true</StartConferenceOnEnter>
9
+ <EndConferenceOnExit>false</EndConferenceOnExit>
10
+ <DateCreated>Wed, 31 Dec 1969 16:33:29 -0800</DateCreated>
11
+ <DateUpdated>Wed, 31 Dec 1969 16:33:29 -0800</DateUpdated>
12
+ </Participant>
13
+ <Participant>
14
+ <ConferenceSid>CF9f2ead1ae43cdabeab102fa30d938378</ConferenceSid>
15
+ <AccountSid>mysid</AccountSid>
16
+ <CallSid>CA3c3c002e06c4cdaa5367e814ade05c76</CallSid>
17
+ <Muted>false</Muted>
18
+ <StartConferenceOnEnter>true</StartConferenceOnEnter>
19
+ <EndConferenceOnExit>false</EndConferenceOnExit>
20
+ <DateCreated>Wed, 31 Dec 1969 16:33:29 -0800</DateCreated>
21
+ <DateUpdated>Wed, 31 Dec 1969 16:33:29 -0800</DateUpdated>
22
+ </Participant>
23
+ </Participants>
24
+ </TwilioResponse>
@@ -0,0 +1,12 @@
1
+ <TwilioResponse>
2
+ <Conferences page="0" numpages="1" pagesize="50" total="1" start="0" end="0">
3
+ <Conference>
4
+ <Sid>CFd0a50bbe038c437e87f6c82db8f37f21</Sid>
5
+ <AccountSid>mysid</AccountSid>
6
+ <FriendlyName>1234</FriendlyName>
7
+ <Status>2</Status>
8
+ <DateCreated>Thu, 03 Sep 2009 23:37:53 -0700</DateCreated>
9
+ <DateUpdated>Fri, 04 Sep 2009 00:35:02 -0700</DateUpdated>
10
+ </Conference>
11
+ </Conferences>
12
+ </TwilioResponse>
@@ -71,7 +71,13 @@ dial_with_number_and_send_digits:
71
71
  response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number sendDigits="wwww1928">415-123-4567</Number></Dial></Response>
72
72
 
73
73
  dial_multiple_numbers:
74
- response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number>415-123-4567</Number><Number>415-123-4568</Number><Number>415-123-4569</Number></Dial></Response>
74
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number>415-123-4567</Number><Number>415-123-4568</Number><Number>415-123-4569</Number></Dial></Response>
75
+
76
+ dial_conference:
77
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference>MyRoom</Conference></Dial></Response>
78
+
79
+ dial_muted_conference:
80
+ response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial><Conference mute="true">MyRoom</Conference></Dial></Response>
75
81
 
76
82
  hangup:
77
83
  response: <?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>
@@ -20,6 +20,11 @@ class CallTest < Test::Unit::TestCase #:nodoc: all
20
20
  Twilio::Call.make('4158675309', '4155551212', 'http://test.local/call_handler')
21
21
  end
22
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
+
23
28
  context "with segments" do
24
29
  should "returns a list of Call resources that were segments created in the same call" do
25
30
  assert_equal stub_response(:get, :calls, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments'),
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/../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
@@ -201,6 +201,24 @@ class VerbTest < Test::Unit::TestCase #:nodoc: all
201
201
  assert_equal verb_response(:dial_multiple_numbers), verb.response
202
202
  end
203
203
 
204
+ should "dial a conference" do
205
+ verb = Twilio::Verb.new {
206
+ dial {
207
+ 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 {
215
+ dial {
216
+ conference 'MyRoom', :mute => :true
217
+ }
218
+ }
219
+ assert_equal verb_response(:dial_muted_conference), verb.response
220
+ end
221
+
204
222
  should "hangup" do
205
223
  assert_equal verb_response(:hangup), Twilio::Verb.hangup
206
224
  end
data/twilio.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{twilio}
8
- s.version = "2.4.1"
8
+ s.version = "2.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Phil Misiowiec"]
12
- s.date = %q{2009-11-03}
12
+ s.date = %q{2009-11-28}
13
13
  s.email = %q{github@webficient.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "lib/twilio.rb",
25
25
  "lib/twilio/account.rb",
26
26
  "lib/twilio/call.rb",
27
+ "lib/twilio/conference.rb",
27
28
  "lib/twilio/connection.rb",
28
29
  "lib/twilio/incoming_phone_number.rb",
29
30
  "lib/twilio/local_phone_number.rb",
@@ -37,7 +38,13 @@ Gem::Specification.new do |s|
37
38
  "test/fixtures/xml/account_renamed.xml",
38
39
  "test/fixtures/xml/call.xml",
39
40
  "test/fixtures/xml/call_new.xml",
41
+ "test/fixtures/xml/call_redirected.xml",
40
42
  "test/fixtures/xml/calls.xml",
43
+ "test/fixtures/xml/conference.xml",
44
+ "test/fixtures/xml/conference_participant.xml",
45
+ "test/fixtures/xml/conference_participant_muted.xml",
46
+ "test/fixtures/xml/conference_participants.xml",
47
+ "test/fixtures/xml/conferences.xml",
41
48
  "test/fixtures/xml/incoming_phone_number.xml",
42
49
  "test/fixtures/xml/incoming_phone_numbers.xml",
43
50
  "test/fixtures/xml/notification.xml",
@@ -53,6 +60,7 @@ Gem::Specification.new do |s|
53
60
  "test/test_helper.rb",
54
61
  "test/twilio/account_test.rb",
55
62
  "test/twilio/call_test.rb",
63
+ "test/twilio/conference_test.rb",
56
64
  "test/twilio/connection_test.rb",
57
65
  "test/twilio/incoming_phone_number_test.rb",
58
66
  "test/twilio/local_phone_number_test.rb",
@@ -72,6 +80,7 @@ Gem::Specification.new do |s|
72
80
  "test/test_helper.rb",
73
81
  "test/twilio/account_test.rb",
74
82
  "test/twilio/call_test.rb",
83
+ "test/twilio/conference_test.rb",
75
84
  "test/twilio/connection_test.rb",
76
85
  "test/twilio/incoming_phone_number_test.rb",
77
86
  "test/twilio/local_phone_number_test.rb",
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: 2.4.1
4
+ version: 2.5.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-11-03 00:00:00 -08:00
12
+ date: 2009-11-28 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,7 @@ files:
50
50
  - lib/twilio.rb
51
51
  - lib/twilio/account.rb
52
52
  - lib/twilio/call.rb
53
+ - lib/twilio/conference.rb
53
54
  - lib/twilio/connection.rb
54
55
  - lib/twilio/incoming_phone_number.rb
55
56
  - lib/twilio/local_phone_number.rb
@@ -63,7 +64,13 @@ files:
63
64
  - test/fixtures/xml/account_renamed.xml
64
65
  - test/fixtures/xml/call.xml
65
66
  - test/fixtures/xml/call_new.xml
67
+ - test/fixtures/xml/call_redirected.xml
66
68
  - test/fixtures/xml/calls.xml
69
+ - test/fixtures/xml/conference.xml
70
+ - test/fixtures/xml/conference_participant.xml
71
+ - test/fixtures/xml/conference_participant_muted.xml
72
+ - test/fixtures/xml/conference_participants.xml
73
+ - test/fixtures/xml/conferences.xml
67
74
  - test/fixtures/xml/incoming_phone_number.xml
68
75
  - test/fixtures/xml/incoming_phone_numbers.xml
69
76
  - test/fixtures/xml/notification.xml
@@ -79,6 +86,7 @@ files:
79
86
  - test/test_helper.rb
80
87
  - test/twilio/account_test.rb
81
88
  - test/twilio/call_test.rb
89
+ - test/twilio/conference_test.rb
82
90
  - test/twilio/connection_test.rb
83
91
  - test/twilio/incoming_phone_number_test.rb
84
92
  - test/twilio/local_phone_number_test.rb
@@ -120,6 +128,7 @@ test_files:
120
128
  - test/test_helper.rb
121
129
  - test/twilio/account_test.rb
122
130
  - test/twilio/call_test.rb
131
+ - test/twilio/conference_test.rb
123
132
  - test/twilio/connection_test.rb
124
133
  - test/twilio/incoming_phone_number_test.rb
125
134
  - test/twilio/local_phone_number_test.rb