summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/client4.go')
-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)