From a040008a051a12350f13554b285d0f92379b6310 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Mon, 1 Aug 2016 09:11:49 +0100 Subject: [PATCH] Allow setting the api version and enterprise url on construct --- lib/Github/Client.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Github/Client.php b/lib/Github/Client.php index f6861a01010..ffbe5f2399d 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -89,7 +89,7 @@ class Client /** * @var string */ - private $apiVersion = 'v3'; + private $apiVersion; /** * The object that sends HTTP messages @@ -141,8 +141,10 @@ class Client * Instantiate a new GitHub client. * * @param HttpClient|null $httpClient + * @param string|null $apiVersion + * @param string|null $enterpriseUrl */ - public function __construct(HttpClient $httpClient = null) + public function __construct(HttpClient $httpClient = null, $apiVersion = null, $enterpriseUrl = null) { $this->httpClient = $httpClient ?: HttpClientDiscovery::find(); $this->messageFactory = MessageFactoryDiscovery::find(); @@ -156,8 +158,12 @@ public function __construct(HttpClient $httpClient = null) $this->addPlugin(new Plugin\HeaderDefaultsPlugin(array( 'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)', ))); - // Add standard headers. - $this->clearHeaders(); + + $this->setApiVersion($apiVersion ?: 'v3'); + + if ($enterpriseUrl) { + $this->setEnterpriseUrl($enterpriseUrl); + } } /**