Skip to content

Commit 79a0993

Browse files
authored
bug #968 Add accept header for the checks API (Agares)
This PR was squashed before being merged into the 3.0.x-dev branch. Discussion ---------- Fixes #967. This PR adds the Accept header back for the Checks API. This is required to make this work on GitHub Enterprise 2.22 (the latest stable version), which still considers this API a preview. Commits ------- d311068 Add accept header for the checks API 2ab07f3 Change to the old way of setting headers
1 parent ac08595 commit 79a0993

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/Github/Api/Repository/Checks/CheckRuns.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33
namespace Github\Api\Repository\Checks;
44

55
use Github\Api\AbstractApi;
6+
use Github\Api\AcceptHeaderTrait;
67

78
/**
89
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks
910
*/
1011
class CheckRuns extends AbstractApi
1112
{
13+
use AcceptHeaderTrait;
14+
1215
/**
1316
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-run
1417
*
1518
* @return array
1619
*/
1720
public function create(string $username, string $repository, array $params = [])
1821
{
22+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
23+
1924
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs', $params);
2025
}
2126

@@ -26,6 +31,8 @@ public function create(string $username, string $repository, array $params = [])
2631
*/
2732
public function show(string $username, string $repository, int $checkRunId)
2833
{
34+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
35+
2936
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId);
3037
}
3138

@@ -36,6 +43,8 @@ public function show(string $username, string $repository, int $checkRunId)
3643
*/
3744
public function update(string $username, string $repository, int $checkRunId, array $params = [])
3845
{
46+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
47+
3948
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId, $params);
4049
}
4150

@@ -46,6 +55,8 @@ public function update(string $username, string $repository, int $checkRunId, ar
4655
*/
4756
public function annotations(string $username, string $repository, int $checkRunId)
4857
{
58+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
59+
4960
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId.'/annotations');
5061
}
5162

@@ -56,6 +67,8 @@ public function annotations(string $username, string $repository, int $checkRunI
5667
*/
5768
public function allForCheckSuite(string $username, string $repository, int $checkSuiteId, array $params = [])
5869
{
70+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
71+
5972
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/check-runs', $params);
6073
}
6174

@@ -66,6 +79,8 @@ public function allForCheckSuite(string $username, string $repository, int $chec
6679
*/
6780
public function allForReference(string $username, string $repository, string $ref, array $params = [])
6881
{
82+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
83+
6984
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params);
7085
}
7186
}

lib/Github/Api/Repository/Checks/CheckSuites.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33
namespace Github\Api\Repository\Checks;
44

55
use Github\Api\AbstractApi;
6+
use Github\Api\AcceptHeaderTrait;
67

78
/**
89
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks
910
*/
1011
class CheckSuites extends AbstractApi
1112
{
13+
use AcceptHeaderTrait;
14+
1215
/**
1316
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-suite
1417
*
1518
* @return array
1619
*/
1720
public function create(string $username, string $repository, array $params = [])
1821
{
22+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
23+
1924
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites', $params);
2025
}
2126

@@ -26,6 +31,8 @@ public function create(string $username, string $repository, array $params = [])
2631
*/
2732
public function updatePreferences(string $username, string $repository, array $params = [])
2833
{
34+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
35+
2936
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/preferences', $params);
3037
}
3138

@@ -36,6 +43,8 @@ public function updatePreferences(string $username, string $repository, array $p
3643
*/
3744
public function getCheckSuite(string $username, string $repository, int $checkSuiteId)
3845
{
46+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
47+
3948
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId);
4049
}
4150

@@ -46,6 +55,8 @@ public function getCheckSuite(string $username, string $repository, int $checkSu
4655
*/
4756
public function rerequest(string $username, string $repository, int $checkSuiteId)
4857
{
58+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
59+
4960
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/rerequest');
5061
}
5162

@@ -56,6 +67,8 @@ public function rerequest(string $username, string $repository, int $checkSuiteI
5667
*/
5768
public function allForReference(string $username, string $repository, string $ref, array $params = [])
5869
{
70+
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';
71+
5972
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-suites', $params);
6073
}
6174
}

0 commit comments

Comments
 (0)