diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php index f7da05bfbda..ce3ee3698a2 100644 --- a/lib/Github/Api/Apps.php +++ b/lib/Github/Api/Apps.php @@ -11,13 +11,6 @@ */ class Apps extends AbstractApi { - use AcceptHeaderTrait; - - private function configurePreviewHeader() - { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - } - /** * Create an access token for an installation. * @@ -36,8 +29,6 @@ public function createInstallationToken($installationId, $userId = null) $parameters['user_id'] = $userId; } - $this->configurePreviewHeader(); - return $this->post('/app/installations/'.$installationId.'/access_tokens', $parameters); } @@ -50,8 +41,6 @@ public function createInstallationToken($installationId, $userId = null) */ public function findInstallations() { - $this->configurePreviewHeader(); - return $this->get('/app/installations'); } @@ -66,8 +55,6 @@ public function findInstallations() */ public function getInstallation($installationId) { - $this->configurePreviewHeader(); - return $this->get('/app/installations/'.$installationId); } @@ -82,8 +69,6 @@ public function getInstallation($installationId) */ public function getInstallationForOrganization($org) { - $this->configurePreviewHeader(); - return $this->get('/orgs/'.rawurldecode($org).'/installation'); } @@ -99,8 +84,6 @@ public function getInstallationForOrganization($org) */ public function getInstallationForRepo($owner, $repo) { - $this->configurePreviewHeader(); - return $this->get('/repos/'.rawurldecode($owner).'/'.rawurldecode($repo).'/installation'); } @@ -115,8 +98,6 @@ public function getInstallationForRepo($owner, $repo) */ public function getInstallationForUser($username) { - $this->configurePreviewHeader(); - return $this->get('/users/'.rawurldecode($username).'/installation'); } @@ -129,8 +110,6 @@ public function getInstallationForUser($username) */ public function removeInstallation($installationId) { - $this->configurePreviewHeader(); - $this->delete('/app/installations/'.$installationId); } @@ -150,8 +129,6 @@ public function listRepositories($userId = null) $parameters['user_id'] = $userId; } - $this->configurePreviewHeader(); - return $this->get('/installation/repositories', $parameters); } @@ -167,8 +144,6 @@ public function listRepositories($userId = null) */ public function addRepository($installationId, $repositoryId) { - $this->configurePreviewHeader(); - return $this->put('/installations/'.$installationId.'/repositories/'.$repositoryId); } @@ -184,8 +159,6 @@ public function addRepository($installationId, $repositoryId) */ public function removeRepository($installationId, $repositoryId) { - $this->configurePreviewHeader(); - return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId); } diff --git a/lib/Github/Api/CurrentUser.php b/lib/Github/Api/CurrentUser.php index 0d4992adc80..f82b500707b 100644 --- a/lib/Github/Api/CurrentUser.php +++ b/lib/Github/Api/CurrentUser.php @@ -18,8 +18,6 @@ */ class CurrentUser extends AbstractApi { - use AcceptHeaderTrait; - /** * Get the authenticated user. * @@ -198,8 +196,6 @@ public function subscriptions() */ public function installations(array $params = []) { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - return $this->get('/user/installations', array_merge(['page' => 1], $params)); } @@ -211,8 +207,6 @@ public function installations(array $params = []) */ public function repositoriesByInstallation($installationId, array $params = []) { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(['page' => 1], $params)); } } diff --git a/lib/Github/Api/CurrentUser/Starring.php b/lib/Github/Api/CurrentUser/Starring.php index 9ee690ff644..c0516651f3b 100644 --- a/lib/Github/Api/CurrentUser/Starring.php +++ b/lib/Github/Api/CurrentUser/Starring.php @@ -26,7 +26,7 @@ class Starring extends AbstractApi public function configure($bodyType = null) { if ('star' === $bodyType) { - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->getApiVersion()); + $this->acceptHeaderValue = 'application/vnd.github.star+json'; } return $this; diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php index 8cf3af390d4..1a008dc8070 100644 --- a/lib/Github/Api/Deployment.php +++ b/lib/Github/Api/Deployment.php @@ -13,8 +13,6 @@ */ class Deployment extends AbstractApi { - use AcceptHeaderTrait; - /** * List deployments for a particular repository. * @@ -109,15 +107,6 @@ public function updateStatus($username, $repository, $id, array $params) throw new MissingArgumentException(['state']); } - // adjust media-type per github docs - // https://docs.github.com/rest/deployments/statuses#create-a-deployment-status - if ($params['state'] === 'inactive') { - $this->acceptHeaderValue = 'application/vnd.github.ant-man-preview+json'; - } - if ($params['state'] === 'in_progress' || $params['state'] === 'queued') { - $this->acceptHeaderValue = 'application/vnd.github.flash-preview+json'; - } - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params); } diff --git a/lib/Github/Api/Gist/Comments.php b/lib/Github/Api/Gist/Comments.php index 48d694be359..56642473fcd 100644 --- a/lib/Github/Api/Gist/Comments.php +++ b/lib/Github/Api/Gist/Comments.php @@ -29,7 +29,7 @@ public function configure($bodyType = null) $bodyType = 'raw'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType); return $this; } diff --git a/lib/Github/Api/Gists.php b/lib/Github/Api/Gists.php index 8556428ff7a..ae036b5ced3 100644 --- a/lib/Github/Api/Gists.php +++ b/lib/Github/Api/Gists.php @@ -32,7 +32,7 @@ public function configure($bodyType = null) $bodyType = 'raw'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->getApiVersion(), $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s', $bodyType); return $this; } diff --git a/lib/Github/Api/GitData/Blobs.php b/lib/Github/Api/GitData/Blobs.php index 373406a5bb6..ff958512099 100644 --- a/lib/Github/Api/GitData/Blobs.php +++ b/lib/Github/Api/GitData/Blobs.php @@ -28,7 +28,7 @@ class Blobs extends AbstractApi public function configure($bodyType = null) { if ('raw' === $bodyType) { - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.raw', $this->getApiVersion()); + $this->acceptHeaderValue = 'application/vnd.github.raw'; } return $this; diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php index 655028fdf37..a09a7e00c6f 100644 --- a/lib/Github/Api/GraphQL.php +++ b/lib/Github/Api/GraphQL.php @@ -26,7 +26,7 @@ class GraphQL extends AbstractApi * * @return array */ - public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github.v4+json') + public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github+json') { $this->acceptHeaderValue = $acceptHeaderValue; $params = [ diff --git a/lib/Github/Api/Issue.php b/lib/Github/Api/Issue.php index 3fb5237005c..13098c5e5ff 100644 --- a/lib/Github/Api/Issue.php +++ b/lib/Github/Api/Issue.php @@ -38,7 +38,7 @@ public function configure($bodyType = null) $bodyType = 'raw'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType); return $this; } diff --git a/lib/Github/Api/Issue/Comments.php b/lib/Github/Api/Issue/Comments.php index 5bea07ed9fe..0c7ad3e52d3 100644 --- a/lib/Github/Api/Issue/Comments.php +++ b/lib/Github/Api/Issue/Comments.php @@ -32,7 +32,7 @@ public function configure($bodyType = null) $bodyType = 'full'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType); return $this; } diff --git a/lib/Github/Api/Issue/Timeline.php b/lib/Github/Api/Issue/Timeline.php index 40d02c93db7..e9bd350fb7f 100644 --- a/lib/Github/Api/Issue/Timeline.php +++ b/lib/Github/Api/Issue/Timeline.php @@ -3,20 +3,19 @@ namespace Github\Api\Issue; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; class Timeline extends AbstractApi { - use AcceptHeaderTrait; - /** * Configure the accept header to use the timeline preview media type. * + * @deprecated since 3.17, GitHub no longer requires a custom accept header; this method will be removed in 4.0. + * * @return $this */ public function configure() { - $this->acceptHeaderValue = 'application/vnd.github.mockingbird-preview'; + trigger_deprecation('KnpLabs/php-github-api', '3.17', 'The "%s" is deprecated and will be removed.', __METHOD__); return $this; } diff --git a/lib/Github/Api/Miscellaneous/CodeOfConduct.php b/lib/Github/Api/Miscellaneous/CodeOfConduct.php index cc3f9f5e46b..7116970ed98 100644 --- a/lib/Github/Api/Miscellaneous/CodeOfConduct.php +++ b/lib/Github/Api/Miscellaneous/CodeOfConduct.php @@ -3,20 +3,19 @@ namespace Github\Api\Miscellaneous; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; class CodeOfConduct extends AbstractApi { - use AcceptHeaderTrait; - /** * Configure the accept header for the codes of conduct preview API. * + * @deprecated since 3.17, GitHub no longer requires a custom accept header; this method will be removed in 4.0. + * * @return $this */ public function configure() { - $this->acceptHeaderValue = 'application/vnd.github.scarlet-witch-preview+json'; + trigger_deprecation('KnpLabs/php-github-api', '3.17', 'The "%s" is deprecated and will be removed.', __METHOD__); return $this; } diff --git a/lib/Github/Api/Project/AbstractProjectApi.php b/lib/Github/Api/Project/AbstractProjectApi.php index 170f7023ee2..d90fdd129ac 100644 --- a/lib/Github/Api/Project/AbstractProjectApi.php +++ b/lib/Github/Api/Project/AbstractProjectApi.php @@ -3,7 +3,6 @@ namespace Github\Api\Project; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; /** * Base class for the "Projects (classic)" boards API. @@ -13,19 +12,16 @@ */ abstract class AbstractProjectApi extends AbstractApi { - use AcceptHeaderTrait; - /** * Configure the accept header for Early Access to the projects (classic) api. * - * @deprecated GitHub Projects (classic) was sunset by GitHub; this endpoint no longer has documentation - * on docs.github.com. + * @deprecated since 3.17, GitHub no longer requires a custom accept header; this method will be removed in 4.0. * * @return $this */ public function configure() { - $this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; + trigger_deprecation('KnpLabs/php-github-api', '3.17', 'The "%s" is deprecated and will be removed.', __METHOD__); return $this; } diff --git a/lib/Github/Api/Project/Cards.php b/lib/Github/Api/Project/Cards.php index 09d7beccf1e..2b8d1a6ac2a 100644 --- a/lib/Github/Api/Project/Cards.php +++ b/lib/Github/Api/Project/Cards.php @@ -3,7 +3,6 @@ namespace Github\Api\Project; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; use Github\Exception\MissingArgumentException; /** @@ -14,19 +13,16 @@ */ class Cards extends AbstractApi { - use AcceptHeaderTrait; - /** * Configure the accept header for Early Access to the projects (classic) api. * - * @deprecated GitHub Projects (classic) was sunset by GitHub; this endpoint no longer has documentation - * on docs.github.com. + * @deprecated since 3.17, GitHub no longer requires a custom accept header; this method will be removed in 4.0. * * @return $this */ public function configure() { - $this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; + trigger_deprecation('KnpLabs/php-github-api', '3.17', 'The "%s" is deprecated and will be removed.', __METHOD__); return $this; } diff --git a/lib/Github/Api/Project/Columns.php b/lib/Github/Api/Project/Columns.php index a03a1ea5edf..d2826d84ead 100644 --- a/lib/Github/Api/Project/Columns.php +++ b/lib/Github/Api/Project/Columns.php @@ -3,7 +3,6 @@ namespace Github\Api\Project; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; use Github\Exception\MissingArgumentException; /** @@ -14,19 +13,16 @@ */ class Columns extends AbstractApi { - use AcceptHeaderTrait; - /** * Configure the accept header for Early Access to the projects (classic) api. * - * @deprecated GitHub Projects (classic) was sunset by GitHub; this endpoint no longer has documentation - * on docs.github.com. + * @deprecated since 3.17, GitHub no longer requires a custom accept header; this method will be removed in 4.0. * * @return $this */ public function configure() { - $this->acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; + trigger_deprecation('KnpLabs/php-github-api', '3.17', 'The "%s" is deprecated and will be removed.', __METHOD__); return $this; } diff --git a/lib/Github/Api/PullRequest.php b/lib/Github/Api/PullRequest.php index ca00f66521b..2cc4f4331d9 100644 --- a/lib/Github/Api/PullRequest.php +++ b/lib/Github/Api/PullRequest.php @@ -31,10 +31,6 @@ class PullRequest extends AbstractApi */ public function configure($bodyType = null, $apiVersion = null) { - if (null === $apiVersion) { - $apiVersion = $this->getApiVersion(); - } - if (!in_array($bodyType, ['text', 'html', 'full', 'diff', 'patch'])) { $bodyType = 'raw'; } @@ -43,7 +39,7 @@ public function configure($bodyType = null, $apiVersion = null) $bodyType .= '+json'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $apiVersion, $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s', $bodyType); return $this; } diff --git a/lib/Github/Api/PullRequest/Comments.php b/lib/Github/Api/PullRequest/Comments.php index cbb042598f2..e5f4a920c5e 100644 --- a/lib/Github/Api/PullRequest/Comments.php +++ b/lib/Github/Api/PullRequest/Comments.php @@ -36,7 +36,7 @@ public function configure($bodyType = null, $apiVersion = null) $bodyType = 'raw'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $apiVersion, $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType); return $this; } diff --git a/lib/Github/Api/PullRequest/Review.php b/lib/Github/Api/PullRequest/Review.php index 1546311b97d..2360e97e29d 100644 --- a/lib/Github/Api/PullRequest/Review.php +++ b/lib/Github/Api/PullRequest/Review.php @@ -3,7 +3,6 @@ namespace Github\Api\PullRequest; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; use Github\Exception\InvalidArgumentException; use Github\Exception\MissingArgumentException; @@ -16,8 +15,6 @@ */ class Review extends AbstractApi { - use AcceptHeaderTrait; - /** * @deprecated since 3.2, will be removed in 4.0. * diff --git a/lib/Github/Api/PullRequest/ReviewRequest.php b/lib/Github/Api/PullRequest/ReviewRequest.php index 4db027c6009..d5831670a8d 100644 --- a/lib/Github/Api/PullRequest/ReviewRequest.php +++ b/lib/Github/Api/PullRequest/ReviewRequest.php @@ -3,15 +3,12 @@ namespace Github\Api\PullRequest; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; /** * @link https://docs.github.com/rest/pulls/review-requests */ class ReviewRequest extends AbstractApi { - use AcceptHeaderTrait; - /** * @deprecated since 3.2, will be removed in 4.0. * diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php index 912baddd3fc..41273c426ed 100644 --- a/lib/Github/Api/Repo.php +++ b/lib/Github/Api/Repo.php @@ -40,8 +40,6 @@ */ class Repo extends AbstractApi { - use AcceptHeaderTrait; - /** * List all public repositories. * @@ -705,8 +703,6 @@ public function milestones($username, $repository, array $parameters = []) */ public function enableAutomatedSecurityFixes(string $username, string $repository) { - $this->acceptHeaderValue = 'application/vnd.github.london-preview+json'; - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/automated-security-fixes'); } @@ -720,8 +716,6 @@ public function enableAutomatedSecurityFixes(string $username, string $repositor */ public function disableAutomatedSecurityFixes(string $username, string $repository) { - $this->acceptHeaderValue = 'application/vnd.github.london-preview+json'; - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/automated-security-fixes'); } @@ -787,9 +781,6 @@ public function events($username, $repository, $page = 1) */ public function communityProfile($username, $repository) { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.black-panther-preview+json'; - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/community/profile'); } @@ -805,9 +796,6 @@ public function communityProfile($username, $repository) */ public function codeOfConduct($username, $repository) { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.scarlet-witch-preview+json'; - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/community/code_of_conduct'); } @@ -823,9 +811,6 @@ public function codeOfConduct($username, $repository) */ public function topics($username, $repository) { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/topics'); } @@ -842,9 +827,6 @@ public function topics($username, $repository) */ public function replaceTopics($username, $repository, array $topics) { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - return $this->put('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/topics', ['names' => $topics]); } @@ -874,9 +856,6 @@ public function transfer($username, $repository, $newOwner, $teamId = []) */ public function createFromTemplate(string $templateOwner, string $templateRepo, array $parameters = []) { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.baptiste-preview+json'; - return $this->post('/repos/'.rawurldecode($templateOwner).'/'.rawurldecode($templateRepo).'/generate', $parameters); } diff --git a/lib/Github/Api/Repository/Checks/CheckRuns.php b/lib/Github/Api/Repository/Checks/CheckRuns.php index 1fd0b834238..3eefd6018ae 100644 --- a/lib/Github/Api/Repository/Checks/CheckRuns.php +++ b/lib/Github/Api/Repository/Checks/CheckRuns.php @@ -3,15 +3,12 @@ namespace Github\Api\Repository\Checks; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; /** * @link https://docs.github.com/rest/checks/runs */ class CheckRuns extends AbstractApi { - use AcceptHeaderTrait; - /** * @link https://docs.github.com/rest/checks/runs#create-a-check-run * @@ -19,8 +16,6 @@ class CheckRuns extends AbstractApi */ 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); } @@ -31,8 +26,6 @@ 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); } @@ -43,8 +36,6 @@ 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); } @@ -55,8 +46,6 @@ 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'); } @@ -67,8 +56,6 @@ 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); } @@ -79,8 +66,6 @@ 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 47fd0cd2be3..a7acf5939b4 100644 --- a/lib/Github/Api/Repository/Checks/CheckSuites.php +++ b/lib/Github/Api/Repository/Checks/CheckSuites.php @@ -3,15 +3,12 @@ namespace Github\Api\Repository\Checks; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; /** * @link https://docs.github.com/rest/checks/suites */ class CheckSuites extends AbstractApi { - use AcceptHeaderTrait; - /** * @link https://docs.github.com/rest/checks/suites#create-a-check-suite * @@ -19,8 +16,6 @@ class CheckSuites extends AbstractApi */ 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); } @@ -31,8 +26,6 @@ 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); } @@ -43,8 +36,6 @@ 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); } @@ -55,8 +46,6 @@ 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'); } @@ -67,8 +56,6 @@ 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); } } diff --git a/lib/Github/Api/Repository/Comments.php b/lib/Github/Api/Repository/Comments.php index 01cd1dff38e..2868b90d179 100644 --- a/lib/Github/Api/Repository/Comments.php +++ b/lib/Github/Api/Repository/Comments.php @@ -32,7 +32,7 @@ public function configure($bodyType = null) $bodyType = 'full'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType); return $this; } diff --git a/lib/Github/Api/Repository/Contents.php b/lib/Github/Api/Repository/Contents.php index 96352129109..a44e860c84f 100644 --- a/lib/Github/Api/Repository/Contents.php +++ b/lib/Github/Api/Repository/Contents.php @@ -33,7 +33,7 @@ public function configure($bodyType = null) $bodyType = 'raw'; } - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->getApiVersion(), $bodyType); + $this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType); return $this; } diff --git a/lib/Github/Api/Repository/Pages.php b/lib/Github/Api/Repository/Pages.php index a66fcfc2adc..a87f2a79ca4 100644 --- a/lib/Github/Api/Repository/Pages.php +++ b/lib/Github/Api/Repository/Pages.php @@ -3,7 +3,6 @@ namespace Github\Api\Repository; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; /** * @link https://docs.github.com/rest/pages/pages @@ -12,8 +11,6 @@ */ class Pages extends AbstractApi { - use AcceptHeaderTrait; - /** * Get a GitHub Pages site for a repository. * @@ -42,8 +39,6 @@ public function show($username, $repository) */ public function enable($username, $repository, array $params = []) { - $this->acceptHeaderValue = 'application/vnd.github.switcheroo-preview+json'; - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages', $params); } @@ -59,8 +54,6 @@ public function enable($username, $repository, array $params = []) */ public function disable($username, $repository) { - $this->acceptHeaderValue = 'application/vnd.github.switcheroo-preview+json'; - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages'); } diff --git a/lib/Github/Api/Repository/Protection.php b/lib/Github/Api/Repository/Protection.php index 24a65e5fd1c..1fab8a0e48b 100644 --- a/lib/Github/Api/Repository/Protection.php +++ b/lib/Github/Api/Repository/Protection.php @@ -3,7 +3,6 @@ namespace Github\Api\Repository; use Github\Api\AbstractApi; -use Github\Api\AcceptHeaderTrait; /** * @link https://docs.github.com/rest/branches/branch-protection @@ -12,8 +11,6 @@ */ class Protection extends AbstractApi { - use AcceptHeaderTrait; - /** * Retrieves configured protection for the provided branch. * @@ -27,9 +24,6 @@ class Protection extends AbstractApi */ public function show($username, $repository, $branch) { - // Preview endpoint - $this->acceptHeaderValue = 'application/vnd.github.luke-cage-preview+json'; - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection'); } @@ -47,9 +41,6 @@ public function show($username, $repository, $branch) */ public function update($username, $repository, $branch, array $params = []) { - // Preview endpoint - $this->acceptHeaderValue = 'application/vnd.github.luke-cage-preview+json'; - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection', $params); } diff --git a/lib/Github/Api/Repository/Stargazers.php b/lib/Github/Api/Repository/Stargazers.php index be8f8831d70..9a34870fa20 100644 --- a/lib/Github/Api/Repository/Stargazers.php +++ b/lib/Github/Api/Repository/Stargazers.php @@ -27,7 +27,7 @@ class Stargazers extends AbstractApi public function configure($bodyType = null) { if ('star' === $bodyType) { - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->getApiVersion()); + $this->acceptHeaderValue = 'application/vnd.github.star+json'; } return $this; diff --git a/lib/Github/Api/Search.php b/lib/Github/Api/Search.php index a961e223c99..8a488f6d539 100644 --- a/lib/Github/Api/Search.php +++ b/lib/Github/Api/Search.php @@ -71,7 +71,7 @@ public function code($q, $sort = 'updated', $order = 'desc') */ public function codeWithMatch(string $q, string $sort = 'updated', string $order = 'desc'): array { - $this->acceptHeaderValue = 'application/vnd.github.v3.text-match+json'; + $this->acceptHeaderValue = 'application/vnd.github.text-match+json'; return $this->code($q, $sort, $order); } @@ -105,9 +105,6 @@ public function users($q, $sort = 'updated', $order = 'desc') */ public function commits($q, $sort = null, $order = 'desc') { - // This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.cloak-preview'; - return $this->get('/search/commits', ['q' => $q, 'sort' => $sort, 'order' => $order]); } @@ -122,9 +119,6 @@ public function commits($q, $sort = null, $order = 'desc') */ public function topics($q) { - // This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - return $this->get('/search/topics', ['q' => $q]); } } diff --git a/lib/Github/Client.php b/lib/Github/Client.php index 49ff9e1a9bc..24e512597f1 100644 --- a/lib/Github/Client.php +++ b/lib/Github/Client.php @@ -135,7 +135,7 @@ public function __construct(?Builder $httpClientBuilder = null, $apiVersion = nu $builder->addPlugin(new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('https://api.github.com'))); $builder->addPlugin(new Plugin\HeaderDefaultsPlugin([ 'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)', - 'Accept' => sprintf('application/vnd.github.%s+json', $this->apiVersion), + 'Accept' => 'application/vnd.github+json', ])); if ($enterpriseUrl) {