Sha256: bdb57095a723755f491a786152d4c4dce135f4f78a983001e1ae70a23e60f0af
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
module Trumpet class Channel < Trumpet::Resource def self.create(options) Channel.new(Trumpet::Request.post('/channels', options)) end def self.find(name, options={}) Channel.new(Trumpet::Request.get("/channels/#{name}", options)) end def self.all(options={}) Trumpet::Request.get('/channels', options).map { |attributes| Channel.new(attributes) } end def self.all_by_user(name, options={}) channels = Trumpet::Request.get("/users/#{name}/channels", options) channels.map { |attributes| Channel.new(attributes) } end def delete(options={}) options[:credentials] ||= @credentials !!Trumpet::Request.delete("/channels/#{name}", :parse_response => false, :credentials => options[:credentials]) end def broadcast(message, options={}) options[:credentials] ||= @credentials !!Trumpet::Request.post("/channels/#{@name}/messages", :parameters => message.to_h, :parse_response => false, :credentials => options[:credentials]) end def messages(options={}) options[:credentials] ||= @credentials messages = Trumpet::Request.get("/channels/#{@name}/messages", options) messages.map { |attributes| Message.new(attributes) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trumpet-trumpet-0.1.2 | lib/trumpet/channel.rb |
trumpet-trumpet-0.1.3 | lib/trumpet/channel.rb |
trumpet-trumpet-0.1.4 | lib/trumpet/channel.rb |