From dfc78e1b3929aceaa53d8c6364625b727446860b Mon Sep 17 00:00:00 2001 From: Kuzia Date: Mon, 6 Mar 2023 09:27:04 +0300 Subject: [PATCH 1/3] remove lockfile --- .gitignore | 3 +- composer.lock | 844 -------------------------------------------------- 2 files changed, 2 insertions(+), 845 deletions(-) delete mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index a725465..d1502b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -vendor/ \ No newline at end of file +vendor/ +composer.lock diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 97bb863..0000000 --- a/composer.lock +++ /dev/null @@ -1,844 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "7fbf00ea98eeea03f7d8dcd237f72067", - "packages": [ - { - "name": "guzzlehttp/guzzle", - "version": "7.4.5", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", - "reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.5", - "guzzlehttp/psr7": "^1.9 || ^2.4", - "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" - }, - "provide": { - "psr/http-client-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "ext-curl": "*", - "php-http/client-integration-tests": "^3.0", - "phpunit/phpunit": "^8.5.5 || ^9.3.5", - "psr/log": "^1.1 || ^2.0 || ^3.0" - }, - "suggest": { - "ext-curl": "Required for CURL handler support", - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.4-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "psr-18", - "psr-7", - "rest", - "web service" - ], - "support": { - "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.4.5" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", - "type": "tidelift" - } - ], - "time": "2022-06-20T22:16:13+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/fe752aedc9fd8fcca3fe7ad05d419d32998a06da", - "reference": "fe752aedc9fd8fcca3fe7ad05d419d32998a06da", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5-dev" - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "support": { - "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", - "type": "tidelift" - } - ], - "time": "2021-10-22T20:56:57+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "2.4.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "13388f00956b1503577598873fffb5ae994b5737" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/13388f00956b1503577598873fffb5ae994b5737", - "reference": "13388f00956b1503577598873fffb5ae994b5737", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.8 || ^9.3.10" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.4.0" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2022-06-20T21:43:11+00:00" - }, - { - "name": "pimple/pimple", - "version": "v3.2.3", - "source": { - "type": "git", - "url": "https://github.com/silexphp/Pimple.git", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", - "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/container": "^1.0" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "psr-0": { - "Pimple": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Pimple, a simple Dependency Injection Container", - "homepage": "http://pimple.sensiolabs.org", - "keywords": [ - "container", - "dependency injection" - ], - "time": "2018-01-21T07:42:36+00:00" - }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/http-client", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", - "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "support": { - "source": "https://github.com/php-fig/http-client/tree/master" - }, - "time": "2020-06-29T06:28:15+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory/tree/master" - }, - "time": "2019-04-30T12:38:16+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/master" - }, - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - } - ], - "packages-dev": [ - { - "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.11-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2019-02-06T07:57:58+00:00" - }, - { - "name": "symfony/var-dumper", - "version": "v3.4.30", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "b6a45abfe961183a4c26fad98a6112c487e983bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/b6a45abfe961183a4c26fad98a6112c487e983bf", - "reference": "b6a45abfe961183a4c26fad98a6112c487e983bf", - "shasum": "" - }, - "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-mbstring": "~1.0" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" - }, - "require-dev": { - "ext-iconv": "*", - "twig/twig": "~1.34|~2.4" - }, - "suggest": { - "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", - "ext-intl": "To show region name in time zone dump", - "ext-symfony_debug": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, - "autoload": { - "files": [ - "Resources/functions/dump.php" - ], - "psr-4": { - "Symfony\\Component\\VarDumper\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony mechanism for exploring and dumping PHP variables", - "homepage": "https://symfony.com", - "keywords": [ - "debug", - "dump" - ], - "time": "2019-07-26T11:29:23+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.5.0", - "ext-json": "*" - }, - "platform-dev": [], - "plugin-api-version": "2.3.0" -} From 03d7fc032636e97f18f899f08c9e1230f90104bd Mon Sep 17 00:00:00 2001 From: Kuzia Date: Mon, 6 Mar 2023 09:46:26 +0300 Subject: [PATCH 2/3] ref #50 decouple from pimple --- README.md | 85 ++++++++++++++++---------------------------------- composer.json | 1 - src/Client.php | 17 ++-------- src/Driver.php | 54 ++++++++++++++------------------ 4 files changed, 53 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index 907de25..da9e159 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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: @@ -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' ]); @@ -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) diff --git a/composer.json b/composer.json index 0891bb5..4bf328a 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/Client.php b/src/Client.php index 03f516d..1fdb00f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -20,7 +20,6 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\RequestOptions; use Psr\Http\Message\ResponseInterface; -use Pimple\Container; /** * Class Client @@ -44,20 +43,10 @@ class Client */ private $client; - /** - * Client constructor. - * - * @param Container $container - */ - public function __construct(Container $container) + /** @param array $options */ + public function __construct(GuzzleClient $guzzle, array $options) { - $guzzleOptions = []; - if (isset($container['guzzle'])) { - $guzzleOptions = $container['guzzle']; - } - $this->client = new GuzzleClient($guzzleOptions); - - $options = $container['driver']; + $this->client = $guzzle; $this->baseUri = $options['scheme'] . '://' . $options['url'] . $options['basePath']; } diff --git a/src/Driver.php b/src/Driver.php index a9e9bd5..fce12ad 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -38,8 +38,8 @@ use Gnello\Mattermost\Models\ThreadModel; use Gnello\Mattermost\Models\UserModel; use Gnello\Mattermost\Models\WebhookModel; +use GuzzleHttp\Client as Guzzle; use GuzzleHttp\Psr7\Response; -use Pimple\Container; use Psr\Http\Message\ResponseInterface; /** @@ -54,7 +54,7 @@ class Driver * * @var array */ - private $defaultOptions = [ + const DEFAULT_OPTIONS = [ 'scheme' => 'https', 'basePath' => '/api/v4', 'url' => 'localhost', @@ -63,33 +63,27 @@ class Driver 'token' => null, ]; - /** - * @var Container - */ - private $container; + /** @var array */ + private $driverOptions; + + /** @var Client */ + private $client; /** * @var array */ private $models = []; - /** - * Driver constructor. - * - * @param Container $container - */ - public function __construct(Container $container) + public function __construct( + Guzzle $guzzle, + array $driverOptions + ) { - $driverOptions = $this->defaultOptions; - - if (isset($container['driver'])) { - $driverOptions = array_merge($driverOptions, $container['driver']); - } - - $container['driver'] = $driverOptions; - $container['client'] = new Client($container); - - $this->container = $container; + $this->driverOptions = array_merge(self::DEFAULT_OPTIONS, $driverOptions); + $this->client = new Client( + $guzzle, + $this->driverOptions + ); } /** @@ -97,23 +91,21 @@ public function __construct(Container $container) */ public function authenticate() { - $driverOptions = $this->container['driver']; - - if (isset($driverOptions['token'])) { + if (isset($this->driverOptions['token'])) { - $this->container['client']->setToken($driverOptions['token']); + $this->client->setToken($this->driverOptions['token']); $response = $this->getUserModel()->getAuthenticatedUser(); - } else if (isset($driverOptions['login_id']) && isset($driverOptions['password'])) { + } else if (isset($this->driverOptions['login_id']) && isset($this->driverOptions['password'])) { $response = $this->getUserModel()->loginToUserAccount([ - 'login_id' => $driverOptions['login_id'], - 'password' => $driverOptions['password'] + 'login_id' => $this->driverOptions['login_id'], + 'password' => $this->driverOptions['password'] ]); if ($response->getStatusCode() == 200) { $token = $response->getHeader('Token')[0]; - $this->container['client']->setToken($token); + $this->client->setToken($token); } } else { @@ -138,7 +130,7 @@ public function authenticate() private function getModel($className) { if (!isset($this->models[$className])) { - $this->models[$className] = new $className($this->container['client']); + $this->models[$className] = new $className($this->client); } return $this->models[$className]; From 3058d2ff173d4434607bada1ca66d82c17a12849 Mon Sep 17 00:00:00 2001 From: Kuzia Date: Mon, 6 Mar 2023 11:06:27 +0300 Subject: [PATCH 3/3] switch from GuzzleHttp to psr 7/17/18 --- README.md | 63 +++-- composer.json | 18 +- src/Client.php | 319 +++++++++++++------------ src/Driver.php | 24 +- src/Models/BotModel.php | 4 +- src/Models/BrandModel.php | 4 +- src/Models/ChannelModel.php | 4 +- src/Models/EmojiModel.php | 4 +- src/Models/FileModel.php | 4 +- src/Models/IntegrationActionsModel.php | 1 - src/Models/JobModel.php | 4 +- src/Models/PluginModel.php | 4 +- src/Models/SAMLModel.php | 8 +- src/Models/SystemModel.php | 4 +- src/Models/TeamModel.php | 6 +- src/Models/UserModel.php | 6 +- 16 files changed, 268 insertions(+), 209 deletions(-) diff --git a/README.md b/README.md index da9e159..3ddfd1b 100644 --- a/README.md +++ b/README.md @@ -32,29 +32,55 @@ composer require gnello/php-mattermost-driver:1.* #### Login id and password ```php 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', -]); +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; + +// construct or discover your own PSR7 instances +/** @var ClientInterface */ +$httpClient = ...; +/** @var RequestFactoryInterface */ +$requestFactory = ...; +/** @var StreamFactoryInterface */ +$streamFactory = ...; + +$driver = new Driver( + $httpClient, + $requestFactory, + $streamFactory, + [ + 'url' => 'your_chat_url', + 'login_id' => 'your_login_id', + 'password' => 'your_password', + ] +); $result = $driver->authenticate(); ``` #### Token ```php - use \Gnello\Mattermost\Driver; - - // construct your own GuzzleHttp client instance -$guzzle = new GuzzleHttp/Client(...); - -$driver = new Driver($guzzle, [ - 'url' => 'your_chat_url', - 'token' => 'your_token', -]); +use \Gnello\Mattermost\Driver; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\StreamFactoryInterface; + +// construct or discover your own PSR7 instances +/** @var ClientInterface */ +$httpClient = ...; +/** @var RequestFactoryInterface */ +$requestFactory = ...; +/** @var StreamFactoryInterface */ +$streamFactory = ...; + +$driver = new Driver( + $httpClient, + $requestFactory, + $streamFactory, + [ + 'url' => 'your_chat_url', + 'token' => 'your_token', + ] +); $result = $driver->authenticate(); ``` @@ -198,4 +224,3 @@ Don't you see the endpoint you need? Feel free to open an issue or a PR! [10]: https://github.com/gnello/laravel-mattermost-driver [11]: https://poser.pugx.org/gnello/php-mattermost-driver/downloads [12]: https://packagist.org/packages/gnello/php-mattermost-driver -[13]: https://docs.guzzlephp.org/en/stable/request-options.html diff --git a/composer.json b/composer.json index 4bf328a..ded6998 100644 --- a/composer.json +++ b/composer.json @@ -17,15 +17,27 @@ "require": { "php": ">=5.5.0", "ext-json": "*", - "psr/http-message" : "^1.0", - "guzzlehttp/guzzle": "^6.2|^7.4" + "nyholm/psr7": "^1.5", + "psr/http-client": "^1.0", + "psr/http-client-implementation": "^1.0", + "psr/http-message": "^1.0", + "psr/http-message-implementation": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-factory-implementation": "^1.0", + "php-http/multipart-stream-builder": "^1.2" }, "require-dev": { - "symfony/var-dumper": "^3.1" + "symfony/var-dumper": "^3.1", + "guzzlehttp/guzzle": "^7.5" }, "autoload": { "psr-4": { "Gnello\\Mattermost\\": "src/" } + }, + "config": { + "allow-plugins": { + "php-http/discovery": true + } } } diff --git a/src/Client.php b/src/Client.php index 1fdb00f..a6913a1 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1,148 +1,171 @@ - - * @link https://api.mattermost.com/ - */ - -namespace Gnello\Mattermost; - -use GuzzleHttp\Client as GuzzleClient; -use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\Response; -use GuzzleHttp\RequestOptions; -use Psr\Http\Message\ResponseInterface; - -/** - * Class Client - * - * @package Gnello\Mattermost - */ -class Client -{ - /** - * @var string - */ - private $baseUri; - - /** - * @var array - */ - private $headers = []; - - /** - * @var GuzzleClient - */ - private $client; - - /** @param array $options */ - public function __construct(GuzzleClient $guzzle, array $options) - { - $this->client = $guzzle; - $this->baseUri = $options['scheme'] . '://' . $options['url'] . $options['basePath']; - } - - /** - * @param $token - */ - public function setToken($token) - { - $this->headers = ['Authorization' => 'Bearer ' . $token]; - } - - /** - * @param $uri - * @return string - */ - private function makeUri($uri) - { - return $this->baseUri . $uri; - } - - /** - * @param $options - * @param $type - * @return array - */ - private function buildOptions($options, $type) - { - return [ - RequestOptions::HEADERS => $this->headers, - $type => $options, - ]; - } - - /** - * @param $method - * @param $uri - * @param $type - * @param array $options - * @return ResponseInterface - */ - private function dispatch($method, $uri, $type, array $options = []) - { - try { - $response = $this->client->{$method}($this->makeUri($uri), $this->buildOptions($options, $type)); - } catch (RequestException $e) { - if ($e->hasResponse()) { - $response = $e->getResponse(); - } else { - $response = new Response(500, [], $e->getMessage()); - } - } - - return $response; - } - - /** - * @param $uri - * @param array $options - * @param string $type - * @return ResponseInterface - */ - public function get($uri, array $options = [], $type = RequestOptions::QUERY) - { - return $this->dispatch('get', $uri, $type, $options); - } - - /** - * @param $uri - * @param array $options - * @param string $type - * @return ResponseInterface - */ - public function post($uri, $options = [], $type = RequestOptions::JSON) - { - return $this->dispatch('post', $uri, $type, $options); - } - - /** - * @param $uri - * @param array $options - * @param string $type - * @return ResponseInterface - */ - public function put($uri, $options = [], $type = RequestOptions::JSON) - { - return $this->dispatch('put', $uri, $type, $options); - } - - /** - * @param $uri - * @param array $options - * @param string $type - * @return ResponseInterface - */ - public function delete($uri, $options = [], $type = RequestOptions::JSON) - { - return $this->dispatch('delete', $uri, $type, $options); - } -} + + * @link https://api.mattermost.com/ + */ + +namespace Gnello\Mattermost; + +use Http\Message\MultipartStream\MultipartStreamBuilder; +use Nyholm\Psr7\Uri; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamFactoryInterface; + +/** + * Class Client + * + * @package Gnello\Mattermost + */ +class Client +{ + const REQUEST_JSON = 'json'; + const REQUEST_QUERY = 'query'; + const REQUEST_MULTIPART = 'multipart'; + + /** @var string */ + private $baseUri; + + /** @var array */ + private $headers = []; + + /** @var ClientInterface */ + private $client; + + /** @var RequestFactoryInterface */ + private $requestFactory; + /** @var StreamFactoryInterface */ + private $streamFactory; + + /** @param array $options */ + public function __construct( + ClientInterface $client, + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory, + string $baseUrl + ) { + $this->client = $client; + $this->requestFactory = $requestFactory; + $this->streamFactory = $streamFactory; + $this->baseUri = $baseUrl; + } + + /** + * @param $token + */ + public function setToken($token) + { + $this->headers = ['Authorization' => 'Bearer ' . $token]; + } + + /** + * @param $uri + * @return string + */ + private function makeUri($uri) + { + return $this->baseUri . $uri; + } + + /** + * @param $method + * @param $uri + * @param $type + * @param array $options + * @return ResponseInterface + */ + private function dispatch(string $method, string $uri, string $type, array $options = []) + { + $method = strtoupper($method); + $request = $this->requestFactory->createRequest($method, $this->makeUri($uri)); + + foreach ($this->headers as $key => $value) { + $request = $request->withHeader($key, $value); + } + + switch ($type) { + case self::REQUEST_JSON: + $request = $request->withHeader('Content-Type', 'application/json'); + $request = $request->withBody($this->streamFactory->createStream((string) \json_encode($options, \JSON_THROW_ON_ERROR))); + break; + + case self::REQUEST_MULTIPART: + $builder = new MultipartStreamBuilder($this->streamFactory); + + foreach ($options as $value) { + $builder = $builder->addResource($value['name'], $value['contents'], isset($value['filename']) ? [ + 'filename' => $value['filename'], + ] : []); + } + + $request = $request->withBody($builder->build()); + $request = $request->withHeader('Content-type', 'multipart/form-data; boundary="' . $builder->getBoundary() . '"'); + break; + + case self::REQUEST_QUERY: + $request = $request->withUri(new Uri($this->makeUri($uri) . '?' . \http_build_query($options, '', '&', \PHP_QUERY_RFC3986))); + break; + + default: + throw new \RuntimeException("Unexpected type {$type}"); + } + + $response = $this->client->sendRequest($request); + + return $response; + } + + /** + * @param $uri + * @param array $options + * @param string $type + * @return ResponseInterface + */ + public function get($uri, array $options = [], $type = self::REQUEST_QUERY) + { + return $this->dispatch('get', $uri, $type, $options); + } + + /** + * @param $uri + * @param array $options + * @param string $type + * @return ResponseInterface + */ + public function post($uri, $options = [], $type = self::REQUEST_JSON) + { + return $this->dispatch('post', $uri, $type, $options); + } + + /** + * @param $uri + * @param array $options + * @param string $type + * @return ResponseInterface + */ + public function put($uri, $options = [], $type = self::REQUEST_JSON) + { + return $this->dispatch('put', $uri, $type, $options); + } + + /** + * @param $uri + * @param array $options + * @param string $type + * @return ResponseInterface + */ + public function delete($uri, $options = [], $type = self::REQUEST_JSON) + { + return $this->dispatch('delete', $uri, $type, $options); + } +} diff --git a/src/Driver.php b/src/Driver.php index fce12ad..e7aae22 100644 --- a/src/Driver.php +++ b/src/Driver.php @@ -38,9 +38,11 @@ use Gnello\Mattermost\Models\ThreadModel; use Gnello\Mattermost\Models\UserModel; use Gnello\Mattermost\Models\WebhookModel; -use GuzzleHttp\Client as Guzzle; -use GuzzleHttp\Psr7\Response; +use Nyholm\Psr7\Response; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamFactoryInterface; /** * Class Driver @@ -75,14 +77,17 @@ class Driver private $models = []; public function __construct( - Guzzle $guzzle, + ClientInterface $httpClient, + RequestFactoryInterface $requestFactory, + StreamFactoryInterface $streamFactory, array $driverOptions - ) - { + ) { $this->driverOptions = array_merge(self::DEFAULT_OPTIONS, $driverOptions); $this->client = new Client( - $guzzle, - $this->driverOptions + $httpClient, + $requestFactory, + $streamFactory, + $this->driverOptions['scheme'] . '://' . $this->driverOptions['url'] . $this->driverOptions['basePath'] ); } @@ -92,12 +97,9 @@ public function __construct( public function authenticate() { if (isset($this->driverOptions['token'])) { - $this->client->setToken($this->driverOptions['token']); $response = $this->getUserModel()->getAuthenticatedUser(); - } else if (isset($this->driverOptions['login_id']) && isset($this->driverOptions['password'])) { - $response = $this->getUserModel()->loginToUserAccount([ 'login_id' => $this->driverOptions['login_id'], 'password' => $this->driverOptions['password'] @@ -107,9 +109,7 @@ public function authenticate() $token = $response->getHeader('Token')[0]; $this->client->setToken($token); } - } else { - $response = new Response(401, [], json_encode([ "id" => "missing.credentials.", "message" => "You must provide a login_id and password or a valid token.", diff --git a/src/Models/BotModel.php b/src/Models/BotModel.php index f3081c1..e40351d 100644 --- a/src/Models/BotModel.php +++ b/src/Models/BotModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -109,7 +109,7 @@ public function setBotIcon($botUserId, array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['image']); - return $this->client->post(self::$endpoint . '/' . $botUserId . '/icon', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/' . $botUserId . '/icon', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/BrandModel.php b/src/Models/BrandModel.php index b1acc20..73530b6 100644 --- a/src/Models/BrandModel.php +++ b/src/Models/BrandModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -42,7 +42,7 @@ public function uploadBrandImage(array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['image']); - return $this->client->post(self::$endpoint . '/image', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/image', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/ChannelModel.php b/src/Models/ChannelModel.php index d59ba22..8d02553 100644 --- a/src/Models/ChannelModel.php +++ b/src/Models/ChannelModel.php @@ -15,7 +15,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -111,7 +111,7 @@ public function updateChannel($channelId, array $requestOptions) */ public function deleteChannel($channelId, array $requestOptions = []) { - return $this->client->delete(self::$endpoint . '/' . $channelId, $requestOptions, RequestOptions::QUERY); + return $this->client->delete(self::$endpoint . '/' . $channelId, $requestOptions, Client::REQUEST_QUERY); } /** diff --git a/src/Models/EmojiModel.php b/src/Models/EmojiModel.php index 1617fe5..7f12b36 100644 --- a/src/Models/EmojiModel.php +++ b/src/Models/EmojiModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -34,7 +34,7 @@ public function createCustomEmoji(array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['image', 'emoji']); - return $this->client->post(self::$endpoint, $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint, $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/FileModel.php b/src/Models/FileModel.php index 20eaaf4..5fe1ba8 100644 --- a/src/Models/FileModel.php +++ b/src/Models/FileModel.php @@ -15,7 +15,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -55,7 +55,7 @@ public function uploadFile(array $requestOptions) ]; } - return $this->client->post(self::$endpoint, $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint, $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/IntegrationActionsModel.php b/src/Models/IntegrationActionsModel.php index ac682db..553d939 100644 --- a/src/Models/IntegrationActionsModel.php +++ b/src/Models/IntegrationActionsModel.php @@ -11,7 +11,6 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; use Psr\Http\Message\ResponseInterface; /** diff --git a/src/Models/JobModel.php b/src/Models/JobModel.php index 33ddeda..272ce9b 100644 --- a/src/Models/JobModel.php +++ b/src/Models/JobModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -32,7 +32,7 @@ class JobModel extends AbstractModel */ public function getJobs(array $requestOptions = []) { - return $this->client->get(self::$endpoint, $requestOptions, RequestOptions::QUERY); + return $this->client->get(self::$endpoint, $requestOptions, Client::REQUEST_QUERY); } /** diff --git a/src/Models/PluginModel.php b/src/Models/PluginModel.php index 34dfa46..46222c3 100644 --- a/src/Models/PluginModel.php +++ b/src/Models/PluginModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -34,7 +34,7 @@ public function uploadPlugin(array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['plugin']); - return $this->client->post(self::$endpoint, $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint, $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/SAMLModel.php b/src/Models/SAMLModel.php index 26b18cf..fa38923 100644 --- a/src/Models/SAMLModel.php +++ b/src/Models/SAMLModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -42,7 +42,7 @@ public function uploadIDPCertificate(array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['certificate']); - return $this->client->post(self::$endpoint . '/certificate/idp', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/certificate/idp', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** @@ -61,7 +61,7 @@ public function uploadPublicCertificate(array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['certificate']); - return $this->client->post(self::$endpoint . '/certificate/public', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/certificate/public', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** @@ -80,7 +80,7 @@ public function uploadPrivateCertificate(array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['certificate']); - return $this->client->post(self::$endpoint . '/certificate/private', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/certificate/private', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/SystemModel.php b/src/Models/SystemModel.php index 84e1fa7..e309a0c 100644 --- a/src/Models/SystemModel.php +++ b/src/Models/SystemModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -128,7 +128,7 @@ public function uploadLicenseFile(array $requestOptions) $customEndpoint = '/license'; $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['license']); - return $this->client->post($customEndpoint, $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post($customEndpoint, $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/TeamModel.php b/src/Models/TeamModel.php index 552f3ca..6ffbe38 100644 --- a/src/Models/TeamModel.php +++ b/src/Models/TeamModel.php @@ -15,7 +15,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -256,7 +256,7 @@ public function setTeamIcon($teamId, array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['image']); - return $this->client->post(self::$endpoint . '/' . $teamId . '/image', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/' . $teamId . '/image', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** @@ -347,7 +347,7 @@ public function importTeamFromOtherApplication($teamId, array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['file', 'filesize', 'importFrom']); - return $this->client->post(self::$endpoint . '/' . $teamId . '/import', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/' . $teamId . '/import', $internalRequestOptions, Client::REQUEST_MULTIPART); } /** diff --git a/src/Models/UserModel.php b/src/Models/UserModel.php index a843a7c..9fee8f6 100644 --- a/src/Models/UserModel.php +++ b/src/Models/UserModel.php @@ -11,7 +11,7 @@ namespace Gnello\Mattermost\Models; -use GuzzleHttp\RequestOptions; +use Gnello\Mattermost\Client; use Psr\Http\Message\ResponseInterface; /** @@ -131,7 +131,7 @@ public function updateUser($userId, array $requestOptions) */ public function deactivateUserAccount($userId, array $requestOptions = []) { - return $this->client->delete(self::$endpoint . '/' . $userId, $requestOptions, RequestOptions::QUERY); + return $this->client->delete(self::$endpoint . '/' . $userId, $requestOptions, Client::REQUEST_QUERY); } /** @@ -182,7 +182,7 @@ public function setUserProfileImage($userId, array $requestOptions) { $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['image']); - return $this->client->post(self::$endpoint . '/' . $userId . '/image', $internalRequestOptions, RequestOptions::MULTIPART); + return $this->client->post(self::$endpoint . '/' . $userId . '/image', $internalRequestOptions, Client::REQUEST_MULTIPART); } /**