Skip to content

Commit d508be8

Browse files
committed
Cleanup the accept HTTP header as GitHub no longer versions this
1 parent 663af58 commit d508be8

29 files changed

+14
-224
lines changed

lib/Github/Api/Apps.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@
1111
*/
1212
class Apps extends AbstractApi
1313
{
14-
use AcceptHeaderTrait;
15-
16-
private function configurePreviewHeader()
17-
{
18-
$this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json';
19-
}
20-
2114
/**
2215
* Create an access token for an installation.
2316
*
@@ -36,8 +29,6 @@ public function createInstallationToken($installationId, $userId = null)
3629
$parameters['user_id'] = $userId;
3730
}
3831

39-
$this->configurePreviewHeader();
40-
4132
return $this->post('/app/installations/'.$installationId.'/access_tokens', $parameters);
4233
}
4334

@@ -50,8 +41,6 @@ public function createInstallationToken($installationId, $userId = null)
5041
*/
5142
public function findInstallations()
5243
{
53-
$this->configurePreviewHeader();
54-
5544
return $this->get('/app/installations');
5645
}
5746

@@ -66,8 +55,6 @@ public function findInstallations()
6655
*/
6756
public function getInstallation($installationId)
6857
{
69-
$this->configurePreviewHeader();
70-
7158
return $this->get('/app/installations/'.$installationId);
7259
}
7360

@@ -82,8 +69,6 @@ public function getInstallation($installationId)
8269
*/
8370
public function getInstallationForOrganization($org)
8471
{
85-
$this->configurePreviewHeader();
86-
8772
return $this->get('/orgs/'.rawurldecode($org).'/installation');
8873
}
8974

@@ -99,8 +84,6 @@ public function getInstallationForOrganization($org)
9984
*/
10085
public function getInstallationForRepo($owner, $repo)
10186
{
102-
$this->configurePreviewHeader();
103-
10487
return $this->get('/repos/'.rawurldecode($owner).'/'.rawurldecode($repo).'/installation');
10588
}
10689

@@ -115,8 +98,6 @@ public function getInstallationForRepo($owner, $repo)
11598
*/
11699
public function getInstallationForUser($username)
117100
{
118-
$this->configurePreviewHeader();
119-
120101
return $this->get('/users/'.rawurldecode($username).'/installation');
121102
}
122103

@@ -129,8 +110,6 @@ public function getInstallationForUser($username)
129110
*/
130111
public function removeInstallation($installationId)
131112
{
132-
$this->configurePreviewHeader();
133-
134113
$this->delete('/app/installations/'.$installationId);
135114
}
136115

@@ -150,8 +129,6 @@ public function listRepositories($userId = null)
150129
$parameters['user_id'] = $userId;
151130
}
152131

153-
$this->configurePreviewHeader();
154-
155132
return $this->get('/installation/repositories', $parameters);
156133
}
157134

@@ -167,8 +144,6 @@ public function listRepositories($userId = null)
167144
*/
168145
public function addRepository($installationId, $repositoryId)
169146
{
170-
$this->configurePreviewHeader();
171-
172147
return $this->put('/installations/'.$installationId.'/repositories/'.$repositoryId);
173148
}
174149

@@ -184,8 +159,6 @@ public function addRepository($installationId, $repositoryId)
184159
*/
185160
public function removeRepository($installationId, $repositoryId)
186161
{
187-
$this->configurePreviewHeader();
188-
189162
return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
190163
}
191164

lib/Github/Api/CurrentUser.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
class CurrentUser extends AbstractApi
2020
{
21-
use AcceptHeaderTrait;
22-
2321
public function show()
2422
{
2523
return $this->get('/user');
@@ -173,8 +171,6 @@ public function subscriptions()
173171
*/
174172
public function installations(array $params = [])
175173
{
176-
$this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json';
177-
178174
return $this->get('/user/installations', array_merge(['page' => 1], $params));
179175
}
180176

@@ -186,8 +182,6 @@ public function installations(array $params = [])
186182
*/
187183
public function repositoriesByInstallation($installationId, array $params = [])
188184
{
189-
$this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json';
190-
191185
return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(['page' => 1], $params));
192186
}
193187
}

lib/Github/Api/CurrentUser/Starring.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Starring extends AbstractApi
2626
public function configure($bodyType = null)
2727
{
2828
if ('star' === $bodyType) {
29-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->getApiVersion());
29+
$this->acceptHeaderValue = 'application/vnd.github.star+json';
3030
}
3131

3232
return $this;

lib/Github/Api/Deployment.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
*/
1414
class Deployment extends AbstractApi
1515
{
16-
use AcceptHeaderTrait;
17-
1816
/**
1917
* List deployments for a particular repository.
2018
*
@@ -107,15 +105,6 @@ public function updateStatus($username, $repository, $id, array $params)
107105
throw new MissingArgumentException(['state']);
108106
}
109107

110-
// adjust media-type per github docs
111-
// https://docs.github.com/en/rest/reference/repos#create-a-deployment-status
112-
if ($params['state'] === 'inactive') {
113-
$this->acceptHeaderValue = 'application/vnd.github.ant-man-preview+json';
114-
}
115-
if ($params['state'] === 'in_progress' || $params['state'] === 'queued') {
116-
$this->acceptHeaderValue = 'application/vnd.github.flash-preview+json';
117-
}
118-
119108
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params);
120109
}
121110

lib/Github/Api/Gist/Comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function configure($bodyType = null)
2929
$bodyType = 'raw';
3030
}
3131

32-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType);
32+
$this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType);
3333

3434
return $this;
3535
}

lib/Github/Api/Gists.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function configure($bodyType = null)
3232
$bodyType = 'raw';
3333
}
3434

35-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->getApiVersion(), $bodyType);
35+
$this->acceptHeaderValue = sprintf('application/vnd.github.%s', $bodyType);
3636

3737
return $this;
3838
}

lib/Github/Api/GitData/Blobs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Blobs extends AbstractApi
2626
public function configure($bodyType = null)
2727
{
2828
if ('raw' === $bodyType) {
29-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.raw', $this->getApiVersion());
29+
$this->acceptHeaderValue = 'application/vnd.github.raw';
3030
}
3131

3232
return $this;

lib/Github/Api/GraphQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GraphQL extends AbstractApi
2222
*
2323
* @return array
2424
*/
25-
public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github.v4+json')
25+
public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github+json')
2626
{
2727
$this->acceptHeaderValue = $acceptHeaderValue;
2828
$params = [

lib/Github/Api/Issue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function configure($bodyType = null)
3737
$bodyType = 'raw';
3838
}
3939

40-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType);
40+
$this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType);
4141

4242
return $this;
4343
}

lib/Github/Api/Issue/Comments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function configure($bodyType = null)
3131
$bodyType = 'full';
3232
}
3333

34-
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType);
34+
$this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType);
3535

3636
return $this;
3737
}

0 commit comments

Comments
 (0)