From 0e007e344bf10993529711f14c4168365c3504c3 Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Thu, 27 Apr 2017 22:41:52 +0900 Subject: APIv4 POST /commands/execute (#6205) --- model/client4.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index 2a7338809..a33e62846 100644 --- a/model/client4.go +++ b/model/client4.go @@ -2389,6 +2389,17 @@ func (c *Client4) ListCommands(teamId string, customOnly bool) ([]*Command, *Res } } +// ExecuteCommand executes a given command. +func (c *Client4) ExecuteCommand(channelId, command string) (*CommandResponse, *Response) { + commandArgs := &CommandArgs{ChannelId: channelId, Command: command} + if r, err := c.DoApiPost(c.GetCommandsRoute()+"/execute", commandArgs.ToJson()); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return CommandResponseFromJson(r.Body), BuildResponse(r) + } +} + // ListCommands will retrieve a list of commands available in the team. func (c *Client4) ListAutocompleteCommands(teamId string) ([]*Command, *Response) { if r, err := c.DoApiGet(c.GetTeamAutoCompleteCommandsRoute(teamId), ""); err != nil { -- cgit v1.2.3-1-g7c22