Class: BandwidthIris::SipPeer

Inherits:
Object
  • Object
show all
Extended by:
ClientWrapper
Includes:
ApiItem
Defined in:
lib/bandwidth-iris/sip_peer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClientWrapper

wrap_client_arg

Methods included from ApiItem

#[], #[]=, #initialize, #to_data

Class Method Details

.create(client, site_id, item) ⇒ Object



18
19
20
# File 'lib/bandwidth-iris/sip_peer.rb', line 18

def self.create(client, site_id, item)
  Site.new({:id => site_id}, client).create_sip_peer(item)
end

.get(client, site_id, peer_id) ⇒ Object



13
14
15
# File 'lib/bandwidth-iris/sip_peer.rb', line 13

def self.get(client, site_id, peer_id)
  Site.new({:id => site_id}, client).get_sip_peer(peer_id)
end

.list(client, site_id) ⇒ Object



8
9
10
# File 'lib/bandwidth-iris/sip_peer.rb', line 8

def self.list(client, site_id)
  Site.new({:id => site_id}, client).get_sip_peers()
end

Instance Method Details

#deleteObject



23
24
25
# File 'lib/bandwidth-iris/sip_peer.rb', line 23

def delete()
  @client.make_request(:delete,"#{@client.(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{peer_id}")
end

#get_tns(number = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/bandwidth-iris/sip_peer.rb', line 28

def get_tns(number = nil)
  r = @client.make_request(:get,"#{@client.(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{peer_id}/tns#{if number then '/' + CGI.escape(number) else '' end}")[0]
  if number
    r[:sip_peer_telephone_number]
  else
    list = r[:sip_peer_telephone_numbers][:sip_peer_telephone_number]
    return [] if !list
    if list.is_a?(Array) then list else [list] end
  end
end

#move_tns(numbers) ⇒ Object



43
44
45
# File 'lib/bandwidth-iris/sip_peer.rb', line 43

def move_tns(numbers)
  @client.make_request(:post,"#{@client.(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{peer_id}/movetns", {:sip_peer_telephone_numbers => {:full_number => numbers}})[0]
end

#update_tns(number, data) ⇒ Object



39
40
41
# File 'lib/bandwidth-iris/sip_peer.rb', line 39

def update_tns(number, data)
  @client.make_request(:put,"#{@client.(SITE_PATH)}/#{site_id}/#{SIPPEER_PATH}/#{peer_id}/tns/#{CGI.escape(number)}", {:sip_peer_telephone_number => data})[0]
end