mirror of
https://github.com/avency/Gitea.git
synced 2025-10-28 18:24:58 +01:00
feat: Add user endpoint
This commit is contained in:
79
Classes/Endpoint/User/RepositoriesTrait.php
Normal file
79
Classes/Endpoint/User/RepositoriesTrait.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\User;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Users Repositories Trait
|
||||
*/
|
||||
trait RepositoriesTrait
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRepositories(): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/repos');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getStarredRepositories(): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/starred');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return bool
|
||||
*/
|
||||
public function checkStarredRepository(string $owner, string $repositoryName): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/starred/' . $owner . '/' . $repositoryName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return bool
|
||||
*/
|
||||
public function addStarredRepository(string $owner, string $repositoryName): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/starred/' . $owner . '/' . $repositoryName, 'PUT');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteStarredRepository(string $owner, string $repositoryName): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/starred/' . $owner . '/' . $repositoryName, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getSubscriptions(): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/subscriptions');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user