Skip to content

Commit a040008

Browse files
Allow setting the api version and enterprise url on construct
1 parent 50eecee commit a040008

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/Github/Client.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Client
8989
/**
9090
* @var string
9191
*/
92-
private $apiVersion = 'v3';
92+
private $apiVersion;
9393

9494
/**
9595
* The object that sends HTTP messages
@@ -141,8 +141,10 @@ class Client
141141
* Instantiate a new GitHub client.
142142
*
143143
* @param HttpClient|null $httpClient
144+
* @param string|null $apiVersion
145+
* @param string|null $enterpriseUrl
144146
*/
145-
public function __construct(HttpClient $httpClient = null)
147+
public function __construct(HttpClient $httpClient = null, $apiVersion = null, $enterpriseUrl = null)
146148
{
147149
$this->httpClient = $httpClient ?: HttpClientDiscovery::find();
148150
$this->messageFactory = MessageFactoryDiscovery::find();
@@ -156,8 +158,12 @@ public function __construct(HttpClient $httpClient = null)
156158
$this->addPlugin(new Plugin\HeaderDefaultsPlugin(array(
157159
'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)',
158160
)));
159-
// Add standard headers.
160-
$this->clearHeaders();
161+
162+
$this->setApiVersion($apiVersion ?: 'v3');
163+
164+
if ($enterpriseUrl) {
165+
$this->setEnterpriseUrl($enterpriseUrl);
166+
}
161167
}
162168

163169
/**

0 commit comments

Comments
 (0)