Module: Mattermost
- Includes:
- HTTParty
- Defined in:
- lib/mattermost.rb,
lib/mattermost/post.rb,
lib/mattermost/team.rb,
lib/mattermost/user.rb,
lib/mattermost/admin.rb,
lib/mattermost/channel.rb,
lib/mattermost/version.rb,
lib/mattermost/mattermost_object.rb
Defined Under Namespace
Classes: Admin, Channel, MattermostObject, NotImplementedError, Post, Team, User
Constant Summary
collapse
- VERSION =
"0.3"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Attribute Details
#team ⇒ Object
Returns the value of attribute team.
18
19
20
|
# File 'lib/mattermost.rb', line 18
def team
@team
end
|
Class Method Details
.connect(username, password, server, team_name, options = {}) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/mattermost.rb', line 22
def self.connect(username, password, server, team_name, options = {})
self.base_uri server
options[:httparty].each do |k,v|
self.send(k, v)
end
request = self.post('/users/login',
:body => { :login_id => username, :password => password, :token => "" }.to_json )
self. "Cookie" => "MMAUTHTOKEN=#{request.headers['token']}"
self. "X-Requested-With" => 'XMLHttpRequest'
initial_load = self.get("/users/initial_load")
team = initial_load.parsed_response['teams'].select { |team| team['name'] == team_name }.first
@team = Team.new(team)
unless options[:preload_user] == false
Mattermost::User.all
end
end
|
.connected? ⇒ Boolean
39
40
41
|
# File 'lib/mattermost.rb', line 39
def self.connected?
Mattermost.get("/users/me").success?
end
|
.team ⇒ Object
43
44
45
|
# File 'lib/mattermost.rb', line 43
def self.team
@team
end
|