Skip to content

#50: remove pimple/pimple container #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
vendor/
vendor/
composer.lock
85 changes: 27 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Stable Version][7]][8] [![Scrutinizer Code Quality][5]][6] [![Total Downloads][11]][12]

The PHP Driver to interact with the [Mattermost Web Service API][4].
The PHP Driver to interact with the [Mattermost Web Service API][4].

Please read [the api documentation][1] for further information on using this application.

Expand Down Expand Up @@ -31,64 +31,33 @@ composer require gnello/php-mattermost-driver:1.*

#### Login id and password
```php
use \Gnello\Mattermost\Driver;

$container = new \Pimple\Container([
'driver' => [
'url' => 'your_chat_url',
'login_id' => 'your_login_id',
'password' => 'your_password',
]
]);

$driver = new Driver($container);
$result = $driver->authenticate();
```
use \Gnello\Mattermost\Driver;

// construct your own GuzzleHttp client instance
$guzzle = new GuzzleHttp/Client(...);

$driver = new Driver($guzzle, [
'url' => 'your_chat_url',
'login_id' => 'your_login_id',
'password' => 'your_password',
]);
$result = $driver->authenticate();
```

#### Token
```php
use \Gnello\Mattermost\Driver;

$container = new \Pimple\Container([
'driver' => [
'url' => 'your_chat_url',
'token' => 'your_token',
]
]);

$driver = new Driver($container);
$result = $driver->authenticate();
```

### Options
Below a list of all the Driver available options, for the Guzzle options
please refer to its [official documentation][13].

| Option | Default value | Description |
|:---------|:--------------|:-------------------------------------------------------------------------------------------|
| scheme | "https" | The URI scheme. |
| basePath | "/api/v4" | The base path of the API endpoint. |
| url | "localhost" | The URL of the Mattermost server, without the scheme (es. "www.mydomain.com"). |
| login_id | null | The account username to use with the API. |
| password | null | The account password to use with the API. |
| token | null | The account token to use with the API, if specified it override the login_id and password. |

You can specify the options as shown in the following example:
```php
use \Gnello\Mattermost\Driver;

$container = new \Pimple\Container([
'driver' => [
//put here any options for the driver
],
'guzzle' => [
//put here any options for Guzzle
]
]);

$driver = new Driver($container);
$result = $driver->authenticate();
```

// construct your own GuzzleHttp client instance
$guzzle = new GuzzleHttp/Client(...);

$driver = new Driver($guzzle, [
'url' => 'your_chat_url',
'token' => 'your_token',
]);

$result = $driver->authenticate();
```

### Check results
This Driver follows the [PSR-7][2] document therefore any response is a ResponseInterface type:
Expand All @@ -106,8 +75,8 @@ if ($result->getStatusCode() == 200) {
```php
//Add a new user
$result = $driver->getUserModel()->createUser([
'email' => 'test@test.com',
'username' => 'test',
'email' => 'test@test.com',
'username' => 'test',
'password' => 'testpsw'
]);

Expand Down Expand Up @@ -180,7 +149,7 @@ $result = $driver->getPreferenceModel('user_id')->getUserPreference();
//Please read the PreferenceModel class or refer to the api documentation for a complete list of available methods.
```

## Endpoints supported
## Endpoints supported

- [Bleve](https://api.mattermost.com/#tag/bleve)
- [Bots](https://api.mattermost.com/#tag/bots)
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"php": ">=5.5.0",
"ext-json": "*",
"psr/http-message" : "^1.0",
"pimple/pimple" : "~3.0",
"guzzlehttp/guzzle": "^6.2|^7.4"
},
"require-dev": {
Expand Down
Loading