diff --git a/README.md b/README.md index a68d924..775b65c 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # php-mattermost-driver (v3.7.0) -Completed Php Driver to interact with the [Mattermost Web Service API][4]. +Completed Php Driver to interact with the [Mattermost Web Service API][4]. +Version of the Mattermost server required: 3.7.0 -Version of the Mattermost server required: 3.7.0 Please read [the api documentation][1] for further information on using this application. ## Installation @@ -31,13 +31,7 @@ Read more about how to install and use Composer on your local machine [here][3]. ]); $driver = new Driver($container); - $login = $driver->authenticate(); - - if ($login) { - echo "SUCCESS!"; - } else { - echo "SOMETHING WENT WRONG."; - } + $result = $driver->authenticate(); ``` ### Check results @@ -63,7 +57,7 @@ $requestOptions = [ $result = $driver->getUserModel()->createUser($requestOptions); //Get a user -$res = $driver->getUserModel()->getUserByUsername('username'); +$result = $driver->getUserModel()->getUserByUsername('username'); ``` ### Team data model @@ -83,4 +77,4 @@ In Development, coming soon! [1]: https://api.mattermost.com/ [2]: http://www.php-fig.org/psr/psr-7/ [3]: https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx -[4]: https://about.mattermost.com/ +[4]: https://about.mattermost.com/ \ No newline at end of file diff --git a/src/Driver.php b/src/Driver.php index 78ce48e..a50af3a 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -62,7 +62,7 @@ public function __construct(Container $container) } /** - * @return bool + * @return null|\Psr\Http\Message\ResponseInterface */ public function authenticate() { @@ -75,16 +75,13 @@ public function authenticate() /** @var Client $client */ $client = $this->container['client']; $response = $client->post('/users/login', $options); - $statusCode = $response->getStatusCode(); - if ($statusCode == 200) { + if ($response->getStatusCode() == 200) { $token = $response->getHeader('Token')[0]; $client->setToken($token); - - return true; } - return false; + return $response; } /**