slayer-twilio 3.0.1
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 +8 -0
- data/CHANGELOG.rdoc +31 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +9 -0
- data/lib/twilio.rb +53 -0
- data/lib/twilio/account.rb +12 -0
- data/lib/twilio/available_phone_numbers.rb +56 -0
- data/lib/twilio/call.rb +37 -0
- data/lib/twilio/conference.rb +35 -0
- data/lib/twilio/incoming_phone_number.rb +30 -0
- data/lib/twilio/notification.rb +20 -0
- data/lib/twilio/outgoing_caller_id.rb +33 -0
- data/lib/twilio/recording.rb +24 -0
- data/lib/twilio/sms.rb +22 -0
- data/lib/twilio/twilio_object.rb +19 -0
- data/lib/twilio/verb.rb +387 -0
- data/lib/twilio/version.rb +3 -0
- data/spec/fixtures/xml/account.xml +23 -0
- data/spec/fixtures/xml/account_renamed.xml +11 -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/spec/fixtures/xml/call.xml +18 -0
- data/spec/fixtures/xml/call_new.xml +14 -0
- data/spec/fixtures/xml/call_redirected.xml +15 -0
- data/spec/fixtures/xml/calls.xml +36 -0
- data/spec/fixtures/xml/conference.xml +10 -0
- data/spec/fixtures/xml/conference_participant.xml +12 -0
- data/spec/fixtures/xml/conference_participant_muted.xml +12 -0
- data/spec/fixtures/xml/conference_participants.xml +24 -0
- data/spec/fixtures/xml/conferences.xml +12 -0
- data/spec/fixtures/xml/incoming_phone_number.xml +12 -0
- data/spec/fixtures/xml/incoming_phone_numbers.xml +24 -0
- data/spec/fixtures/xml/notification.xml +19 -0
- data/spec/fixtures/xml/notifications.xml +32 -0
- data/spec/fixtures/xml/outgoing_caller_id.xml +10 -0
- data/spec/fixtures/xml/outgoing_caller_id_new.xml +7 -0
- data/spec/fixtures/xml/outgoing_caller_ids.xml +20 -0
- data/spec/fixtures/xml/recording.xml +10 -0
- data/spec/fixtures/xml/recordings.xml +20 -0
- data/spec/fixtures/xml/sms.xml +14 -0
- data/spec/fixtures/xml/sms_messages.xml +29 -0
- data/spec/fixtures/xml/sms_new.xml +14 -0
- data/spec/fixtures/xml/sms_new_with_callback.xml +15 -0
- data/spec/fixtures/xml/transcription.xml +13 -0
- data/spec/fixtures/xml/transcriptions.xml +26 -0
- data/spec/fixtures/yml/verb_responses.yml +86 -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 +253 -0
- data/twilio.gemspec +30 -0
- metadata +258 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<SMSMessages page="0" numpages="2" pagesize="50" total="69" start="0"
|
3
|
+
end="49">
|
4
|
+
<SMSMessage>
|
5
|
+
<Sid>SM872fb94e3b358913777cdb313f25b46f</Sid>
|
6
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:08 -0700</DateCreated>
|
7
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:10 -0700</DateUpdated>
|
8
|
+
<DateSent>Sun, 04 Oct 2009 03:48:10 -0700</DateSent>
|
9
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
10
|
+
<To>4158675309</To>
|
11
|
+
<From>6505551212</From>
|
12
|
+
<Body>Hi there Jenny! Want to grab dinner?</Body>
|
13
|
+
<Status>sent</Status>
|
14
|
+
<Flags>2</Flags>
|
15
|
+
</SMSMessage>
|
16
|
+
<SMSMessage>
|
17
|
+
<Sid>SM47dfd824add482e1fee25ee3ce216113</Sid>
|
18
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:07 -0700</DateCreated>
|
19
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:07 -0700</DateUpdated>
|
20
|
+
<DateSent>Sun, 04 Oct 2009 03:48:07 -0700</DateSent>
|
21
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
22
|
+
<To>6505551212</To>
|
23
|
+
<From>4158675309</From>
|
24
|
+
<Body>The judge said you can't text me anymore.</Body>
|
25
|
+
<Status>sent</Status>
|
26
|
+
<Flags>1</Flags>
|
27
|
+
</SMSMessage>
|
28
|
+
</SMSMessages>
|
29
|
+
</TwilioResponse>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<SMSMessage>
|
3
|
+
<Sid>SM872fb94e3b358913777cdb313f25b46f</Sid>
|
4
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:08 -0700</DateCreated>
|
5
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:10 -0700</DateUpdated>
|
6
|
+
<DateSent>Sun, 04 Oct 2009 03:48:10 -0700</DateSent>
|
7
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
8
|
+
<To>5558675309</To>
|
9
|
+
<From>4155551212</From>
|
10
|
+
<Body>Hi Jenny! Want to grab dinner?</Body>
|
11
|
+
<Status>sent</Status>
|
12
|
+
<Flags>2</Flags>
|
13
|
+
</SMSMessage>
|
14
|
+
</TwilioResponse>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<SMSMessage>
|
3
|
+
<Sid>SM872fb94e3b358913777cdb313f25b46f</Sid>
|
4
|
+
<DateCreated>Sun, 04 Oct 2009 03:48:08 -0700</DateCreated>
|
5
|
+
<DateUpdated>Sun, 04 Oct 2009 03:48:10 -0700</DateUpdated>
|
6
|
+
<DateSent>Sun, 04 Oct 2009 03:48:10 -0700</DateSent>
|
7
|
+
<AccountSid>AC5ea872f6da5a21de157d80997a64bd33</AccountSid>
|
8
|
+
<To>5558675309</To>
|
9
|
+
<From>4155551212</From>
|
10
|
+
<Body>Hi Jenny! Want to grab dinner?</Body>
|
11
|
+
<StatusCallback>http://example.com/callback</StatusCallback>
|
12
|
+
<Status>sent</Status>
|
13
|
+
<Flags>2</Flags>
|
14
|
+
</SMSMessage>
|
15
|
+
</TwilioResponse>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<Transcription>
|
3
|
+
<Sid>TRbdece5b75f2cd8f6ef38e0a10f5c4447</Sid>
|
4
|
+
<DateCreated>1235986685</DateCreated>
|
5
|
+
<DateUpdated>1235957924</DateUpdated>
|
6
|
+
<AccountSid>mysid</AccountSid>
|
7
|
+
<Status>completed</Status>
|
8
|
+
<RecordingSid>RE3870404da563592ef6a72136438a879c</RecordingSid>
|
9
|
+
<Duration>9</Duration>
|
10
|
+
<TranscriptionText>This is the body a transcribed recording</TranscriptionText>
|
11
|
+
<Price>-0.03000</Price>
|
12
|
+
</Transcription>
|
13
|
+
</TwilioResponse>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<TwilioResponse>
|
2
|
+
<Transcriptions page="0" numpages="1" pagesize="50" total="2" start="0" end="1">
|
3
|
+
<Transcription>
|
4
|
+
<Sid>TR685e9a2bdf89b978491b1afada63f078</Sid>
|
5
|
+
<DateCreated>1235986685</DateCreated>
|
6
|
+
<DateUpdated>1235957975</DateUpdated>
|
7
|
+
<AccountSid>mysid</AccountSid>
|
8
|
+
<Status>completed</Status>
|
9
|
+
<RecordingSid>RE3870404da563592ef6a72136438a879c</RecordingSid>
|
10
|
+
<Duration>9</Duration>
|
11
|
+
<TranscriptionText>This is the body of one transcribed recording</TranscriptionText>
|
12
|
+
<Price>-0.25000</Price>
|
13
|
+
</Transcription>
|
14
|
+
<Transcription>
|
15
|
+
<Sid>TRbdece5b75f2cd8f6ef38e0a10f5c4447</Sid>
|
16
|
+
<DateCreated>1235986685</DateCreated>
|
17
|
+
<DateUpdated>1235957924</DateUpdated>
|
18
|
+
<AccountSid>mysid</AccountSid>
|
19
|
+
<Status>completed</Status>
|
20
|
+
<RecordingSid>RE3870404da563592ef6a72136438a879c</RecordingSid>
|
21
|
+
<Duration>9</Duration>
|
22
|
+
<TranscriptionText>This is the body of another transcribed recording</TranscriptionText>
|
23
|
+
<Price>-0.03000</Price>
|
24
|
+
</Transcription>
|
25
|
+
</Transcriptions>
|
26
|
+
</TwilioResponse>
|
@@ -0,0 +1,86 @@
|
|
1
|
+
play_mp3:
|
2
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Play loop="1">http://foo.com/cowbell.mp3</Play></Response>
|
3
|
+
|
4
|
+
play_mp3_two_times:
|
5
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Play loop="2">http://foo.com/cowbell.mp3</Play></Response>
|
6
|
+
|
7
|
+
play_mp3_two_times_with_pause:
|
8
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Play>http://foo.com/cowbell.mp3</Play><Pause/><Play>http://foo.com/cowbell.mp3</Play></Response>
|
9
|
+
|
10
|
+
gather:
|
11
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather/></Response>
|
12
|
+
|
13
|
+
gather_with_action:
|
14
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather action="http://foobar.com"/></Response>
|
15
|
+
|
16
|
+
gather_with_get_method:
|
17
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather method="GET"/></Response>
|
18
|
+
|
19
|
+
gather_with_timeout:
|
20
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather timeout="10"/></Response>
|
21
|
+
|
22
|
+
gather_with_finish_key:
|
23
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather finishOnKey="*"/></Response>
|
24
|
+
|
25
|
+
gather_with_num_digits:
|
26
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Gather numDigits="5"/></Response>
|
27
|
+
|
28
|
+
record:
|
29
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record></Record></Response>
|
30
|
+
|
31
|
+
record_with_action:
|
32
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record action="http://foobar.com"/></Response>
|
33
|
+
|
34
|
+
record_with_get_method:
|
35
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record method="GET"/></Response>
|
36
|
+
|
37
|
+
record_with_timeout:
|
38
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record timeout="10"/></Response>
|
39
|
+
|
40
|
+
record_with_finish_key:
|
41
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record finishOnKey="*"/></Response>
|
42
|
+
|
43
|
+
record_with_max_length:
|
44
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Record maxLength="1800"/></Response>
|
45
|
+
|
46
|
+
dial:
|
47
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial>415-123-4567</Dial></Response>
|
48
|
+
|
49
|
+
dial_with_action:
|
50
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial action="http://foobar.com">415-123-4567</Dial></Response>
|
51
|
+
|
52
|
+
dial_with_get_method:
|
53
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial method="GET">415-123-4567</Dial></Response>
|
54
|
+
|
55
|
+
dial_with_timeout:
|
56
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial timeout="10">415-123-4567</Dial></Response>
|
57
|
+
|
58
|
+
dial_with_hangup_on_star:
|
59
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial hangupOnStar="true">415-123-4567</Dial></Response>
|
60
|
+
|
61
|
+
dial_with_time_limit:
|
62
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial timeLimit="3600">415-123-4567</Dial></Response>
|
63
|
+
|
64
|
+
dial_with_caller_id:
|
65
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial callerId="858-987-6543">415-123-4567</Dial></Response>
|
66
|
+
|
67
|
+
dial_with_redirect:
|
68
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial>415-123-4567</Dial><Redirect>http://www.foo.com/nextInstructions</Redirect></Response>
|
69
|
+
|
70
|
+
dial_with_number_and_send_digits:
|
71
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Dial><Number sendDigits="wwww1928">415-123-4567</Number></Dial></Response>
|
72
|
+
|
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>
|
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>
|
81
|
+
|
82
|
+
hangup:
|
83
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>
|
84
|
+
|
85
|
+
reject:
|
86
|
+
response: <?xml version="1.0" encoding="UTF-8"?><Response><Reject/></Response>
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
|
4
|
+
require 'twilio'
|
5
|
+
|
6
|
+
require 'support/twilio_helpers'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.include TwilioHelpers
|
11
|
+
config.before(:suite) do
|
12
|
+
WebMock.disable_net_connect!
|
13
|
+
end
|
14
|
+
config.after(:suite) do
|
15
|
+
WebMock.allow_net_connect!
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module TwilioHelpers #:nodoc:
|
2
|
+
|
3
|
+
def stub_http_request(http_method, fixture_name, *opts)
|
4
|
+
if opts
|
5
|
+
request_options = opts.pop if opts.last.is_a?(Hash)
|
6
|
+
resource = opts.pop
|
7
|
+
end
|
8
|
+
|
9
|
+
fake_response = fixture(fixture_name)
|
10
|
+
url = twilio_url(resource)
|
11
|
+
|
12
|
+
if request_options
|
13
|
+
stub_request(http_method, url).with(request_options).to_return(:body => fake_response)
|
14
|
+
else
|
15
|
+
stub_request(http_method, url).to_return(:body => fake_response)
|
16
|
+
end
|
17
|
+
|
18
|
+
return fake_response, url
|
19
|
+
end
|
20
|
+
|
21
|
+
def stub_get(fixture, *opts)
|
22
|
+
stub_http_request(:get, fixture, *opts)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stub_post(fixture, *opts)
|
26
|
+
stub_http_request(:post, fixture, *opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
def stub_put(fixture, *opts)
|
30
|
+
stub_http_request(:put, fixture, *opts)
|
31
|
+
end
|
32
|
+
|
33
|
+
def stub_delete(fixture, *opts)
|
34
|
+
stub_http_request(:delete, fixture, *opts)
|
35
|
+
end
|
36
|
+
|
37
|
+
def verb_response(verb)
|
38
|
+
path = File.join(File.dirname(__FILE__), "../fixtures/yml/verb_responses.yml")
|
39
|
+
YAML.load_file(path)[verb.to_s]['response']
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def twilio_url(url=nil)
|
45
|
+
"https://mysid:mytoken@api.twilio.com:443/2010-04-01/Accounts/mysid#{'/' + url if url}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def fixture(filename)
|
49
|
+
path = File.join(File.dirname(__FILE__), "../fixtures/xml/#{filename}.xml")
|
50
|
+
File.read path
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Account' do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "gets an account" do
|
9
|
+
response, url = stub_get(:account)
|
10
|
+
|
11
|
+
Twilio::Account.get.should == response
|
12
|
+
WebMock.should have_requested(:get, twilio_url)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "updates name" do
|
16
|
+
response, url = stub_put(:account_renamed)
|
17
|
+
|
18
|
+
Twilio::Account.update_name('Bubba').should == response
|
19
|
+
WebMock.should have_requested(:put, twilio_url).with(:body => {:FriendlyName => 'Bubba'})
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Available Phone Numbers" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
end
|
7
|
+
|
8
|
+
context "Local Number" do
|
9
|
+
it "is searchable" do
|
10
|
+
response, url = stub_get(:available_phone_numbers_local, 'AvailablePhoneNumbers/US/Local')
|
11
|
+
|
12
|
+
Twilio::AvailablePhoneNumbers.search_local.should == response
|
13
|
+
WebMock.should have_requested(:get, url)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "is searchable by area code" do
|
17
|
+
response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?AreaCode=510')
|
18
|
+
|
19
|
+
Twilio::AvailablePhoneNumbers.search_local(:area_code => 510).should == response
|
20
|
+
WebMock.should have_requested(:get, url)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "is searchable by postal code" do
|
24
|
+
response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?InPostalCode=94612')
|
25
|
+
|
26
|
+
Twilio::AvailablePhoneNumbers.search_local(:postal_code => 94612).should == response
|
27
|
+
WebMock.should have_requested(:get, url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "is searchable using multiple parameters" do
|
31
|
+
response, url = stub_get(:available_phone_numbers_local_search, 'AvailablePhoneNumbers/US/Local?NearLatLong=37.806940%2C-122.270360&InRateCenter=OKLD0349T&NearNumber=15105551213&Distance=50&InRegion=CA&InLata=722&Contains=510555****')
|
32
|
+
|
33
|
+
Twilio::AvailablePhoneNumbers.search_local(:in_region => 'CA', :contains => '510555****', :near_lat_long => '37.806940,-122.270360', :near_number => '15105551213', :in_lata => 722, :in_rate_center => 'OKLD0349T', :distance => 50).should == response
|
34
|
+
WebMock.should have_requested(:get, url)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "Toll-free Number" do
|
39
|
+
it "is searchable" do
|
40
|
+
response, url = stub_get(:available_phone_numbers_toll_free, 'AvailablePhoneNumbers/US/TollFree')
|
41
|
+
|
42
|
+
Twilio::AvailablePhoneNumbers.search_toll_free.should == response
|
43
|
+
WebMock.should have_requested(:get, url)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "is searchable as a vanity number" do
|
47
|
+
response, url = stub_get(:available_phone_numbers_toll_free_search, 'AvailablePhoneNumbers/US/TollFree?Contains=STORM')
|
48
|
+
|
49
|
+
Twilio::AvailablePhoneNumbers.search_toll_free(:contains => 'STORM').should == response
|
50
|
+
WebMock.should have_requested(:get, url)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Call" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
@call_sid = 'CA42ed11f93dc08b952027ffbc406d0868'
|
7
|
+
end
|
8
|
+
|
9
|
+
it "can be made" do
|
10
|
+
response, url = stub_post(:call_new, 'Calls')
|
11
|
+
|
12
|
+
Twilio::Call.make('4158675309', '4155551212', 'http://localhost:3000/call_handler').should == response
|
13
|
+
WebMock.should have_requested(:post, url)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "can be redirected" do
|
17
|
+
response, url = stub_post(:call_redirected, "Calls/#{@call_sid}")
|
18
|
+
|
19
|
+
Twilio::Call.redirect(@call_sid, 'http://localhost:3000/redirect_handler').should == response
|
20
|
+
WebMock.should have_requested(:post, url)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "gets a list of calls" do
|
24
|
+
response, url = stub_get(:calls, 'Calls')
|
25
|
+
|
26
|
+
Twilio::Call.list.should == response
|
27
|
+
WebMock.should have_requested(:get, url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "gets a specific call" do
|
31
|
+
response, url = stub_get(:calls, "Calls/#{@call_sid}")
|
32
|
+
|
33
|
+
Twilio::Call.get(@call_sid).should == response
|
34
|
+
WebMock.should have_requested(:get, url)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "gets a list of call segments" do
|
38
|
+
response, url = stub_get(:calls, "Calls/#{@call_sid}/Segments")
|
39
|
+
|
40
|
+
Twilio::Call.segments(@call_sid).should == response
|
41
|
+
WebMock.should have_requested(:get, url)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "gets a specific call segment" do
|
45
|
+
response, url = stub_get(:calls, "Calls/#{@call_sid}/Segments/abc123")
|
46
|
+
|
47
|
+
Twilio::Call.segments(@call_sid, 'abc123').should == response
|
48
|
+
WebMock.should have_requested(:get, url)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "gets a list of call recordings" do
|
52
|
+
response, url = stub_get(:recordings, "Calls/#{@call_sid}/Recordings")
|
53
|
+
|
54
|
+
Twilio::Call.recordings(@call_sid).should == response
|
55
|
+
WebMock.should have_requested(:get, url)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "gets a list of call notifications" do
|
59
|
+
response, url = stub_get(:notifications, "Calls/#{@call_sid}/Notifications")
|
60
|
+
|
61
|
+
Twilio::Call.notifications(@call_sid).should == response
|
62
|
+
WebMock.should have_requested(:get, url)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Conference" do
|
4
|
+
before(:all) do
|
5
|
+
Twilio.connect('mysid', 'mytoken')
|
6
|
+
@conference_sid = 'CF9f2ead1ae43cdabeab102fa30d938378'
|
7
|
+
@call_sid = 'CA9ae8e040497c0598481c2031a154919e'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "gets a list of conferences" do
|
11
|
+
response, url = stub_get(:conferences, 'Conferences')
|
12
|
+
|
13
|
+
Twilio::Conference.list.should == response
|
14
|
+
WebMock.should have_requested(:get, url)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "gets a specific conference" do
|
18
|
+
response, url = stub_get(:conference, "Conferences/#{@conference_sid}")
|
19
|
+
|
20
|
+
Twilio::Conference.get(@conference_sid).should == response
|
21
|
+
WebMock.should have_requested(:get, url)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "gets a list of participants" do
|
25
|
+
response, url = stub_get(:conference_participants, "Conferences/#{@conference_sid}/Participants")
|
26
|
+
|
27
|
+
Twilio::Conference.participants(@conference_sid).should == response
|
28
|
+
WebMock.should have_requested(:get, url)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "gets a specific participant" do
|
32
|
+
response, url = stub_get(:conference_participant, "Conferences/#{@conference_sid}/Participants/#{@call_sid}")
|
33
|
+
|
34
|
+
Twilio::Conference.participant(@conference_sid, @call_sid).should == response
|
35
|
+
WebMock.should have_requested(:get, url)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "can mute a particant" do
|
39
|
+
response, url = stub_post(:conference_participant_muted, "Conferences/#{@conference_sid}/Participants/#{@call_sid}", :body => 'Muted=true')
|
40
|
+
|
41
|
+
Twilio::Conference.mute_participant(@conference_sid, @call_sid).should == response
|
42
|
+
WebMock.should have_requested(:post, url)
|
43
|
+
end
|
44
|
+
|
45
|
+
it "can unmute a participant" do
|
46
|
+
response, url = stub_post(:conference_participant, "Conferences/#{@conference_sid}/Participants/#{@call_sid}", :body => 'Muted=false')
|
47
|
+
|
48
|
+
Twilio::Conference.unmute_participant(@conference_sid, @call_sid).should == response
|
49
|
+
WebMock.should have_requested(:post, url)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "can be kicked" do
|
53
|
+
response, url = stub_delete(:conference_participant, "Conferences/#{@conference_sid}/Participants/#{@call_sid}")
|
54
|
+
|
55
|
+
Twilio::Conference.kick_participant(@conference_sid, @call_sid).should == response
|
56
|
+
WebMock.should have_requested(:delete, url)
|
57
|
+
end
|
58
|
+
end
|