mirror of
https://github.com/avency/Gitea.git
synced 2025-10-29 18:52:33 +01:00
feat: Add issues endpoint
This commit is contained in:
62
Classes/Endpoint/Issues/ReactionsTrait.php
Normal file
62
Classes/Endpoint/Issues/ReactionsTrait.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Reactions Trait
|
||||
*/
|
||||
trait ReactionsTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return array|null
|
||||
*/
|
||||
public function getReactions(string $owner, string $repositoryName, int $index): ?array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/reactions');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string $reaction
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteReaction(string $owner, string $repositoryName, int $index, string $reaction): bool
|
||||
{
|
||||
$options['json'] = [
|
||||
'content' => $reaction
|
||||
];
|
||||
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/reactions', 'DELETE', $options);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string $reaction
|
||||
* @return array
|
||||
*/
|
||||
public function addReaction(string $owner, string $repositoryName, int $index, string $reaction): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'content' => $reaction
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/reactions', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user