team.rb 714 Bytes
Newer Older
1
module Mattermost
Kamil Trzcinski's avatar
Kamil Trzcinski committed
2
  class Team < Client
3
    # Returns all teams that the current user is a member of
Kamil Trzcinski's avatar
Kamil Trzcinski committed
4
    def all
5
      session_get("/api/v4/users/me/teams")
6
    end
7

8 9
    # Creates a team on the linked Mattermost instance, the team admin will be the
    # `current_user` passed to the Mattermost::Client instance
Z.J. van de Weg's avatar
Z.J. van de Weg committed
10
    def create(name:, display_name:, type:)
11
      session_post('/api/v4/teams', body: {
Z.J. van de Weg's avatar
Z.J. van de Weg committed
12 13 14 15
        name: name,
        display_name: display_name,
        type: type
      }.to_json)
16
    end
17 18

    # The deletion is done async, so the response is fast.
19
    # On the mattermost side, this triggers an soft deletion
20
    def destroy(team_id:)
21
      session_delete("/api/v4/teams/#{team_id}")
22
    end
23 24
  end
end