Class: Trumpet::User

Inherits:
Resource show all
Defined in:
lib/trumpet/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#to_h

Class Method Details

.create(options) ⇒ Object



4
5
6
7
# File 'lib/trumpet/user.rb', line 4

def self.create(options)
  attributes = Trumpet::Request.post('/users', options)
  User.new(attributes)
end

.find(name, options = {}) ⇒ Object



9
10
11
# File 'lib/trumpet/user.rb', line 9

def self.find(name, options={})
  User.new(Trumpet::Request.get("/users/#{name}", options))
end

Instance Method Details

#channels(options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/trumpet/user.rb', line 29

def channels(options={})
  options[:credentials] ||= @credentials
  channels = Trumpet::Request.get("/users/#{name}/channels", options)
  channels.map { |attributes| Channel.new(attributes) }
end

#delete(options = {}) ⇒ Object

TODO: Not yet supported in backend def update(parameters)

options = {}

options[:credentials] ||= @credentials
options[:parameters] = self.to_h.merge(parameters)

!!set_attributes(Trumpet::Request.put("/users/#{name}", options))

end



23
24
25
26
27
# File 'lib/trumpet/user.rb', line 23

def delete(options={})
  options[:credentials] ||= @credentials
  options[:parse_response] = false
  !!Trumpet::Request.delete("/users/#{@name}", options)
end

#listeners(options = {}) ⇒ Object



35
36
37
38
39
# File 'lib/trumpet/user.rb', line 35

def listeners(options={})
  options[:credentials] ||= @credentials
  listeners = Trumpet::Request.get("/users/#{name}/listeners", options)
  listeners.map { |attributes| Listener.new(attributes) }
end

#receivers(options = {}) ⇒ Object



41
42
43
44
45
# File 'lib/trumpet/user.rb', line 41

def receivers(options={})
  options[:credentials] ||= @credentials
  receivers = Trumpet::Request.get("/users/#{name}/receivers", options)
  receivers.map { |attributes| Receiver.new(attributes) }
end