* @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:----YDZ49KGZzIaLtxgFFl0zDo6q5lykZEjtdVqXLwfa65mBrlP7cWZyrLQIUDOJOf1/E+5lsY1CVsCTuIuADmbZmXQEas3htJr4X3zjv4aWMCrAfUAVyMvTMeahFXiMYawk+hH3jjLL6+ZiaY73RCgHJksrgMxW1G8ldxtYMN3pqHL5qRr8q8VuV61O4b8q+hzXEOxW6SaVmcaElIykOKjTpmD5WoprZt95RSzwaRQlYp1erQI9Pp03UAlGahJ1cIaaHjfkrqCaSXDPQ6m0u7GiZaJOAAn7XPYcAi7iawXZdJ5lMN0GevC5ucm/Th9+SqHLrffSN3k+BkKOYJvzB8D0h+HdTmbQjdtE+yfIDEzae7xestJye/EmMWja63iX6UWFZagbiDBcodgPImbxGIcqzmV6Sx5WGjWmw8r13NPP7/3rKFglly9tiK1S5MeYxZFVRM+5PtO2g6uH9GDQwPV8YlbIGEiIyrCuDsEXV9qmUC8Y0RwEBPGxRCmOApELtz6TiZTENJ4hoyD7cKd/gY9562nzu/YD5De/noAmpYWATFbBhdoaoEnOU6k/XrUALFNdR7qWr1C9N4dqk+dZ58rui234ihTkYdyIzLHKrHPBkyIrh9gVZxf1a/wUZtY+/pshLRbLGGBY/oFrelVbp0qLn6X060BJ0enhlDB+zSEBQfM=----ATTACHMENT:----OTAxMDkxMTk3OTU5MDczNiA2NDYyNjcxNDUwMjQ3NjE1IDI3OTc2MzI4MDI5NjgwMDM=