From 9312469ad54cf2ff268a44e478b584549f62e2c4 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 3 Feb 2017 10:27:12 -0500 Subject: Implement POST /channels/direct endpoint for APIv4 (#5283) --- model/client4.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index fb314e26d..6ea0398d0 100644 --- a/model/client4.go +++ b/model/client4.go @@ -265,5 +265,17 @@ func (c *Client4) CreateChannel(channel *Channel) (*Channel, *Response) { } } +// CreateDirectChannel creates a direct message channel based on the two user +// ids provided. +func (c *Client4) CreateDirectChannel(userId1, userId2 string) (*Channel, *Response) { + requestBody := []string{userId1, userId2} + if r, err := c.DoApiPost(c.GetChannelsRoute()+"/direct", ArrayToJson(requestBody)); 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.. -- cgit v1.2.3-1-g7c22