From d31106835197fd13904cb398a067cc476a08c721 Mon Sep 17 00:00:00 2001 From: Pawel Luczkiewicz Date: Fri, 5 Feb 2021 10:03:48 +0100 Subject: [PATCH 1/2] Add accept header for the checks API --- lib/Github/Api/Repository/Checks/CheckRuns.php | 10 ++++++++++ lib/Github/Api/Repository/Checks/CheckSuites.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/Github/Api/Repository/Checks/CheckRuns.php b/lib/Github/Api/Repository/Checks/CheckRuns.php index 6f91997e8b4..d9aeba92a8a 100644 --- a/lib/Github/Api/Repository/Checks/CheckRuns.php +++ b/lib/Github/Api/Repository/Checks/CheckRuns.php @@ -3,12 +3,22 @@ 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; + + public function configure() + { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + + return $this; + } + /** * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-run * diff --git a/lib/Github/Api/Repository/Checks/CheckSuites.php b/lib/Github/Api/Repository/Checks/CheckSuites.php index d597fed54e7..36bc0c98c90 100644 --- a/lib/Github/Api/Repository/Checks/CheckSuites.php +++ b/lib/Github/Api/Repository/Checks/CheckSuites.php @@ -3,12 +3,22 @@ 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; + + public function configure() + { + $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; + + return $this; + } + /** * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-suite * From 2ab07f34cb4de2a5cca72a74144a1af62c23f809 Mon Sep 17 00:00:00 2001 From: Pawel Luczkiewicz Date: Mon, 8 Feb 2021 10:32:33 +0100 Subject: [PATCH 2/2] Change to the old way of setting headers --- .../Api/Repository/Checks/CheckRuns.php | 19 ++++++++++++------- .../Api/Repository/Checks/CheckSuites.php | 17 ++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/Github/Api/Repository/Checks/CheckRuns.php b/lib/Github/Api/Repository/Checks/CheckRuns.php index d9aeba92a8a..d1e456212ce 100644 --- a/lib/Github/Api/Repository/Checks/CheckRuns.php +++ b/lib/Github/Api/Repository/Checks/CheckRuns.php @@ -12,13 +12,6 @@ class CheckRuns extends AbstractApi { use AcceptHeaderTrait; - public function configure() - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this; - } - /** * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-run * @@ -26,6 +19,8 @@ public function configure() */ 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); } @@ -36,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); } @@ -46,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); } @@ -56,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'); } @@ -66,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); } @@ -76,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); } } diff --git a/lib/Github/Api/Repository/Checks/CheckSuites.php b/lib/Github/Api/Repository/Checks/CheckSuites.php index 36bc0c98c90..ca6b432eb83 100644 --- a/lib/Github/Api/Repository/Checks/CheckSuites.php +++ b/lib/Github/Api/Repository/Checks/CheckSuites.php @@ -12,13 +12,6 @@ class CheckSuites extends AbstractApi { use AcceptHeaderTrait; - public function configure() - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this; - } - /** * @link https://docs.github.com/en/free-pro-team@latest/rest/reference/checks#create-a-check-suite * @@ -26,6 +19,8 @@ public function configure() */ 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); } @@ -36,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); } @@ -46,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); } @@ -56,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'); } @@ -66,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); } }