Skip to content

Add accept header for the checks API #968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/Github/Api/Repository/Checks/CheckRuns.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
namespace Github\Api\Repository\Checks;

use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;

/**
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks
*/
class CheckRuns extends AbstractApi
{
use AcceptHeaderTrait;

/**
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-run
*
* @return array
*/
public function create(string $username, string $repository, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs', $params);
}

Expand All @@ -26,6 +31,8 @@ public function create(string $username, string $repository, array $params = [])
*/
public function show(string $username, string $repository, int $checkRunId)
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId);
}

Expand All @@ -36,6 +43,8 @@ public function show(string $username, string $repository, int $checkRunId)
*/
public function update(string $username, string $repository, int $checkRunId, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId, $params);
}

Expand All @@ -46,6 +55,8 @@ public function update(string $username, string $repository, int $checkRunId, ar
*/
public function annotations(string $username, string $repository, int $checkRunId)
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId.'/annotations');
}

Expand All @@ -56,6 +67,8 @@ public function annotations(string $username, string $repository, int $checkRunI
*/
public function allForCheckSuite(string $username, string $repository, int $checkSuiteId, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/check-runs', $params);
}

Expand All @@ -66,6 +79,8 @@ public function allForCheckSuite(string $username, string $repository, int $chec
*/
public function allForReference(string $username, string $repository, string $ref, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params);
}
}
13 changes: 13 additions & 0 deletions lib/Github/Api/Repository/Checks/CheckSuites.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
namespace Github\Api\Repository\Checks;

use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;

/**
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks
*/
class CheckSuites extends AbstractApi
{
use AcceptHeaderTrait;

/**
* @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-suite
*
* @return array
*/
public function create(string $username, string $repository, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites', $params);
}

Expand All @@ -26,6 +31,8 @@ public function create(string $username, string $repository, array $params = [])
*/
public function updatePreferences(string $username, string $repository, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/preferences', $params);
}

Expand All @@ -36,6 +43,8 @@ public function updatePreferences(string $username, string $repository, array $p
*/
public function getCheckSuite(string $username, string $repository, int $checkSuiteId)
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId);
}

Expand All @@ -46,6 +55,8 @@ public function getCheckSuite(string $username, string $repository, int $checkSu
*/
public function rerequest(string $username, string $repository, int $checkSuiteId)
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/rerequest');
}

Expand All @@ -56,6 +67,8 @@ public function rerequest(string $username, string $repository, int $checkSuiteI
*/
public function allForReference(string $username, string $repository, string $ref, array $params = [])
{
$this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json';

return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-suites', $params);
}
}