gitlab-org--gitlab-foss/lib/mattermost/team.rb

27 lines
698 B
Ruby
Raw Normal View History

module Mattermost
2016-12-19 23:22:10 +00:00
class Team < Client
2017-02-02 14:04:02 +00:00
# Returns **all** teams for an admin
2016-12-19 23:22:10 +00:00
def all
session_get('/api/v3/teams/all')
end
2017-02-02 14:04:02 +00:00
2017-02-03 10:29:56 +00: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)
session_post('/api/v3/teams/create', body: new_team_params(group).to_json)
2017-02-03 10:29:56 +00:00
end
private
MATTERMOST_TEAM_LENGTH_MAX = 59
def new_team_params(group)
2017-02-03 10:29:56 +00:00
{
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
}
2017-02-02 14:04:02 +00:00
end
end
end