diff options
Diffstat (limited to 'model')
-rw-r--r-- | model/client4.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/model/client4.go b/model/client4.go index f0adfd382..c82f5ce0e 100644 --- a/model/client4.go +++ b/model/client4.go @@ -60,6 +60,14 @@ func (c *Client4) GetTeamsRoute() string { return fmt.Sprintf("/teams") } +func (c *Client4) GetChannelsRoute() string { + return fmt.Sprintf("/channels") +} + +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) } @@ -236,7 +244,16 @@ func (c *Client4) CreateTeam(team *Team) (*Team, *Response) { } // Channel Section -// to be filled in.. + +// CreateChannel creates a channel based on the provided channel struct. +func (c *Client4) CreateChannel(channel *Channel) (*Channel, *Response) { + if r, err := c.DoApiPost(c.GetChannelsRoute(), channel.ToJson()); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return ChannelFromJson(r.Body), BuildResponse(r) + } +} // Post Section // to be filled in.. |