Class: Mattermost::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mattermost/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Client

Returns a new instance of Client.



13
14
15
16
# File 'lib/mattermost/client.rb', line 13

def initialize(server)
  self.server = server
  self.base_uri = "#{server}/api/v4"
end

Instance Attribute Details

#serverObject

Returns the value of attribute server.



11
12
13
# File 'lib/mattermost/client.rb', line 11

def server
  @server
end

#tokenObject

Returns the value of attribute token.



11
12
13
# File 'lib/mattermost/client.rb', line 11

def token
  @token
end

Instance Method Details

#connected?Boolean

Returns:



34
35
36
# File 'lib/mattermost/client.rb', line 34

def connected?
  getMe().success?
end

#login(username, password) ⇒ Object



18
19
20
21
22
# File 'lib/mattermost/client.rb', line 18

def (username, password)
   = post('/users/login', :body => {:login_id => uername, :password => password}.to_json)
  self.token = .headers['token']
  update_token
end

#logoutObject



24
25
26
27
# File 'lib/mattermost/client.rb', line 24

def logout
  self.token = nil
  update_token
end

#use_access_token(token) ⇒ Object



29
30
31
32
# File 'lib/mattermost/client.rb', line 29

def use_access_token(token)
  self.token = token
  update_token
end