gitea/src/73b3ebfa-c52a-4a96-a8de-718.../code.power

77 lines
2.1 KiB
Plaintext

/**
* Get a list of reactions from a comment of an issue.
*
* @param string $owner The owner name.
* @param string $repo The repo name.
* @param int $commentId The comment ID.
*
* @return array|null
* @since 3.2.0
**/
public function list(string $owner, string $repo, int $commentId): ?array
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions";
// Send the get request.
return $this->response->get(
$this->http->get(
$this->uri->get($path)
)
);
}
/**
* Add a reaction to a comment of an issue.
*
* @param string $owner The owner name.
* @param string $repo The repo name.
* @param int $commentId The comment ID.
* @param string $content The reaction to add, e.g. "+1".
*
* @return object|null
* @since 3.2.0
**/
public function add(string $owner, string $repo, int $commentId, string $content): ?object
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions";
// Build the request data.
$data = new \stdClass();
$data->content = $content;
// Send the post request.
return $this->response->get(
$this->http->post(
$this->uri->get($path), json_encode($data)
)
);
}
/**
* Remove a reaction from a comment of an issue.
*
* @param string $owner The owner name.
* @param string $repo The repo name.
* @param int $commentId The comment ID.
* @param string $content The reaction to remove, e.g. "+1".
*
* @return string
* @since 3.2.0
**/
public function remove(string $owner, string $repo, int $commentId, string $content): string
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions";
// Build the URI.
$uri = $this->uri->get($path);
$uri->setVar('content', $content);
// Send the delete request.
return $this->response->get(
$this->http->delete($uri), 200, 'success'
);
}