diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index 808ce74e3..43787cf08 100644 --- a/model/client4.go +++ b/model/client4.go @@ -98,6 +98,10 @@ func (c *Client4) GetChannelsRoute() string { return fmt.Sprintf("/channels") } +func (c *Client4) GetPublicChannelsForTeamRoute(teamId string) string { + return fmt.Sprintf(c.GetTeamRoute(teamId) + "/channels") +} + func (c *Client4) GetChannelRoute(channelId string) string { return fmt.Sprintf(c.GetChannelsRoute()+"/%v", channelId) } @@ -706,6 +710,17 @@ func (c *Client4) GetChannel(channelId, etag string) (*Channel, *Response) { } } +// GetPublicChannelsForTeam returns a channel 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 { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ChannelListFromJson(r.Body), BuildResponse(r) + } +} + // GetChannelByName returns a channel based on the provided channel name and team id strings. func (c *Client4) GetChannelByName(channelName, teamId string, etag string) (*Channel, *Response) { if r, err := c.DoApiGet(c.GetChannelByNameRoute(channelName, teamId), etag); err != nil { |