baywa-re-lusy / users-api-sdk
BayWa r.e. LUSY Users API SDK
4.1.0
2024-11-08 16:09 UTC
Requires
- php: >= 8.2
- ext-curl: *
- baywa-re-lusy/user-subsidiary-model: ^1.0
- laminas/laminas-diactoros: ^3.3
- laminas/laminas-hydrator: ^4.15
- laminas/laminas-permissions-acl: ^2.16
- laminas/laminas-validator: ^2.0
- psr/cache: ^1.0
- psr/http-client: ^1.0
- psr/http-message: ^2.0
- psr/log: ^3.0
- symfony/console: ^6.2
Requires (Dev)
- behat/behat: ^3.14
- guzzlehttp/guzzle: ^7.5
- mockery/mockery: ^1.6
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^10.0
- ramsey/uuid: ^4.7
- squizlabs/php_codesniffer: ^3.7
README
This SDK can be used to retrieve Users and Subsidiaries.
All dependencies injected into the constructor are PSR-compatible:
- Cache : https://www.php-fig.org/psr/psr-6/
- HTTP Client : https://www.php-fig.org/psr/psr-18/
- HTTP Messages : https://www.php-fig.org/psr/psr-7/
- Logger : https://www.php-fig.org/psr/psr-3/
Installation
composer require baywa-re-lusy/users-api-sdk
Usage
use Laminas\Cache\Storage\Adapter\Apcu; $tokenCache = new \Laminas\Cache\Psr\CacheItemPool\CacheItemPoolDecorator(new Apcu()); $resultCache = new \Laminas\Cache\Psr\CacheItemPool\CacheItemPoolDecorator(new Apcu()); $httpClient = new \GuzzleHttp\Client(); $usersApiClient = new \BayWaReLusy\UsersAPI\SDK\UsersApiClient( "<URL to Users API>", "<URL to Token API Endpoint>", "<Client ID>", "<Client Secret>", $tokenCache, $resultCache, $httpClient ); $users = $usersApiClient->getUsers(); $subsidiaries = $usersApiClient->getSubsidiaries(); $user = $usersApiClient->getUser('<userId>');
Cache Refresh via Console commands
This SDK contains Symfony Console commands to refresh the User/Subsidiary cache. You can include the Console commands into your application:
$cliApp = new \Symfony\Component\Console\Application(); $cliApp->add(new \BayWaReLusy\UsersAPI\SDK\Console\RefreshUserCache($usersApiClient)); $cliApp->add(new \BayWaReLusy\UsersAPI\SDK\Console\RefreshSubsidiaryCache($usersApiClient)));
And then run the Console commands with:
./console users-api-sdk:refresh-user-cache ./console users-api-sdk:refresh-subsidiary-cache