Class: BandwidthIris::Site

Inherits:
Object
  • Object
show all
Extended by:
ClientWrapper
Includes:
ApiItem
Defined in:
lib/bandwidth-iris/site.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, item) ⇒ Object



23
24
25
26
27
# File 'lib/bandwidth-iris/site.rb', line 23

def self.create(client, item)
  location = client.make_request(:post, client.(SITE_PATH), {:site => item})[1][:location]
  id = Client.get_id_from_location_header(location)
  self.get(client, id)
end

.get(client, id) ⇒ Object



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

def self.get(client, id)
  data  = client.make_request(:get, "#{client.(SITE_PATH)}/#{id}")[0]
  Site.new(data[:site], client)
end

.list(client, query = nil) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/bandwidth-iris/site.rb', line 8

def self.list(client, query = nil)
  list = client.make_request(:get, client.(SITE_PATH), query)[0][:sites][:site]
  list = if list.is_a?(Array) then list else [list] end
  list.map do |i|
    Site.new(i, client)
  end
end

Instance Method Details

#create_sip_peer(item) ⇒ Object



54
55
56
57
58
# File 'lib/bandwidth-iris/site.rb', line 54

def create_sip_peer(item)
   location = @client.make_request(:post, "#{@client.(SITE_PATH)}/#{id}/sippeers", {:sip_peer => item})[1][:location]
   id = Client.get_id_from_location_header(location)
   get_sip_peer(id)
end

#deleteObject



35
36
37
# File 'lib/bandwidth-iris/site.rb', line 35

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

#get_inservice_numbersObject



78
79
80
81
82
# File 'lib/bandwidth-iris/site.rb', line 78

def get_inservice_numbers()
  list = @client.make_request(:get, "#{@client.(SITE_PATH)}/#{id}/inserviceNumbers")[0]
  # TODO need additional documentaion
  list
end

#get_orders(size: 30, page: 1) ⇒ Object



72
73
74
75
76
# File 'lib/bandwidth-iris/site.rb', line 72

def get_orders(size: 30, page: 1)
  list = @client.make_request(:get, "#{@client.(SITE_PATH)}/#{id}/orders", {size: size, page: page})[0]
  # TODO need additional documentaion
  list
end

#get_portinsObject



60
61
62
63
64
# File 'lib/bandwidth-iris/site.rb', line 60

def get_portins()
  list = @client.make_request(:get, "#{@client.(SITE_PATH)}/#{id}/portins")[0]
  # TODO need additional documentaion
  list
end

#get_sip_peer(peer_id) ⇒ Object



39
40
41
42
43
44
# File 'lib/bandwidth-iris/site.rb', line 39

def get_sip_peer(peer_id)
  item = @client.make_request(:get, "#{@client.(SITE_PATH)}/#{id}/sippeers/#{peer_id}")[0][:sip_peer]
  item[:site_id] = id
  puts item
  item
end

#get_sip_peersObject



46
47
48
49
50
51
52
# File 'lib/bandwidth-iris/site.rb', line 46

def get_sip_peers()
  list = @client.make_request(:get, "#{@client.(SITE_PATH)}/#{id}/sippeers")[0][:sip_peers][:sip_peer]
  return [] if !list
  list = if list.is_a?(Array) then list else [list] end
  list.each {|i| i[:site_id] = id}
  list
end

#get_totaltnsObject



66
67
68
69
70
# File 'lib/bandwidth-iris/site.rb', line 66

def get_totaltns()
  list = @client.make_request(:get, "#{@client.(SITE_PATH)}/#{id}/totaltns")[0]
  # TODO need additional documentaion
  list
end

#update(data) ⇒ Object



31
32
33
# File 'lib/bandwidth-iris/site.rb', line 31

def update(data)
  @client.make_request(:put,"#{@client.(SITE_PATH)}/#{id}", {:site => data})
end