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

27 lines
738 B
Ruby
Raw Normal View History

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
session_get('/api/v3/teams/all')
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
end
end