summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-02 09:04:36 -0500
committerGitHub <noreply@github.com>2017-02-02 09:04:36 -0500
commit609d4f43d9eef504d852fbf02af5473b0d1424c8 (patch)
tree63fe24f08d5364501d3afed7c44b6739719d86e3 /model
parent2ac4f36587b8b217dcfd53e67c650c8ad27c75df (diff)
downloadchat-609d4f43d9eef504d852fbf02af5473b0d1424c8.tar.gz
chat-609d4f43d9eef504d852fbf02af5473b0d1424c8.tar.bz2
chat-609d4f43d9eef504d852fbf02af5473b0d1424c8.zip
Implement POST /channels endpoint for APIv4 (#5241)
Diffstat (limited to 'model')
-rw-r--r--model/client4.go19
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..