summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-04-08 02:06:09 +0900
committerCorey Hulen <corey@hulen.com>2017-04-07 10:06:09 -0700
commita3f5cffd4693446eecdc6f88ed336a4c35c1e708 (patch)
tree3c2a1987e308f07df65f81d85a8a19ebf34cbdba /model
parentf7b39caf318cf0839c7889d615cbc3ab16c285b2 (diff)
downloadchat-a3f5cffd4693446eecdc6f88ed336a4c35c1e708.tar.gz
chat-a3f5cffd4693446eecdc6f88ed336a4c35c1e708.tar.bz2
chat-a3f5cffd4693446eecdc6f88ed336a4c35c1e708.zip
APIv4 PUT /commands/{command_id} (#5999)
* APIv4 PUT /commands/{command_id} * update client parameter and api4 test
Diffstat (limited to 'model')
-rw-r--r--model/client4.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index e2f609589..634c477e2 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -226,6 +226,10 @@ func (c *Client4) GetCommandsRoute() string {
return fmt.Sprintf("/commands")
}
+func (c *Client4) GetCommandRoute(commandId string) string {
+ return fmt.Sprintf(c.GetCommandsRoute()+"/%v", commandId)
+}
+
func (c *Client4) GetEmojisRoute() string {
return fmt.Sprintf("/emoji")
}
@@ -2188,6 +2192,16 @@ func (c *Client4) CreateCommand(cmd *Command) (*Command, *Response) {
}
}
+// UpdateCommand updates a command based on the provided Command struct
+func (c *Client4) UpdateCommand(cmd *Command) (*Command, *Response) {
+ if r, err := c.DoApiPut(c.GetCommandRoute(cmd.Id), cmd.ToJson()); err != nil {
+ return nil, &Response{StatusCode: r.StatusCode, Error: err}
+ } else {
+ defer closeBody(r)
+ return CommandFromJson(r.Body), BuildResponse(r)
+ }
+}
+
// ListCommands will retrieve a list of commands available in the team.
func (c *Client4) ListCommands(teamId string, customOnly bool) ([]*Command, *Response) {
query := fmt.Sprintf("?team_id=%v&custom_only=%v", teamId, customOnly)