coveo-1.0.0-alpha1/src/API/PushApiFactory.php
src/API/PushApiFactory.php
<?php
declare(strict_types=1);
namespace Drupal\coveo\API;
use GuzzleHttp\ClientInterface;
use NecLimDul\Coveo\PushApi\Configuration;
/**
* Push API service factory.
*/
class PushApiFactory {
/**
* API factory service.
*
* @var \Drupal\coveo\API\ApiFactory
*/
private ApiFactory $factory;
public function __construct(ClientInterface $client) {
$this->factory = new ApiFactory($client);
}
/**
* Create a PushAPI service.
*
* @param class-string<T> $class
* A PushAPI service class.
* @param string $token
* An access token with admin privileges.
*
* @return T
* The instantiated API service.
*
* @template T
*/
public function create(
string $class,
#[\SensitiveParameter]
string $token,
) {
$config = new Configuration();
$config->setAccessToken($token);
return $this->factory->create($class, $config);
}
}
