summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-03-24 00:42:32 +0100
committerJoram Wilander <jwawilander@gmail.com>2017-03-23 19:42:32 -0400
commit6935e2d5ea73d34f0f383715fd161059eff74608 (patch)
treeb57173a5616bc06413305ebf553e8c0b11881c3f /model/client4.go
parent42c3ea64a9e2e75193d35939bbca34adfbd5ddf9 (diff)
downloadchat-6935e2d5ea73d34f0f383715fd161059eff74608.tar.gz
chat-6935e2d5ea73d34f0f383715fd161059eff74608.tar.bz2
chat-6935e2d5ea73d34f0f383715fd161059eff74608.zip
implement POST /commands for apiv4 (#5849)
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index ae20d5293..c74d76e04 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -202,6 +202,10 @@ func (c *Client4) GetBrandRoute() string {
return fmt.Sprintf("/brand")
}
+func (c *Client4) GetCommandsRoute() string {
+ return fmt.Sprintf("/commands")
+}
+
func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
return c.DoApiRequest(http.MethodGet, url, "", etag)
}
@@ -1716,3 +1720,15 @@ func (c *Client4) GetLogs(page, perPage int) ([]string, *Response) {
return ArrayFromJson(r.Body), BuildResponse(r)
}
}
+
+// Commands Section
+
+// CreateCommand will create a new command if the user have the right permissions.
+func (c *Client4) CreateCommand(cmd *Command) (*Command, *Response) {
+ if r, err := c.DoApiPost(c.GetCommandsRoute(), cmd.ToJson()); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return CommandFromJson(r.Body), BuildResponse(r)
+ }
+}