22
33[ ![ Latest Stable Version] [ 7 ]] [ 8 ] [ ![ Scrutinizer Code Quality] [ 5 ]] [ 6 ] [ ![ Total Downloads] [ 11 ]] [ 12 ]
44
5- The PHP Driver to interact with the [ Mattermost Web Service API] [ 4 ] .
5+ The PHP Driver to interact with the [ Mattermost Web Service API] [ 4 ] .
66
77Please read [ the api documentation] [ 1 ] for further information on using this application.
88
@@ -31,64 +31,33 @@ composer require gnello/php-mattermost-driver:1.*
3131
3232#### Login id and password
3333``` php
34- use \Gnello\Mattermost\Driver;
35-
36- $container = new \Pimple\Container([
37- 'driver' => [
38- 'url' => 'your_chat_url',
39- 'login_id' => 'your_login_id',
40- 'password' => 'your_password',
41- ]
42- ]);
43-
44- $driver = new Driver($container);
45- $result = $driver->authenticate();
46- ```
34+ use \Gnello\Mattermost\Driver;
35+
36+ // construct your own GuzzleHttp client instance
37+ $guzzle = new GuzzleHttp/Client(...);
38+
39+ $driver = new Driver($guzzle, [
40+ 'url' => 'your_chat_url',
41+ 'login_id' => 'your_login_id',
42+ 'password' => 'your_password',
43+ ]);
44+ $result = $driver->authenticate();
45+ ```
4746
4847#### Token
4948``` php
5049 use \Gnello\Mattermost\Driver;
51-
52- $container = new \Pimple\Container([
53- 'driver' => [
54- 'url' => 'your_chat_url',
55- 'token' => 'your_token',
56- ]
57- ]);
58-
59- $driver = new Driver($container);
60- $result = $driver->authenticate();
61- ```
62-
63- ### Options
64- Below a list of all the Driver available options, for the Guzzle options
65- please refer to its [ official documentation] [ 13 ] .
66-
67- | Option | Default value | Description |
68- | :---------| :--------------| :-------------------------------------------------------------------------------------------|
69- | scheme | "https" | The URI scheme. |
70- | basePath | "/api/v4" | The base path of the API endpoint. |
71- | url | "localhost" | The URL of the Mattermost server, without the scheme (es. "www.mydomain.com"). |
72- | login_id | null | The account username to use with the API. |
73- | password | null | The account password to use with the API. |
74- | token | null | The account token to use with the API, if specified it override the login_id and password. |
75-
76- You can specify the options as shown in the following example:
77- ``` php
78- use \Gnello\Mattermost\Driver;
79-
80- $container = new \Pimple\Container([
81- 'driver' => [
82- //put here any options for the driver
83- ],
84- 'guzzle' => [
85- //put here any options for Guzzle
86- ]
87- ]);
88-
89- $driver = new Driver($container);
90- $result = $driver->authenticate();
91- ```
50+
51+ // construct your own GuzzleHttp client instance
52+ $guzzle = new GuzzleHttp/Client(...);
53+
54+ $driver = new Driver($guzzle, [
55+ 'url' => 'your_chat_url',
56+ 'token' => 'your_token',
57+ ]);
58+
59+ $result = $driver->authenticate();
60+ ```
9261
9362### Check results
9463This Driver follows the [ PSR-7] [ 2 ] document therefore any response is a ResponseInterface type:
@@ -106,8 +75,8 @@ if ($result->getStatusCode() == 200) {
10675``` php
10776//Add a new user
10877$result = $driver->getUserModel()->createUser([
109- 'email' => 'test@test.com',
110- 'username' => 'test',
78+ 'email' => 'test@test.com',
79+ 'username' => 'test',
11180 'password' => 'testpsw'
11281]);
11382
@@ -180,7 +149,7 @@ $result = $driver->getPreferenceModel('user_id')->getUserPreference();
180149//Please read the PreferenceModel class or refer to the api documentation for a complete list of available methods.
181150```
182151
183- ## Endpoints supported
152+ ## Endpoints supported
184153
185154- [ Bleve] ( https://api.mattermost.com/#tag/bleve )
186155- [ Bots] ( https://api.mattermost.com/#tag/bots )
0 commit comments