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,66 @@
<?php
declare(strict_types=1);
namespace Avency\Gitea\Endpoint\User;
use Avency\Gitea\Client;
/**
* Users Followers Trait
*/
trait FollowersTrait
{
/**
* @return array
*/
public function getFollowers(): array
{
$response = $this->client->request(self::BASE_URI . '/followers');
return \GuzzleHttp\json_decode($response->getBody(), true);
}
/**
* @return array
*/
public function getFollowing(): array
{
$response = $this->client->request(self::BASE_URI . '/following');
return \GuzzleHttp\json_decode($response->getBody(), true);
}
/**
* @param string $username
* @return bool
*/
public function checkFollowing(string $username): bool
{
$this->client->request(self::BASE_URI . '/following/' . $username);
return true;
}
/**
* @param string $username
* @return bool
*/
public function addFollowing(string $username): bool
{
$this->client->request(self::BASE_URI . '/following/' . $username, 'PUT');
return true;
}
/**
* @param string $username
* @return bool
*/
public function deleteFollowing(string $username): bool
{
$this->client->request(self::BASE_URI . '/following/' . $username, 'DELETE');
return true;
}
}