Class: Twilio::Call

Inherits:
TwilioObject show all
Defined in:
lib/twilio/call.rb

Overview

A Call represenents a connection between a telephone and Twilio. This may be inbound, when a person calls your application, or outbound when your application initiates the call, either via the REST API, or during a call via the Dial Verb.

Instance Method Summary collapse

Methods inherited from TwilioObject

#connected?, #initialize, method_missing

Constructor Details

This class inherits a constructor from Twilio::TwilioObject

Instance Method Details

#get(call_sid) ⇒ Object



17
18
19
# File 'lib/twilio/call.rb', line 17

def get(call_sid)
  Twilio.get("/Calls/#{call_sid}")
end

#list(opts = {}) ⇒ Object



13
14
15
# File 'lib/twilio/call.rb', line 13

def list(opts = {})
  Twilio.get("/Calls", :query => (opts.empty? ? nil : opts))  
end

#make(from, to, url, opts = {}) ⇒ Object

Example:

Twilio.connect('my_twilio_sid', 'my_auth_token')
Twilio::Call.make(CALLER_ID, user_number, 'http://myapp.com/twilio_response_handler')


9
10
11
# File 'lib/twilio/call.rb', line 9

def make(from, to, url, opts = {})
  Twilio.post("/Calls", :body => {:From => from, :To => to, :Url => url}.merge(opts))
end

#notifications(call_sid) ⇒ Object



33
34
35
# File 'lib/twilio/call.rb', line 33

def notifications(call_sid)
  Twilio.get("/Calls/#{call_sid}/Notifications")
end

#recordings(call_sid) ⇒ Object



29
30
31
# File 'lib/twilio/call.rb', line 29

def recordings(call_sid)
  Twilio.get("/Calls/#{call_sid}/Recordings")
end

#redirect(call_sid, new_url, url_action = 'POST') ⇒ Object



21
22
23
# File 'lib/twilio/call.rb', line 21

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

#segments(call_sid, call_segment_sid = nil) ⇒ Object



25
26
27
# File 'lib/twilio/call.rb', line 25

def segments(call_sid, call_segment_sid = nil)
  Twilio.get("/Calls/#{call_sid}/Segments#{ '/' + call_segment_sid if call_segment_sid }")
end