mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Implement a few team endpoints for APIv4 (#5296)
* Implement GET /teams/{team_id} endpoint for APIv4
* Implement GET /users/{user_id}/teams endpoint for APIv4
* Implement GET /teams/{team_id}/members/{user_id} endpoint for APIv4
This commit is contained in:
committed by
Harrison Healey
parent
d91fea6518
commit
ba18374bd1
@@ -64,6 +64,14 @@ func (c *Client4) GetTeamsRoute() string {
|
||||
return fmt.Sprintf("/teams")
|
||||
}
|
||||
|
||||
func (c *Client4) GetTeamRoute(teamId string) string {
|
||||
return fmt.Sprintf(c.GetTeamsRoute()+"/%v", teamId)
|
||||
}
|
||||
|
||||
func (c *Client4) GetTeamMemberRoute(teamId, userId string) string {
|
||||
return fmt.Sprintf(c.GetTeamRoute(teamId)+"/members/%v", userId)
|
||||
}
|
||||
|
||||
func (c *Client4) GetChannelsRoute() string {
|
||||
return fmt.Sprintf("/channels")
|
||||
}
|
||||
@@ -72,10 +80,6 @@ func (c *Client4) GetChannelRoute(channelId string) string {
|
||||
return fmt.Sprintf(c.GetChannelsRoute()+"/%v", channelId)
|
||||
}
|
||||
|
||||
func (c *Client4) GetTeamRoute(teamId string) string {
|
||||
return fmt.Sprintf(c.GetTeamsRoute()+"/%v", teamId)
|
||||
}
|
||||
|
||||
func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
|
||||
return c.DoApiRequest(http.MethodGet, url, "", etag)
|
||||
}
|
||||
@@ -321,6 +325,37 @@ func (c *Client4) CreateTeam(team *Team) (*Team, *Response) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetTeam returns a team based on the provided team id string.
|
||||
func (c *Client4) GetTeam(teamId, etag string) (*Team, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetTeamRoute(teamId), etag); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return TeamFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// GetTeamsForUser returns a list of teams a user is on. Must be logged in as the user
|
||||
// or be a system administrator.
|
||||
func (c *Client4) GetTeamsForUser(userId, etag string) ([]*Team, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams", etag); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return TeamListFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// GetTeamMember returns a team member based on the provided team and user id strings.
|
||||
func (c *Client4) GetTeamMember(teamId, userId, etag string) (*TeamMember, *Response) {
|
||||
if r, err := c.DoApiGet(c.GetTeamMemberRoute(teamId, userId), etag); err != nil {
|
||||
return nil, &Response{StatusCode: r.StatusCode, Error: err}
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return TeamMemberFromJson(r.Body), BuildResponse(r)
|
||||
}
|
||||
}
|
||||
|
||||
// Channel Section
|
||||
|
||||
// CreateChannel creates a channel based on the provided channel struct.
|
||||
|
||||
Reference in New Issue
Block a user