sprintf('Token %s', $authToken), 'User-Agent' => sprintf( 'Hypernode API PHP Client v%s', InstalledVersions::getVersion('hypernode/api-client'), ), 'Accept' => 'application/json', 'Content-Type' => 'application/json', ]; $httpClient = self::getHttpClient(self::HYPERNODE_API_URL, $httpHeaders, $httpClient); $apiClient = new HttpMethodsClient( $httpClient, Psr17FactoryDiscovery::findRequestFactory(), Psr17FactoryDiscovery::findStreamFactory() ); return new HypernodeClient($apiClient); } public static function getHttpClient( string $apiUrl, array $headers, ?ClientInterface $httpClient = null ): ClientInterface { $httpClient = $httpClient ?? Psr18ClientDiscovery::find(); $uri = Psr17FactoryDiscovery::findUriFactory()->createUri($apiUrl); $plugins = [ new AddHostPlugin($uri), new AddPathPlugin($uri), new HeaderSetPlugin($headers), ]; return new PluginClient($httpClient, $plugins); } }