Class: Wowza::REST::Publishers

Inherits:
Object
  • Object
show all
Defined in:
lib/wowza/rest/publishers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Publishers

Returns a new instance of Publishers.



7
8
9
# File 'lib/wowza/rest/publishers.rb', line 7

def initialize(conn)
  @conn = conn
end

Instance Attribute Details

#server_nameObject

Returns the value of attribute server_name.



5
6
7
# File 'lib/wowza/rest/publishers.rb', line 5

def server_name
  @server_name
end

Instance Method Details

#allObject



11
12
13
14
15
16
17
18
19
# File 'lib/wowza/rest/publishers.rb', line 11

def all
  resp = conn.get(resource_path)
  JSON.parse(resp.body)['publishers'].map do |attrs|
    Publisher.new(name: attrs["name"]).tap do |p|
      p.conn = conn
      p.persisted = true
    end
  end
end

#find(name) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/wowza/rest/publishers.rb', line 21

def find(name)
  resp = conn.get("#{resource_path}/#{name}")
  if resp.code == "200"
    attrs = JSON.parse(resp.body)
    Publisher.new(name: attrs["name"]).tap do |p|
      p.conn = conn
      p.persisted = true
    end
  else
    nil
  end
end

#resource_pathObject



34
35
36
# File 'lib/wowza/rest/publishers.rb', line 34

def resource_path
  "#{server_path}/publishers"
end

#server_pathObject



42
43
44
# File 'lib/wowza/rest/publishers.rb', line 42

def server_path
  "/v2/servers/#{server_name}"
end