Permalink
Browse files

redirect REST action

  • Loading branch information...
1 parent 194da08 commit 189dcad7875f9489354ec71e60a8de84998507c3 @titanous titanous committed Nov 29, 2009
Showing with 24 additions and 0 deletions.
  1. +4 −0 lib/twilio/call.rb
  2. +15 −0 test/fixtures/xml/call_redirected.xml
  3. +5 −0 test/twilio/call_test.rb
View
@@ -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
@@ -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>
View
@@ -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'),

0 comments on commit 189dcad

Please sign in to comment.