summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go39
1 files changed, 36 insertions, 3 deletions
diff --git a/model/client4.go b/model/client4.go
index f2dc7625b..63f65ed48 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -549,8 +549,8 @@ func (c *Client4) RevokeSession(userId, sessionId string) (bool, *Response) {
}
}
-// getTeamsUnreadForUser will return an array with TeamUnread objects that contain the amount of
-// unread messages and mentions the current user has for the teams it belongs to.
+// GetTeamsUnreadForUser will return an array with TeamUnread objects that contain the amount
+// of unread messages and mentions the current user has for the teams it belongs to.
// An optional team ID can be set to exclude that team from the results. Must be authenticated.
func (c *Client4) GetTeamsUnreadForUser(userId, teamIdToExclude string) ([]*TeamUnread, *Response) {
optional := ""
@@ -696,7 +696,7 @@ func (c *Client4) GetTeamMember(teamId, userId, etag string) (*TeamMember, *Resp
}
}
-// UpdateTeamMemberRoles will update the roles on a team for a user
+// UpdateTeamMemberRoles will update the roles on a team for a user.
func (c *Client4) UpdateTeamMemberRoles(teamId, userId, newRoles string) (bool, *Response) {
requestBody := map[string]string{"roles": newRoles}
if r, err := c.DoApiPut(c.GetTeamMemberRoute(teamId, userId)+"/roles", MapToJson(requestBody)); err != nil {
@@ -707,6 +707,16 @@ func (c *Client4) UpdateTeamMemberRoles(teamId, userId, newRoles string) (bool,
}
}
+// UpdateTeam will update a team.
+func (c *Client4) UpdateTeam(team *Team) (*Team, *Response) {
+ if r, err := c.DoApiPut(c.GetTeamRoute(team.Id), team.ToJson()); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return TeamFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// GetTeamMembers returns team members based on the provided team id string.
func (c *Client4) GetTeamMembers(teamId string, page int, perPage int, etag string) ([]*TeamMember, *Response) {
query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
@@ -718,6 +728,17 @@ func (c *Client4) GetTeamMembers(teamId string, page int, perPage int, etag stri
}
}
+// GetTeamMembersByIds will return an array of team members based on the
+// team id and a list of user ids provided. Must be authenticated.
+func (c *Client4) GetTeamMembersByIds(teamId string, userIds []string) ([]*TeamMember, *Response) {
+ if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v/members/ids", teamId), ArrayToJson(userIds)); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return TeamMembersFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// GetTeamStats returns a team stats based on the team id string.
// Must be authenticated.
func (c *Client4) GetTeamStats(teamId, etag string) (*TeamStats, *Response) {
@@ -729,6 +750,18 @@ func (c *Client4) GetTeamStats(teamId, etag string) (*TeamStats, *Response) {
}
}
+// GetTeamUnread will return a TeamUnread object that contains the amount of
+// unread messages and mentions the user has for the specified team.
+// Must be authenticated.
+func (c *Client4) GetTeamUnread(teamId, userId string) (*TeamUnread, *Response) {
+ if r, err := c.DoApiGet(c.GetUserRoute(userId)+c.GetTeamRoute(teamId)+"/unread", ""); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return TeamUnreadFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// Channel Section
// CreateChannel creates a channel based on the provided channel struct.