implement POST /commands for apiv4 (#5849)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
42c3ea64a9
Коммит
6935e2d5ea
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user