Class: Mattermost::Channel

Inherits:
MattermostObject show all
Defined in:
lib/mattermost/channel.rb

Class Method Summary collapse

Methods inherited from MattermostObject

find, find_by, #initialize, method_missing

Constructor Details

This class inherits a constructor from Mattermost::MattermostObject

Class Method Details

.all(force_refresh = false) ⇒ Object

Returns channels for the current team _that the logged in user has joined_ call Mattermost::Channel.more to get a list of all the channels (like, actually)

Parameters:

  • force_refresh (boolean) (defaults to: false)

    to recache the channels



15
16
17
18
# File 'lib/mattermost/channel.rb', line 15

def self.all(force_refresh = false)
  @channels = nil if force_refresh
  @channels ||= all_channels
end

.countsObject

Returns a hash of counts This is mostly useless because fetching a channel will return the counts for you. “yckjbepc4frbmmq9in6tap1dwa”=>32,

"update_times"=>{"ps6kdfuk9p8mjx6pkr3krgq3by"=>1463180151709, "yckjbepc4frbmmq9in6tap1dwa"=>1457216806189}}


35
36
37
# File 'lib/mattermost/channel.rb', line 35

def self.counts
  Mattermost.get("/channels/counts")
end

.create_direct(attributes = {}) ⇒ Object



39
40
41
42
# File 'lib/mattermost/channel.rb', line 39

def self.create_direct(attributes = {})
  raise NotImplementedError
  Mattermost.post("/channels/create_direct")
end

.moreObject

Returns all of the channels for the current team Unlike self.all which only returns the channels the user has joined



22
23
24
25
26
27
28
29
# File 'lib/mattermost/channel.rb', line 22

def self.more
  channels = []
  request = Mattermost.get("/teams/#{Mattermost.team.id}/channels/more")
  request.parsed_response['channels'].each do |channel|
    channels << self.new(channel)
  end
  return channels
end

.new(attributes = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/mattermost/channel.rb', line 4

def self.new(attributes = {})
  if attributes.empty?
    return ::Channel.default_attributes
  end
  ::Channel.new(attributes)
end