From 01aaccb34080ede234602d1ca9acee8373b8560f Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Mon, 27 Mar 2017 20:41:40 +0900 Subject: APIv4 post /channels/ids (#5845) * APIv4 post /channels/ids * updated enpoint as /teams/{team_id}/channels/ids --- model/client4.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index 19d4a9a00..031973a34 100644 --- a/model/client4.go +++ b/model/client4.go @@ -98,7 +98,7 @@ func (c *Client4) GetChannelsRoute() string { return fmt.Sprintf("/channels") } -func (c *Client4) GetPublicChannelsForTeamRoute(teamId string) string { +func (c *Client4) GetChannelsForTeamRoute(teamId string) string { return fmt.Sprintf(c.GetTeamRoute(teamId) + "/channels") } @@ -962,7 +962,17 @@ func (c *Client4) GetChannelStats(channelId string, etag string) (*ChannelStats, // GetPublicChannelsForTeam returns a list of public channels based on the provided team id string. func (c *Client4) GetPublicChannelsForTeam(teamId string, page int, perPage int, etag string) (*ChannelList, *Response) { query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage) - if r, err := c.DoApiGet(c.GetPublicChannelsForTeamRoute(teamId)+query, etag); err != nil { + if r, err := c.DoApiGet(c.GetChannelsForTeamRoute(teamId)+query, etag); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ChannelListFromJson(r.Body), BuildResponse(r) + } +} + +// GetPublicChannelsByIdsForTeam returns a list of public channels based on provided team id string +func (c *Client4) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) (*ChannelList, *Response) { + if r, err := c.DoApiPost(c.GetChannelsForTeamRoute(teamId)+"/ids", ArrayToJson(channelIds)); err != nil { return nil, &Response{StatusCode: r.StatusCode, Error: err} } else { defer closeBody(r) @@ -982,7 +992,7 @@ func (c *Client4) GetChannelsForTeamForUser(teamId, userId, etag string) (*Chann // SearchChannels returns the channels on a team matching the provided search term. func (c *Client4) SearchChannels(teamId string, search *ChannelSearch) (*ChannelList, *Response) { - if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/channels/search", search.ToJson()); err != nil { + if r, err := c.DoApiPost(c.GetChannelsForTeamRoute(teamId)+"/search", search.ToJson()); err != nil { return nil, &Response{StatusCode: r.StatusCode, Error: err} } else { defer closeBody(r) -- cgit v1.2.3-1-g7c22