summaryrefslogtreecommitdiff
path: root/lib/mattermost/team.rb
blob: 54d029cb02295b59b00dc6dccc93ff521ded96a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Mattermost
  class Team < Session
    def self.team_admin
      body = get('/users/initial_load').parsed_response

      return [] unless body['team_members']

      team_ids = body['team_members'].map do |team|
        team['team_id'] if team['roles'].split.include?('team_admin')
      end.compact

      body['teams'].select do |team|
        team_ids.include?(team['id'])
      end
    end
  end
end