From 256a237d63d51e919991ed78db964700f8234549 Mon Sep 17 00:00:00 2001 From: Timon de Groot Date: Tue, 6 Dec 2022 15:10:54 +0100 Subject: [PATCH] HypernodeClientFactory: Use composer runtime API to get client version --- composer.json | 1 + src/HypernodeClient.php | 2 -- src/HypernodeClientFactory.php | 6 +++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 9a0ef24..ff00b0a 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ } ], "require": { + "composer-runtime-api": "^2.0", "ext-curl": "*", "ext-json": "*", "nesbot/carbon": "^2.0", diff --git a/src/HypernodeClient.php b/src/HypernodeClient.php index 629cb56..0774f76 100644 --- a/src/HypernodeClient.php +++ b/src/HypernodeClient.php @@ -15,8 +15,6 @@ class HypernodeClient { - public const VERSION = '0.1.0'; - public HttpMethodsClientInterface $api; public App $app; public BrancherApp $brancherApp; diff --git a/src/HypernodeClientFactory.php b/src/HypernodeClientFactory.php index dfda8ca..e25be4b 100644 --- a/src/HypernodeClientFactory.php +++ b/src/HypernodeClientFactory.php @@ -4,6 +4,7 @@ namespace Hypernode\Api; +use Composer\InstalledVersions; use Http\Client\Common\HttpMethodsClient; use Http\Client\Common\Plugin\AddHostPlugin; use Http\Client\Common\Plugin\AddPathPlugin; @@ -21,7 +22,10 @@ public static function create(string $authToken, ?ClientInterface $httpClient = { $httpHeaders = [ 'Authorization' => sprintf('Token %s', $authToken), - 'User-Agent' => sprintf('Hypernode API PHP Client v%s', HypernodeClient::VERSION), + 'User-Agent' => sprintf( + 'Hypernode API PHP Client v%s', + InstalledVersions::getVersion('hypernode/api-client'), + ), 'Accept' => 'application/json', 'Content-Type' => 'application/json', ];