Class: Twilio::AvailablePhoneNumber

Inherits:
Object
  • Object
show all
Extended by:
Finder
Includes:
Resource
Defined in:
lib/twilio/available_phone_number.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finder

all, count, find

Methods included from Resource

#[], #[]=, #initialize, #inspect, #update_attributes

Dynamic Method Handling

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

Class Method Details

.all(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/twilio/available_phone_number.rb', line 7

def all(opts={})
  opts                     = Hash[opts.map { |k,v| [k.to_s.camelize, v]}]
  country_code             = opts['IsoCountryCode'] ? opts.delete('IsoCountryCode') : 'US'
  number_type              = opts.delete('TollFree') ? 'TollFree' : 'Local'
  params                   = { :query => opts } if opts.any?

  handle_response get "/Accounts/#{Twilio::Config.}/AvailablePhoneNumbers/#{country_code}/#{number_type}.json", params 
end

Instance Method Details

#purchase!(opts = {}) ⇒ Object

Shortcut for creating a new incoming phone number. Delegates to Twilio::IncomingPhoneNumber.create accepting the same options as that method does.



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

def purchase!(opts={})
  Twilio::IncomingPhoneNumber.create opts.update :phone_number => phone_number
end