2016-12-13 13:52:41 -05:00
|
|
|
module Mattermost
|
2016-12-19 18:22:10 -05:00
|
|
|
class Team < Client
|
2017-02-02 09:04:02 -05:00
|
|
|
# Returns **all** teams for an admin
|
2016-12-19 18:22:10 -05:00
|
|
|
def all
|
2017-01-23 06:58:51 -05:00
|
|
|
session_get('/api/v3/teams/all')
|
2016-12-16 09:45:56 -05:00
|
|
|
end
|
2017-02-02 09:04:02 -05:00
|
|
|
|
2017-02-03 05:29:56 -05:00
|
|
|
# Creates a team on the linked Mattermost instance, the team admin will be the
|
|
|
|
# `current_user` passed to the Mattermost::Client instance
|
|
|
|
def create(group, params)
|
|
|
|
session_post('/api/v3/teams/create', body: new_team_params(group, params).to_json)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
MATTERMOST_TEAM_LENGTH_MAX = 59
|
|
|
|
|
|
|
|
def new_team_params(group, options)
|
|
|
|
{
|
|
|
|
name: group.path[0..MATTERMOST_TEAM_LENGTH_MAX],
|
|
|
|
display_name: group.name[0..MATTERMOST_TEAM_LENGTH_MAX],
|
|
|
|
type: group.public? ? 'O' : 'I' # Open vs Invite-only
|
|
|
|
}.merge(options)
|
2017-02-02 09:04:02 -05:00
|
|
|
end
|
2016-12-13 13:52:41 -05:00
|
|
|
end
|
|
|
|
end
|