From a3f5cffd4693446eecdc6f88ed336a4c35c1e708 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Sat, 8 Apr 2017 02:06:09 +0900 Subject: APIv4 PUT /commands/{command_id} (#5999) * APIv4 PUT /commands/{command_id} * update client parameter and api4 test --- model/client4.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'model/client4.go') 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) -- cgit v1.2.3-1-g7c22