implement POST /commands for apiv4 (#5849)

Этот коммит содержится в:
Carlos Tadeu Panato Junior
2017-03-24 00:42:32 +01:00
коммит произвёл Joram Wilander
родитель 42c3ea64a9
Коммит 6935e2d5ea
4 изменённых файлов: 122 добавлений и 0 удалений

Просмотреть файл

@@ -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)
}
}