Class: Twilio::IncomingPhoneNumber

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

Overview

An IncomingPhoneNumber resource represents a phone number given to you by Twilio to receive incoming phone calls. Example:

Twilio.connect('my_twilio_sid', 'my_auth_token')
Twilio::IncomingPhoneNumber.list

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

#create(opts) ⇒ Object

Creates a phone number in Twilio. You must first find an existing number using the AvailablePhoneNumber class before creating one here.

Required: you must either set PhoneNumber or AreaCode as a required option For additional options, see www.twilio.com/docs/api/rest/incoming-phone-numbers



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

def create(opts)
  raise "You must set either :PhoneNumber or :AreaCode" if !opts.include?(:AreaCode) && !opts.include?(:PhoneNumber)
  Twilio.post("/IncomingPhoneNumbers", :body => opts)
end

#delete(incoming_sid) ⇒ Object



30
31
32
# File 'lib/twilio/incoming_phone_number.rb', line 30

def delete(incoming_sid)
  Twilio.delete("/IncomingPhoneNumbers/#{incoming_sid}")
end

#get(incoming_sid) ⇒ Object



12
13
14
# File 'lib/twilio/incoming_phone_number.rb', line 12

def get(incoming_sid)
  Twilio.get("/IncomingPhoneNumbers/#{incoming_sid}") 
end

#list(opts = {}) ⇒ Object



8
9
10
# File 'lib/twilio/incoming_phone_number.rb', line 8

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

#update(incoming_sid, opts) ⇒ Object



26
27
28
# File 'lib/twilio/incoming_phone_number.rb', line 26

def update(incoming_sid, opts)
  Twilio.post("/IncomingPhoneNumbers/#{incoming_sid}", :body => opts)
end