Skip to content

Commit

Permalink
redirect REST action
Browse files Browse the repository at this point in the history
  • Loading branch information
titanous committed Nov 29, 2009
1 parent 194da08 commit 189dcad
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/twilio/call.rb
Expand Up @@ -18,6 +18,10 @@ def get(call_sid)
Twilio.get("/Calls/#{call_sid}")
end

def redirect(call_sid, new_url, url_action = 'POST')
Twilio.post("/Calls/#{call_sid}", :body => {:CurrentUrl => new_url, :CurrentMethod => url_action})
end

def segments(call_sid, call_segment_sid = nil)
Twilio.get("/Calls/#{call_sid}/Segments#{ '/' + call_segment_sid if call_segment_sid }")
end
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/xml/call_redirected.xml
@@ -0,0 +1,15 @@
<TwilioResponse>
<Call>
<Sid>CA42ed11f93dc08b952027ffbc406d0868</Sid>
<CallSegmentSid/>
<AccountSid>AC309475e5fede1b49e100272a8640f438</AccountSid>
<Called>4155551234</Called>
<Caller>4158675309</Caller>
<PhoneNumberSid>PN01234567890123456789012345678900</PhoneNumberSid>
<Status>1</Status>
<StartTime>Thu, 03 Apr 2008 04:36:33 -0400</StartTime>
<EndTime/>
<Price/>
<Flags>1</Flags>
</Call>
</TwilioResponse>
5 changes: 5 additions & 0 deletions test/twilio/call_test.rb
Expand Up @@ -20,6 +20,11 @@ class CallTest < Test::Unit::TestCase #:nodoc: all
Twilio::Call.make('4158675309', '4155551212', 'http://test.local/call_handler')
end

should "be redirected" do
assert_equal stub_response(:post, :call_redirected, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868'),
Twilio::Call.redirect('CA42ed11f93dc08b952027ffbc406d0868', 'http://www.myapp.com/myhandler.php')
end

context "with segments" do
should "returns a list of Call resources that were segments created in the same call" do
assert_equal stub_response(:get, :calls, :resource => 'Calls/CA42ed11f93dc08b952027ffbc406d0868/Segments'),
Expand Down

0 comments on commit 189dcad

Please sign in to comment.