2
2
3
3
[ ![ Latest Stable Version] [ 7 ]] [ 8 ] [ ![ Scrutinizer Code Quality] [ 5 ]] [ 6 ] [ ![ Total Downloads] [ 11 ]] [ 12 ]
4
4
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 ] .
6
6
7
7
Please read [ the api documentation] [ 1 ] for further information on using this application.
8
8
@@ -31,64 +31,33 @@ composer require gnello/php-mattermost-driver:1.*
31
31
32
32
#### Login id and password
33
33
``` 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
+ ```
47
46
48
47
#### Token
49
48
``` php
50
49
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
+ ```
92
61
93
62
### Check results
94
63
This Driver follows the [ PSR-7] [ 2 ] document therefore any response is a ResponseInterface type:
@@ -106,8 +75,8 @@ if ($result->getStatusCode() == 200) {
106
75
``` php
107
76
//Add a new user
108
77
$result = $driver->getUserModel()->createUser([
109
-
110
- 'username' => 'test',
78
+
79
+ 'username' => 'test',
111
80
'password' => 'testpsw'
112
81
]);
113
82
@@ -180,7 +149,7 @@ $result = $driver->getPreferenceModel('user_id')->getUserPreference();
180
149
//Please read the PreferenceModel class or refer to the api documentation for a complete list of available methods.
181
150
```
182
151
183
- ## Endpoints supported
152
+ ## Endpoints supported
184
153
185
154
- [ Bleve] ( https://api.mattermost.com/#tag/bleve )
186
155
- [ Bots] ( https://api.mattermost.com/#tag/bots )
0 commit comments