Sha256: a11036ea2688e2d47ccc49f0852dc44a1c61db0b53bffe5f50f638c25173a244

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

module Trumpet
  class User < Trumpet::Resource
    
    def self.create(options)
      attributes = Trumpet::Request.post('/users', options)
      User.new(attributes)
    end
    
    def self.find(name, options={})
      User.new(Trumpet::Request.get("/users/#{name}", options))
    end

    # 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
    
    def delete(options={})
      options[:credentials] ||= @credentials
      options[:parse_response] = false
      !!Trumpet::Request.delete("/users/#{@name}", options)
    end
    
    def channels(options={})
      options[:credentials] ||= @credentials
      channels = Trumpet::Request.get("/users/#{name}/channels", options)
      channels.map { |attributes| Channel.new(attributes) }
    end
    
    def listeners(options={})
      options[:credentials] ||= @credentials
      listeners = Trumpet::Request.get("/users/#{name}/listeners", options)
      listeners.map { |attributes| Listener.new(attributes) }
    end
    
    def receivers(options={})
      options[:credentials] ||= @credentials
      receivers = Trumpet::Request.get("/users/#{name}/receivers", options)
      receivers.map { |attributes| Receiver.new(attributes) }
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trumpet-trumpet-0.1.2 lib/trumpet/user.rb
trumpet-trumpet-0.1.3 lib/trumpet/user.rb
trumpet-trumpet-0.1.4 lib/trumpet/user.rb