PHP code example of baywa-re-lusy / users-api-sdk

1. Go to this page and download the library: Download baywa-re-lusy/users-api-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

baywa-re-lusy / users-api-sdk example snippets


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>');

$cliApp = new \Symfony\Component\Console\Application();

$cliApp->add(new \BayWaReLusy\UsersAPI\SDK\Console\RefreshUserCache($usersApiClient));
$cliApp->add(new \BayWaReLusy\UsersAPI\SDK\Console\RefreshSubsidiaryCache($usersApiClient)));