mirror of
https://github.com/avency/Gitea.git
synced 2025-10-29 10:42:33 +01:00
feat: Add issues endpoint
This commit is contained in:
54
Classes/Endpoint/Issues/SubscriptionsTrait.php
Normal file
54
Classes/Endpoint/Issues/SubscriptionsTrait.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Subscriptions Trait
|
||||
*/
|
||||
trait SubscriptionsTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return array|null
|
||||
*/
|
||||
public function getSubscriptions(string $owner, string $repositoryName, int $index): ?array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/subscriptions');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string $username
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteSubscription(string $owner, string $repositoryName, int $index, string $username): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/subscriptions/' . $username, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string $username
|
||||
* @return bool
|
||||
*/
|
||||
public function addSubscription(string $owner, string $repositoryName, int $index, string $username): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/subscriptions/' . $username, 'PUT');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user