* @license http://www.gnu.org/licenses/agpl-3.0 * @link http://fusio-project.org */ class Client { /** @var string */ private $baseUri; /** @var string */ private $appKey; /** @var string */ private $appSecret; /** @var string[]|null */ private $scopes; /** @var TokenStoreInterface */ private $tokenStore; /** @var HttpClient|null */ private $httpClient; /** @var SchemaManager|null */ private $schemaManager; /** * @param string $baseUri * @param string $appKey * @param string $appSecret * @param array|null $scopes * @param HttpClient|null $httpClient * @param SchemaManager|null $schemaManager */ public function __construct( string $baseUri, string $appKey, string $appSecret, ?array $scopes = null, ?TokenStoreInterface $tokenStore = null, ?HttpClient $httpClient = null, ?SchemaManager $schemaManager = null, ) { $this->baseUri = $baseUri; $this->appKey = $appKey; $this->appSecret = $appSecret; $this->scopes = $scopes; $this->tokenStore = $tokenStore ?? new MemoryTokenStore(); $this->httpClient = $httpClient; $this->schemaManager = $schemaManager; } public function authenticate(): AccessToken { $token = $this->tokenStore->get(); if ($token && $token->getExpiresIn() > time()) { return $token; } $authenticator = new Authenticator($this->baseUri, $this->httpClient); $token = $authenticator->requestAccessToken($this->appKey, $this->appSecret, $this->scopes); $this->tokenStore->persist($token); return $token; } public function backend(): Backend\Client { $token = $this->authenticate(); return new Backend\Client($this->baseUri, $token->getAccessToken(), $this->httpClient, $this->schemaManager); } public function consumer(): Consumer\Client { $token = $this->authenticate(); return new Consumer\Client($this->baseUri, $token->getAccessToken(), $this->httpClient, $this->schemaManager); } } __halt_compiler();----SIGNATURE:----sYq5fzhhj3cJma3qhJAz4scr0fcFYL/ncMmUe9I4l3fx8KNR6HXq3VzEHHvlqeOfXWBByOqA1mb7PTYrIifpc3ywuhtCfUSBQYVWnEPtodX/pbn6GnCcAXcOTdSKoEpkVFN/3RckAzyzuLixb8SUjzCwDzwQ8msD9zrjc90eZwdyLf67e+LnE8faGzOkQS1/9KFk1oPj7E37mq8HG68e7tzYccKvcWHiF5BHNvGosBE5kuXJgDoSHrTbkFBSlAYiSnmHn3arJmJmJbr3stySHuxktEYKm6M38mWRPHm5EHg3AjTnO76tUzD3Y8py2Qqgw2cglpe3mLIjQ+sEBbx5yPk2hsWd+/cNFsnR4t+aovPvbLSyZCXp5ED/y24dodr17XPBF/HQ6mi0ctAOcQ1LSHjJsb+iNsdsqsELCIBjjYFt59JdIC6vBRROZW5zh1OZyvndTsjj6nVRCg5NRfz3cq/YcKvcepD8xG/STFKrFT9UhRUedVz2joHfpMd0VttnE0lhjT5K6PYB15ENVuH7ma7z0jMMyyTYc+UKG7iO9lX46jhapAQY+bqV86md1FyL8zQZrrIFh0Qsu8scMtZo/nIy/M1mIpXJfzzp89E9opn2mfi6gx60xKFSoCAdfbVsYnzem/fLraI4da0Ko2HvRBNbFXR6GLscBIE0phGBm50=----ATTACHMENT:----Njg1MDE3ODIzODY4NDMxMyA3NzQxODMwODQ5MDg5MDQ2IDU0NDM0MTcxODA0ODg3MzM=