Class: Telapi::IncomingPhoneNumber

Inherits:
Resource
  • Object
show all
Defined in:
lib/telapi/incoming_phone_number.rb

Overview

Wraps TelAPI Incoming Phone Number functionality

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#attributes, #initialize

Methods included from Network

api_uri, default_options, post, response_format

Constructor Details

This class inherits a constructor from Telapi::Resource

Class Method Details

.create(phone_number) ⇒ Object

Creates a new incoming phone number, returning a Telapi::IncomingPhoneNumber object See http://www.telapi.com/docs/api/rest/incoming-phone-numbers/add-or-delete/

Required params:

phone_number

area code, e.g. 18052585701



31
32
33
34
35
# File 'lib/telapi/incoming_phone_number.rb', line 31

def create(phone_number)
  opts = { :PhoneNumber => phone_number }
  response = Network.post(['IncomingPhoneNumbers'], opts)
  IncomingPhoneNumber.new(response)
end

.delete(id) ⇒ Object

Delete an incoming phone number, returning a Telapi::IncomingPhoneNumber object See http://www.telapi.com/docs/api/rest/incoming-phone-numbers/add-or-delete/

Required params:

id

incoming phone number id



42
43
44
45
# File 'lib/telapi/incoming_phone_number.rb', line 42

def delete(id)
  response = Network.delete(['IncomingPhoneNumbers', id])
  IncomingPhoneNumber.new(response)
end

.get(id) ⇒ Object

Returns a Telapi::IncomingPhoneNumber object given its id See http://www.telapi.com/docs/api/rest/incoming-phone-numbers/view/



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

def get(id)
  response = Network.get(['IncomingPhoneNumbers', id])
  IncomingPhoneNumber.new(response)
end

.list(optional_params = {}) ⇒ Object

Returns a resource collection containing Telapi::IncomingPhoneNumber objects See http://www.telapi.com/docs/api/rest/incoming-phone-numbers/list/

Optional params is a hash containing:

PhoneNumber

valid TelAPI phone number, e.g. 7325551234

FriendlyName

valid domestic format phone number, e.g. 7325551234

Page

integer greater than 0

PageSize

integer greater than 0



14
15
16
17
# File 'lib/telapi/incoming_phone_number.rb', line 14

def list(optional_params = {})
  response = Network.get(['IncomingPhoneNumbers'], optional_params)
  ResourceCollection.new(response, 'incoming_phone_numbers', self)
end

.update(id, optional_params = {}) ⇒ Object

Updates an incoming phone number, returning a Telapi::IncomingPhoneNumber object See http://www.telapi.com/docs/api/rest/incoming-phone-numbers/update/

Required params:

id

incoming phone number id

Optional params is a hash containing:

FriendlyName

string

VoiceUrl

valid URL

VoiceMethod

(POST) or GET

VoiceFallbackUrl

valid URL

VoiceFallbackMethod

(POST) or GET

VoiceCallerIdLookup

true or (false)

SmsUrl

valid URL

SmsMethod

(POST) or GET

SmsFallbackUrl

valid URL

SmsFallbackMethod

(POST) or GET

HeartbeatUrl

valid URL

HeartbeatMethod

(POST) or GET

StatusCallback

valid URL

StatusCallbackMethod

(POST) or GET



68
69
70
71
# File 'lib/telapi/incoming_phone_number.rb', line 68

def update(id, optional_params = {})
  response = Network.post(['IncomingPhoneNumbers', id], optional_params)
  IncomingPhoneNumber.new(response)
end

Instance Method Details

#deleteObject

See ::delete



76
77
78
# File 'lib/telapi/incoming_phone_number.rb', line 76

def delete
  self.class.delete(self.sid)
end

#update(optional_params = {}) ⇒ Object

See ::update



81
82
83
# File 'lib/telapi/incoming_phone_number.rb', line 81

def update(optional_params = {})
  self.class.update(self.sid, optional_params)
end