Update to laravel 7

This commit is contained in:
KodeStar
2022-03-10 11:54:29 +00:00
parent 61a5a1a8b0
commit f9a19fce91
7170 changed files with 274189 additions and 283773 deletions

View File

@@ -0,0 +1,82 @@
<?php
namespace Github\Api\Repository\Actions;
use Github\Api\AbstractApi;
/**
* @link https://docs.github.com/en/rest/reference/actions#artifacts
*/
class Artifacts extends AbstractApi
{
/**
* @link https://docs.github.com/en/rest/reference/actions#list-artifacts-for-a-repository
*
* @param string $username
* @param string $repository
* @param array $parameters
*
* @return array
*/
public function all(string $username, string $repository, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts', $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#list-workflow-run-artifacts
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array
*/
public function runArtifacts(string $username, string $repository, int $runId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/artifacts');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-an-artifact
*
* @param string $username
* @param string $repository
* @param int $artifactId
*
* @return array
*/
public function show(string $username, string $repository, int $artifactId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#delete-an-artifact
*
* @param string $username
* @param string $repository
* @param int $artifactId
*
* @return array
*/
public function remove(string $username, string $repository, int $artifactId)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#download-an-artifact
*
* @param string $username
* @param string $repository
* @param int $artifactId
* @param string $format
*
* @return array
*/
public function download(string $username, string $repository, int $artifactId, string $format = 'zip')
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId.'/'.$format);
}
}

View File

@@ -0,0 +1,95 @@
<?php
namespace Github\Api\Repository\Actions;
use Github\Api\AbstractApi;
/**
* @link https://docs.github.com/en/rest/reference/actions#secrets
*/
class Secrets extends AbstractApi
{
/**
* @link https://docs.github.com/en/rest/reference/actions#list-repository-secrets
*
* @param string $username
* @param string $repository
*
* @return array|string
*/
public function all(string $username, string $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-a-repository-secret
*
* @param string $username
* @param string $repository
* @param string $secretName
*
* @return array|string
*/
public function show(string $username, string $repository, string $secretName)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName));
}
/**
* @link https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret
*
* @param string $username
* @param string $repository
* @param string $secretName
* @param array $parameters
*
* @return array|string
*/
public function create(string $username, string $repository, string $secretName, array $parameters = [])
{
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName), $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret
*
* @param string $username
* @param string $repository
* @param string $secretName
* @param array $parameters
*
* @return array|string
*/
public function update(string $username, string $repository, string $secretName, array $parameters = [])
{
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName), $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret
*
* @param string $username
* @param string $repository
* @param string $secretName
*
* @return array|string
*/
public function remove(string $username, string $repository, string $secretName)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName));
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key
*
* @param string $username
* @param string $repository
*
* @return array|string
*/
public function publicKey(string $username, string $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/public-key');
}
}

View File

@@ -0,0 +1,65 @@
<?php
namespace Github\Api\Repository\Actions;
use Github\Api\AbstractApi;
/**
* @link https://docs.github.com/en/rest/reference/actions#self-hosted-runners
*/
class SelfHostedRunners extends AbstractApi
{
/**
* @link https://docs.github.com/en/rest/reference/actions#list-self-hosted-runners-for-a-repository
*
* @param string $username
* @param string $repository
*
* @return array|string
*/
public function all(string $username, string $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurldecode($repository).'/actions/runners');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-a-self-hosted-runner-for-a-repository
*
* @param string $username
* @param string $repository
* @param int $runnerId
*
* @return array|string
*/
public function show(string $username, string $repository, int $runnerId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurldecode($repository).'/actions/runners/'.$runnerId);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#delete-a-self-hosted-runner-from-a-repository
*
* @param string $username
* @param string $repository
* @param int $runnerId
*
* @return array|string
*/
public function remove(string $username, string $repository, int $runnerId)
{
return $this->delete('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/actions/runners/'.$runnerId);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#list-runner-applications-for-a-repository
*
* @param string $username
* @param string $repository
*
* @return array|string
*/
public function applications(string $username, string $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runners/downloads');
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Github\Api\Repository\Actions;
use Github\Api\AbstractApi;
/**
* @link https://docs.github.com/en/rest/reference/actions#workflow-jobs
*/
class WorkflowJobs extends AbstractApi
{
/**
* @link https://docs.github.com/en/rest/reference/actions#list-jobs-for-a-workflow-run
*
* @param string $username
* @param string $repository
* @param int $runId
* @param array $parameters
*
* @return array
*/
public function all(string $username, string $repository, int $runId, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/jobs', $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-a-job-for-a-workflow-run
*
* @param string $username
* @param string $repository
* @param int $jobId
*
* @return array
*/
public function show(string $username, string $repository, int $jobId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/jobs/'.$jobId);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#download-job-logs-for-a-workflow-run
*
* @param string $username
* @param string $repository
* @param int $jobId
*
* @return array
*/
public function downloadLogs(string $username, string $repository, int $jobId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/jobs/'.$jobId.'/logs');
}
}

View File

@@ -0,0 +1,155 @@
<?php
namespace Github\Api\Repository\Actions;
use Github\Api\AbstractApi;
/**
* @link https://docs.github.com/en/rest/reference/actions#workflow-runs
*/
class WorkflowRuns extends AbstractApi
{
/**
* @link https://docs.github.com/en/rest/reference/actions#list-workflow-runs-for-a-repository
*
* @param string $username
* @param string $repository
* @param array $parameters
*
* @return array
*/
public function all(string $username, string $repository, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs', $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#list-workflow-runs
*
* @param string $username
* @param string $repository
* @param string $workflow
* @param array $parameters
*
* @return array
*/
public function listRuns(string $username, string $repository, string $workflow, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.rawurlencode($workflow).'/runs', $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-a-workflow-run
*
* @param string $username
* @param string $repository
* @param int $runId
* @param array $parameters
*
* @return array
*/
public function show(string $username, string $repository, int $runId, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId, $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array|string
*/
public function remove(string $username, string $repository, int $runId)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#re-run-a-workflow
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array
*/
public function rerun(string $username, string $repository, int $runId)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/rerun');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#cancel-a-workflow-run
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array
*/
public function cancel(string $username, string $repository, int $runId)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/cancel');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-workflow-run-usage
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array
*/
public function usage(string $username, string $repository, int $runId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/timing');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#download-workflow-run-logs
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array|string
*/
public function downloadLogs(string $username, string $repository, int $runId)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#delete-workflow-run-logs
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array|string
*/
public function deleteLogs(string $username, string $repository, int $runId)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#approve-a-workflow-run-for-a-fork-pull-request
*
* @param string $username
* @param string $repository
* @param int $runId
*
* @return array|string
*
* @experimental This endpoint is currently in beta.
*/
public function approve(string $username, string $repository, int $runId)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/approve');
}
}

View File

@@ -0,0 +1,82 @@
<?php
namespace Github\Api\Repository\Actions;
use Github\Api\AbstractApi;
/**
* @link https://docs.github.com/en/rest/reference/actions#workflows
*/
class Workflows extends AbstractApi
{
/**
* @link https://docs.github.com/en/rest/reference/actions#list-repository-workflows
*
* @param string $username
* @param string $repository
* @param array $parameters
*
* @return array
*/
public function all(string $username, string $repository, array $parameters = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows', $parameters);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-a-workflow
*
* @param string $username
* @param string $repository
* @param string|int $workflow
*
* @return array
*/
public function show(string $username, string $repository, $workflow)
{
if (is_string($workflow)) {
$workflow = rawurlencode($workflow);
}
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow);
}
/**
* @link https://docs.github.com/en/rest/reference/actions#get-workflow-usage
*
* @param string $username
* @param string $repository
* @param string|int $workflow
*
* @return array|string
*/
public function usage(string $username, string $repository, $workflow)
{
if (is_string($workflow)) {
$workflow = rawurlencode($workflow);
}
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow.'/timing');
}
/**
* @link https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
*
* @param string $username
* @param string $repository
* @param string|int $workflow
* @param string $ref
* @param array $inputs
*
* @return array|string empty
*/
public function dispatches(string $username, string $repository, $workflow, string $ref, array $inputs = null)
{
if (is_string($workflow)) {
$workflow = rawurlencode($workflow);
}
$parameters = array_filter(['ref' => $ref, 'inputs' => $inputs]);
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow.'/dispatches', $parameters);
}
}

View File

@@ -3,6 +3,7 @@
namespace Github\Api\Repository;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
use Github\Exception\ErrorException;
use Github\Exception\MissingArgumentException;
@@ -13,6 +14,8 @@ use Github\Exception\MissingArgumentException;
*/
class Assets extends AbstractApi
{
use AcceptHeaderTrait;
/**
* Get all release's assets in selected repository
* GET /repos/:owner/:repo/releases/:id/assets.
@@ -25,7 +28,7 @@ class Assets extends AbstractApi
*/
public function all($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id).'/assets');
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id.'/assets');
}
/**
@@ -36,11 +39,15 @@ class Assets extends AbstractApi
* @param string $repository the name of the repo
* @param int $id the id of the asset
*
* @return array
* @return array|string
*/
public function show($username, $repository, $id)
public function show($username, $repository, $id, bool $returnBinaryContent = false)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.rawurlencode($id));
if ($returnBinaryContent) {
$this->acceptHeaderValue = 'application/octet-stream';
}
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id);
}
/**
@@ -67,16 +74,14 @@ class Assets extends AbstractApi
*/
public function create($username, $repository, $id, $name, $contentType, $content)
{
if (!defined('OPENSSL_TLSEXT_SERVER_NAME') || !OPENSSL_TLSEXT_SERVER_NAME) {
throw new ErrorException('Asset upload support requires Server Name Indication. This is not supported by your PHP version. See http://php.net/manual/en/openssl.constsni.php.');
if (!defined('OPENSSL_TLSEXT_SERVER_NAME') || OPENSSL_TLSEXT_SERVER_NAME == 0) {
throw new ErrorException('Asset upload support requires Server Name Indication. This is not supported by your PHP version. See https://www.php.net/manual/en/openssl.constsni.php.');
}
// Asset creation requires a separate endpoint, uploads.github.com.
// Change the base url for the HTTP client temporarily while we execute
// this request.
$response = $this->postRaw('https://uploads.github.com/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id).'/assets?name='.$name, $content, ['Content-Type' => $contentType]);
return $response;
return $this->postRaw('https://uploads.github.com/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id.'/assets?name='.$name, $content, ['Content-Type' => $contentType]);
}
/**
@@ -98,7 +103,7 @@ class Assets extends AbstractApi
throw new MissingArgumentException('name');
}
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.rawurlencode($id), $params);
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id, $params);
}
/**
@@ -113,6 +118,6 @@ class Assets extends AbstractApi
*/
public function remove($username, $repository, $id)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.rawurlencode($id));
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id);
}
}

View File

@@ -0,0 +1,86 @@
<?php
namespace Github\Api\Repository\Checks;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
/**
* @link https://docs.github.com/en/rest/reference/checks
*/
class CheckRuns extends AbstractApi
{
use AcceptHeaderTrait;
/**
* @link https://docs.github.com/en/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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#get-a-check-run
*
* @return array
*/
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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#update-a-check-run
*
* @return array
*/
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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#list-check-run-annotations
*
* @return array
*/
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');
}
/**
* @link https://docs.github.com/en/rest/reference/checks#list-check-runs-in-a-check-suite
*
* @return array
*/
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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#list-check-runs-for-a-git-reference
*
* @return array
*/
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);
}
}

View File

@@ -0,0 +1,74 @@
<?php
namespace Github\Api\Repository\Checks;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
/**
* @link https://docs.github.com/en/rest/reference/checks
*/
class CheckSuites extends AbstractApi
{
use AcceptHeaderTrait;
/**
* @link https://docs.github.com/en/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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#update-repository-preferences-for-check-suites
*
* @return array
*/
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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#get-a-check-suite
*
* @return array
*/
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);
}
/**
* @link https://docs.github.com/en/rest/reference/checks#rerequest-a-check-suite
*
* @return array
*/
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');
}
/**
* @link https://docs.github.com/en/rest/reference/checks#list-check-suites-for-a-git-reference
*
* @return array
*/
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);
}
}

View File

@@ -23,7 +23,7 @@ class Comments extends AbstractApi
*
* @param string|null $bodyType
*
* @return self
* @return $this
*/
public function configure($bodyType = null)
{
@@ -31,7 +31,7 @@ class Comments extends AbstractApi
$bodyType = 'full';
}
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->client->getApiVersion(), $bodyType);
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType);
return $this;
}

View File

@@ -25,7 +25,7 @@ class Contents extends AbstractApi
*
* @param string|null $bodyType
*
* @return self
* @return $this
*/
public function configure($bodyType = null)
{
@@ -33,7 +33,7 @@ class Contents extends AbstractApi
$bodyType = 'raw';
}
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->client->getApiVersion(), $bodyType);
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->getApiVersion(), $bodyType);
return $this;
}
@@ -45,7 +45,7 @@ class Contents extends AbstractApi
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param null|string $reference reference to a branch or commit
* @param string|null $reference reference to a branch or commit
*
* @return array information for README file
*/
@@ -63,8 +63,8 @@ class Contents extends AbstractApi
*
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param null|string $path path to file or directory
* @param null|string $reference reference to a branch or commit
* @param string|null $path path to file or directory
* @param string|null $reference reference to a branch or commit
*
* @return array|string information for file | information for each item in directory
*/
@@ -90,7 +90,7 @@ class Contents extends AbstractApi
* @param string $path path to file
* @param string $content contents of the new file
* @param string $message the commit message
* @param null|string $branch name of a branch
* @param string|null $branch name of a branch
* @param null|array $committer information about the committer
*
* @throws MissingArgumentException
@@ -102,8 +102,8 @@ class Contents extends AbstractApi
$url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path);
$parameters = [
'content' => base64_encode($content),
'message' => $message,
'content' => base64_encode($content),
'message' => $message,
];
if (null !== $branch) {
@@ -126,7 +126,7 @@ class Contents extends AbstractApi
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $path path of file to check
* @param null|string $reference reference to a branch or commit
* @param string|null $reference reference to a branch or commit
*
* @return bool
*/
@@ -166,7 +166,7 @@ class Contents extends AbstractApi
* @param string $content contents of the new file
* @param string $message the commit message
* @param string $sha blob SHA of the file being replaced
* @param null|string $branch name of a branch
* @param string|null $branch name of a branch
* @param null|array $committer information about the committer
*
* @throws MissingArgumentException
@@ -178,9 +178,9 @@ class Contents extends AbstractApi
$url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path);
$parameters = [
'content' => base64_encode($content),
'message' => $message,
'sha' => $sha,
'content' => base64_encode($content),
'message' => $message,
'sha' => $sha,
];
if (null !== $branch) {
@@ -207,7 +207,7 @@ class Contents extends AbstractApi
* @param string $path path to file
* @param string $message the commit message
* @param string $sha blob SHA of the file being deleted
* @param null|string $branch name of a branch
* @param string|null $branch name of a branch
* @param null|array $committer information about the committer
*
* @throws MissingArgumentException
@@ -219,8 +219,8 @@ class Contents extends AbstractApi
$url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path);
$parameters = [
'message' => $message,
'sha' => $sha,
'message' => $message,
'sha' => $sha,
];
if (null !== $branch) {
@@ -245,7 +245,7 @@ class Contents extends AbstractApi
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $format format of archive: tarball or zipball
* @param null|string $reference reference to a branch or commit
* @param string|null $reference reference to a branch or commit
*
* @return string repository archive binary data
*/
@@ -265,12 +265,12 @@ class Contents extends AbstractApi
* @param string $username the user who owns the repository
* @param string $repository the name of the repository
* @param string $path path to file
* @param null|string $reference reference to a branch or commit
* @param string|null $reference reference to a branch or commit
*
* @throws InvalidArgumentException If $path is not a file or if its encoding is different from base64
* @throws ErrorException If $path doesn't include a 'content' index
*
* @return null|string content of file, or null in case of base64_decode failure
* @return string|null content of file, or null in case of base64_decode failure
*/
public function download($username, $repository, $path, $reference = null)
{

View File

@@ -37,7 +37,9 @@ class DeployKeys extends AbstractApi
throw new MissingArgumentException(['title', 'key']);
}
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys/'.rawurlencode($id), $params);
$this->remove($username, $repository, $id);
return $this->create($username, $repository, $params);
}
public function remove($username, $repository, $id)

View File

@@ -39,7 +39,7 @@ class Downloads extends AbstractApi
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads/'.rawurlencode($id));
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads/'.$id);
}
/**
@@ -55,6 +55,6 @@ class Downloads extends AbstractApi
*/
public function remove($username, $repository, $id)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads/'.rawurlencode($id));
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads/'.$id);
}
}

View File

@@ -47,7 +47,7 @@ class Hooks extends AbstractApi
public function test($username, $repository, $id)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id).'/test');
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id).'/tests');
}
public function remove($username, $repository, $id)

View File

@@ -33,10 +33,6 @@ class Labels extends AbstractApi
public function update($username, $repository, $label, array $params)
{
if (!isset($params['name'], $params['color'])) {
throw new MissingArgumentException(['name', 'color']);
}
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params);
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Github\Api\Repository;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
/**
* @link https://developer.github.com/v3/repos/pages/
*
* @author yunwuxin <tzzhangyajun@qq.com>
*/
class Pages extends AbstractApi
{
use AcceptHeaderTrait;
public function show($username, $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages');
}
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);
}
public function disable($username, $repository)
{
$this->acceptHeaderValue = 'application/vnd.github.switcheroo-preview+json';
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages');
}
public function update($username, $repository, array $params = [])
{
return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages', $params);
}
public function requestBuild($username, $repository)
{
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds');
}
public function builds($username, $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds');
}
public function showLatestBuild($username, $repository)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds/latest');
}
public function showBuild($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds/'.rawurlencode($id));
}
}

View File

@@ -14,13 +14,6 @@ class Protection extends AbstractApi
{
use AcceptHeaderTrait;
public function configure()
{
$this->acceptHeaderValue = 'application/vnd.github.loki-preview+json';
return $this;
}
/**
* Retrieves configured protection for the provided branch.
*
@@ -34,6 +27,9 @@ 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');
}
@@ -51,6 +47,9 @@ class Protection extends AbstractApi
*/
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);
}

View File

@@ -65,7 +65,7 @@ class Releases extends AbstractApi
*/
public function show($username, $repository, $id)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id));
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id);
}
/**
@@ -100,7 +100,7 @@ class Releases extends AbstractApi
*/
public function edit($username, $repository, $id, array $params)
{
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id), $params);
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id, $params);
}
/**
@@ -114,7 +114,7 @@ class Releases extends AbstractApi
*/
public function remove($username, $repository, $id)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id));
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id);
}
/**
@@ -122,6 +122,6 @@ class Releases extends AbstractApi
*/
public function assets()
{
return new Assets($this->client);
return new Assets($this->getClient());
}
}

View File

@@ -22,12 +22,12 @@ class Stargazers extends AbstractApi
*
* @param string $bodyType
*
* @return self
* @return $this
*/
public function configure($bodyType = null)
{
if ('star' === $bodyType) {
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->client->getApiVersion());
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->getApiVersion());
}
return $this;