mirror of
https://github.com/avency/Gitea.git
synced 2025-10-30 03:02:32 +01:00
feat: Add user endpoint
This commit is contained in:
66
Classes/Endpoint/User/FollowersTrait.php
Normal file
66
Classes/Endpoint/User/FollowersTrait.php
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user