Class: Mattermost::User

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

Class Method Summary collapse

Methods inherited from MattermostObject

#initialize, method_missing

Constructor Details

This class inherits a constructor from Mattermost::MattermostObject

Class Method Details

.all(force_refresh = false) ⇒ Object



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

def self.all(force_refresh = false)
  @users = nil if force_refresh
  @users ||= all_users
end

.find(id) ⇒ Object

Return the user that has an id of @param id



21
22
23
# File 'lib/mattermost/user.rb', line 21

def self.find(id)
  find_by(:id => id)
end

.find_by(opts = {}) ⇒ Object

Return a user that matches a given attribute. Common pairs are :email => email, or :username => username Return nil if not no matches



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

def self.find_by(opts = {})
  all.select { |user| user.send(opts.keys.first) == opts.values.first }.first
end

.meObject

Returns the user that was used for authentication on Mattermost.connect



32
33
34
35
# File 'lib/mattermost/user.rb', line 32

def self.me
  request = Mattermost.get("/users/me")
  self.new(request.parsed_response)
end

.new(attributes = {}) ⇒ Object



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

def self.new(attributes = {})
  ::User.new(attributes)
end

.status(user_ids = []) ⇒ Object

Return the status of users Statuses are “offline”, “away”, or “online”



27
28
29
# File 'lib/mattermost/user.rb', line 27

def self.status(user_ids = [])
  Mattermost.post("/users/status", :body => user_ids.to_json)
end