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
|
|
|
use Gnello\Mattermost\Client; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class PluginModel |
18
|
|
|
* |
19
|
|
|
* @package Gnello\Mattermost\Models |
20
|
|
|
*/ |
21
|
|
|
class PluginModel extends AbstractModel |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private static $endpoint = '/plugins'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param array $requestOptions |
30
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
31
|
|
|
*/ |
32
|
|
|
public function uploadPlugin(array $requestOptions) |
33
|
|
|
{ |
34
|
|
|
return $this->client->post(self::$endpoint, $requestOptions, Client::TYPE_MULTIPART); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
39
|
|
|
*/ |
40
|
|
|
public function getPlugins() |
41
|
|
|
{ |
42
|
|
|
return $this->client->get(self::$endpoint); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param $pluginId |
47
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
48
|
|
|
*/ |
49
|
|
|
public function removePlugin($pluginId) |
50
|
|
|
{ |
51
|
|
|
return $this->client->delete(self::$endpoint . '/' . $pluginId); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param $pluginId |
56
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
57
|
|
|
*/ |
58
|
|
|
public function activePlugin($pluginId) |
59
|
|
|
{ |
60
|
|
|
return $this->client->post(self::$endpoint . '/' . $pluginId . '/activate'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param $pluginId |
65
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
66
|
|
|
*/ |
67
|
|
|
public function deactivePlugin($pluginId) |
68
|
|
|
{ |
69
|
|
|
return $this->client->post(self::$endpoint . '/' . $pluginId . '/deactivate'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
74
|
|
|
*/ |
75
|
|
|
public function getWebappPlugins() |
76
|
|
|
{ |
77
|
|
|
return $this->client->get(self::$endpoint . '/webapp'); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|