Completed
Push — master ( cf3721...4140f8 )
by Luca
05:10
created

CommandModel::executeCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * This Driver is based entirely on official documentation of the Mattermost Web
4
 * Services API and you can extend it by following the directives of the documentation.
5
 *
6
 * God bless this mess.
7
 *
8
 * @author Luca Agnello <[email protected]>
9
 * @link https://api.mattermost.com/
10
 */
11
12
namespace Gnello\Mattermost\Models;
13
14
/**
15
 * Class CommandModel
16
 *
17
 * @package Gnello\MattermostRestApi\Models
18
 */
19
class CommandModel extends AbstractModel
20
{
21
    /**
22
     * @var string
23
     */
24
    private static $endpoint = '/commands';
25
26
    /**
27
     * @param array $requestOptions
28
     * @return \Psr\Http\Message\ResponseInterface
29
     */
30
    public function createCommand(array $requestOptions)
31
    {
32
        return $this->client->post(self::$endpoint, $requestOptions);
33
    }
34
35
    /**
36
     * @param array $requestOptions
37
     * @return \Psr\Http\Message\ResponseInterface
38
     */
39
    public function listCommandsForTeam(array $requestOptions)
40
    {
41
        return $this->client->get(self::$endpoint, $requestOptions);
42
    }
43
44
    /**
45
     * @param $teamId
46
     * @return \Psr\Http\Message\ResponseInterface
47
     */
48
    public function listAutocompleteCommands($teamId)
49
    {
50
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . '/commands/autocomplete');
51
    }
52
53
    /**
54
     * @param       $commandId
55
     * @param array $requestOptions
56
     * @return \Psr\Http\Message\ResponseInterface
57
     */
58
    public function updateCommand($commandId, array $requestOptions)
59
    {
60
        return $this->client->put(self::$endpoint . '/' . $commandId, $requestOptions);
61
    }
62
63
    /**
64
     * @param $commandId
65
     * @return \Psr\Http\Message\ResponseInterface
66
     */
67
    public function deleteCommand($commandId)
68
    {
69
        return $this->client->delete(self::$endpoint . '/' . $commandId);
70
    }
71
72
    /**
73
     * @param $commandId
74
     * @return \Psr\Http\Message\ResponseInterface
75
     */
76
    public function generateNewToken($commandId)
77
    {
78
        return $this->client->put(self::$endpoint . '/' . $commandId . '/regen_token');
79
    }
80
81
    /**
82
     * @param array $requestOptions
83
     * @return \Psr\Http\Message\ResponseInterface
84
     */
85
    public function executeCommand(array $requestOptions)
86
    {
87
        return $this->client->post(self::$endpoint . '/execute', $requestOptions);
88
    }
89
}
90