Class: Twilio::Call

Inherits:
Object
  • Object
show all
Includes:
Resource
Defined in:
lib/twilio/call.rb

Instance Method Summary collapse

Methods included from Resource

#[], #[]=

Constructor Details

#initialize(attrs = {}) ⇒ Call

:nodoc:



5
6
7
8
9
10
# File 'lib/twilio/call.rb', line 5

def initialize(attrs ={})  #:nodoc:
  @attributes = Hash[attrs.map { |k,v| [k.to_s.camelize, v.to_s] }]
  normalize_http_verbs!
  escape_send_digits! if attributes.include? 'SendDigits'
  normalize_if_machine_parameter!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Twilio::Resource

Instance Method Details

#cancel!Object

Cancels a call if its state is ‘queued’ or ‘ringing’



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

def cancel!
  state_guard { modify_call 'Status' => 'cancelled' }
end

#complete!Object



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

def complete!
  state_guard { modify_call 'Status' => 'completed' }
end

#saveObject

Dials the call



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

def save
  handle_response self.class.post "/Accounts/#{Twilio::ACCOUNT_SID}/Calls.json", :body => attributes
end

#url=(url) ⇒ Object

Update Handler URL



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

def url=(url)
  # If this attribute exists it is assumed the API call to create a call has been made, so we need to tell Twilio.
  modify_call "url" => url if self[:status]
  self[:url] = url
end