diff --git a/src/ClientFactory.php b/src/ClientFactory.php index 6e2ac85..382b330 100644 --- a/src/ClientFactory.php +++ b/src/ClientFactory.php @@ -7,19 +7,22 @@ use GuzzleHttp\Psr7\Uri; use Http\Client\Common\Plugin\AddHostPlugin; use Http\Client\Common\PluginClient; +use Http\Client\HttpAsyncClient; use Http\Discovery\Psr18ClientDiscovery; use Jane\Component\OpenApiRuntime\Client\Plugin\AuthenticationRegistry; +use Psr\Http\Client\ClientInterface; final readonly class ClientFactory { - public static function createClient(string $token = null): Client + public static function createClient(string $token = null, + HttpAsyncClient|ClientInterface $client = null): Client { $plugins = []; if (null !== $token) { $plugins[] = new AuthenticationRegistry([new BearerAuthentication($token)]); } $plugins[] = new AddHostPlugin(new Uri('https://api.checkbox.in.ua'), ['replace' => true]); - $pluginClient = new PluginClient(Psr18ClientDiscovery::find(), $plugins); + $pluginClient = new PluginClient($client??Psr18ClientDiscovery::find(), $plugins); return Client::create($pluginClient); }