feat: Add user endpoint

This commit is contained in:
Michael Gerdemann
2020-01-19 15:53:23 +01:00
parent 6e6b0b6a29
commit 5c2450116b
7 changed files with 421 additions and 27 deletions

View 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);
}
}