| @@ 19-89 (lines=71) @@ | ||
| 16 | * |
|
| 17 | * @package Gnello\MattermostRestApi\Models |
|
| 18 | */ |
|
| 19 | class OAuthModel extends AbstractModel |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | private static $endpoint = '/oauth'; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param array $requestOptions |
|
| 28 | * @return \Psr\Http\Message\ResponseInterface |
|
| 29 | */ |
|
| 30 | public function registerOAuthApp(array $requestOptions) |
|
| 31 | { |
|
| 32 | return $this->client->post(self::$endpoint . '/apps', $requestOptions); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param array $requestOptions |
|
| 37 | * @return \Psr\Http\Message\ResponseInterface |
|
| 38 | */ |
|
| 39 | public function getOAuthApps(array $requestOptions) |
|
| 40 | { |
|
| 41 | return $this->client->get(self::$endpoint . '/apps', $requestOptions); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @param $appId |
|
| 46 | * @return \Psr\Http\Message\ResponseInterface |
|
| 47 | */ |
|
| 48 | public function getOAuthApp($appId) |
|
| 49 | { |
|
| 50 | return $this->client->get(self::$endpoint . '/apps/' . $appId); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @param $appId |
|
| 55 | * @return \Psr\Http\Message\ResponseInterface |
|
| 56 | */ |
|
| 57 | public function deleteOAuthApp($appId) |
|
| 58 | { |
|
| 59 | return $this->client->delete(self::$endpoint . '/apps/' . $appId); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @param $appId |
|
| 64 | * @return \Psr\Http\Message\ResponseInterface |
|
| 65 | */ |
|
| 66 | public function regenerateOAuthAppSecret($appId) |
|
| 67 | { |
|
| 68 | return $this->client->post(self::$endpoint . '/apps/' . $appId . '/regen_secret'); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @param $appId |
|
| 73 | * @return \Psr\Http\Message\ResponseInterface |
|
| 74 | */ |
|
| 75 | public function getOAuthAppInfo($appId) |
|
| 76 | { |
|
| 77 | return $this->client->get(self::$endpoint . '/apps/' . $appId . '/info'); |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * @param $userId |
|
| 82 | * @param array $requestOptions |
|
| 83 | * @return \Psr\Http\Message\ResponseInterface |
|
| 84 | */ |
|
| 85 | public function getAuthorizedOAuthApps($userId, array $requestOptions) |
|
| 86 | { |
|
| 87 | return $this->client->get(UserModel::$endpoint . '/' . $userId . '/oauth/apps/authorized', $requestOptions); |
|
| 88 | } |
|
| 89 | } |
|
| 90 | ||
| @@ 19-90 (lines=72) @@ | ||
| 16 | * |
|
| 17 | * @package Gnello\Mattermost\Models |
|
| 18 | */ |
|
| 19 | class SchemeModel extends AbstractModel |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @var string |
|
| 23 | */ |
|
| 24 | private static $endpoint = '/schemes'; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @return \Psr\Http\Message\ResponseInterface |
|
| 28 | */ |
|
| 29 | public function getSchemes() |
|
| 30 | { |
|
| 31 | return $this->client->get(self::$endpoint); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param array $requestOptions |
|
| 36 | * @return \Psr\Http\Message\ResponseInterface |
|
| 37 | */ |
|
| 38 | public function createScheme(array $requestOptions) |
|
| 39 | { |
|
| 40 | return $this->client->post(self::$endpoint, $requestOptions); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @param $schemeId |
|
| 45 | * @return \Psr\Http\Message\ResponseInterface |
|
| 46 | */ |
|
| 47 | public function getScheme($schemeId) |
|
| 48 | { |
|
| 49 | return $this->client->get(self::$endpoint . '/' . $schemeId); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param $schemeId |
|
| 54 | * @return \Psr\Http\Message\ResponseInterface |
|
| 55 | */ |
|
| 56 | public function deleteScheme($schemeId) |
|
| 57 | { |
|
| 58 | return $this->client->delete(self::$endpoint . '/' . $schemeId); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @param $schemeId |
|
| 63 | * @param array $requestOptions |
|
| 64 | * @return \Psr\Http\Message\ResponseInterface |
|
| 65 | */ |
|
| 66 | public function patchScheme($schemeId, array $requestOptions) |
|
| 67 | { |
|
| 68 | return $this->client->put(self::$endpoint . '/' . $schemeId . '/patch', $requestOptions); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * @param $schemeId |
|
| 73 | * @param array $requestOptions |
|
| 74 | * @return \Psr\Http\Message\ResponseInterface |
|
| 75 | */ |
|
| 76 | public function getTeamsOfScheme($schemeId, array $requestOptions) |
|
| 77 | { |
|
| 78 | return $this->client->get(self::$endpoint . '/' . $schemeId . '/teams', $requestOptions); |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @param $schemeId |
|
| 83 | * @param array $requestOptions |
|
| 84 | * @return \Psr\Http\Message\ResponseInterface |
|
| 85 | */ |
|
| 86 | public function getChannelsOfScheme($schemeId, array $requestOptions) |
|
| 87 | { |
|
| 88 | return $this->client->get(self::$endpoint . '/' . $schemeId . '/channels', $requestOptions); |
|
| 89 | } |
|
| 90 | } |
|
| 91 | ||