mirror of
https://github.com/avency/Gitea.git
synced 2025-10-29 02:34:59 +01:00
feat: Add issues endpoint
This commit is contained in:
47
Classes/Endpoint/Issues.php
Normal file
47
Classes/Endpoint/Issues.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
use Avency\Gitea\Endpoint\Issues\CommentsTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\IssuesTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\IssueTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\LabelsTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\MilestonesTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\ReactionsTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\StopwatchTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\SubscriptionsTrait;
|
||||
use Avency\Gitea\Endpoint\Issues\TimesTrait;
|
||||
|
||||
/**
|
||||
* Issues endpoint
|
||||
*/
|
||||
class Issues extends AbstractEndpoint implements EndpointInterface
|
||||
{
|
||||
use CommentsTrait;
|
||||
use IssueTrait;
|
||||
use IssuesTrait;
|
||||
use LabelsTrait;
|
||||
use MilestonesTrait;
|
||||
use ReactionsTrait;
|
||||
use StopwatchTrait;
|
||||
use SubscriptionsTrait;
|
||||
use TimesTrait;
|
||||
|
||||
const BASE_URI = '/repos';
|
||||
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
*/
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
}
|
||||
140
Classes/Endpoint/Issues/CommentsTrait.php
Normal file
140
Classes/Endpoint/Issues/CommentsTrait.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Comments Trait
|
||||
*/
|
||||
trait CommentsTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return array
|
||||
*/
|
||||
public function getComments(string $owner, string $repositoryName): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/comments');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteComment(string $owner, string $repositoryName, int $id): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/comments/' . $id, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @param string $body
|
||||
* @return array
|
||||
*/
|
||||
public function updateComment(string $owner, string $repositoryName, int $id, string $body): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'body' => $body
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/comments/' . $id, 'PATCH', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function getCommentReactions(string $owner, string $repositoryName, int $id): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'body' => $body
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/comments/' . $id . '/reactions');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @param string $reaction
|
||||
* @return array
|
||||
*/
|
||||
public function addCommentReaction(string $owner, string $repositoryName, int $id, string $reaction): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'content' => $reaction
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/comments/' . $id . '/reactions', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @param string $reaction
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteCommentReaction(string $owner, string $repositoryName, int $id, string $reaction): bool
|
||||
{
|
||||
$options['json'] = [
|
||||
'content' => $reaction
|
||||
];
|
||||
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/comments/' . $id . '/reactions', 'DELETE', $options);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return array
|
||||
*/
|
||||
public function getIssueComments(string $owner, string $repositoryName, int $index): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/comments');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string $body
|
||||
* @return array
|
||||
*/
|
||||
public function addIssueComment(string $owner, string $repositoryName, int $index, string $body): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'body' => $body
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/comments', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
101
Classes/Endpoint/Issues/IssueTrait.php
Normal file
101
Classes/Endpoint/Issues/IssueTrait.php
Normal file
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Issue Trait
|
||||
*/
|
||||
trait IssueTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return array
|
||||
*/
|
||||
public function get(string $owner, string $repositoryName, int $index): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string|null $assignee
|
||||
* @param array|null $assignees
|
||||
* @param string|null $body
|
||||
* @param \DateTime|null $dueDate
|
||||
* @param int|null $milestone
|
||||
* @param string|null $state
|
||||
* @param string|null $title
|
||||
* @param bool|null $unsetDueDate
|
||||
* @return array
|
||||
*/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
int $index,
|
||||
string $assignee = null,
|
||||
array $assignees = null,
|
||||
string $body = null,
|
||||
\DateTime $dueDate = null,
|
||||
int $milestone = null,
|
||||
string $state = null,
|
||||
string $title = null,
|
||||
bool $unsetDueDate = null
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'assignee' => $assignee,
|
||||
'assignees' => $assignees,
|
||||
'body' => $body,
|
||||
'due_date' => $dueDate ? $dueDate->format(\DateTime::ATOM) : null,
|
||||
'mileston' => $milestone,
|
||||
'state' => $state,
|
||||
'title' => $title,
|
||||
'unset_due_date' => $unsetDueDate,
|
||||
];
|
||||
$options['json'] = $this->removeNullValues($options['json']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index, 'PATCH', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param string|null $assignee
|
||||
* @param array|null $assignees
|
||||
* @param string|null $body
|
||||
* @param \DateTime|null $dueDate
|
||||
* @param int|null $milestone
|
||||
* @param string|null $state
|
||||
* @param string|null $title
|
||||
* @param bool|null $unsetDueDate
|
||||
* @return array
|
||||
*/
|
||||
public function setDeadline(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
int $index,
|
||||
\DateTime $dueDate
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'due_date' => $dueDate->format(\DateTime::ATOM),
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/deadline', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
98
Classes/Endpoint/Issues/IssuesTrait.php
Normal file
98
Classes/Endpoint/Issues/IssuesTrait.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Issues Trait
|
||||
*/
|
||||
trait IssuesTrait
|
||||
{
|
||||
/**
|
||||
* @param string|null $searchTerm
|
||||
* @param string|null $state
|
||||
* @param string|null $labels
|
||||
* @param int|null $page
|
||||
* @param int|null $priorityRepoId
|
||||
* @return array
|
||||
*/
|
||||
public function search(
|
||||
string $searchTerm = null,
|
||||
string $state = null,
|
||||
string $labels = null,
|
||||
int $page = null,
|
||||
int $priorityRepoId = null
|
||||
): array
|
||||
{
|
||||
$options['query'] = [
|
||||
'q' => $searchTerm,
|
||||
'state' => $state,
|
||||
'labels' => $labels,
|
||||
'page' => $page,
|
||||
'priority_repo_id' => $priorityRepoId,
|
||||
];
|
||||
$options['query'] = $this->removeNullValues($options['query']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/issues/search', 'GET', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return array
|
||||
*/
|
||||
public function getIssues(string $owner, string $repositoryName): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param string $title
|
||||
* @param string|null $assignee
|
||||
* @param array|null $assignees
|
||||
* @param string|null $body
|
||||
* @param bool|null $closed
|
||||
* @param \Datetime|null $dueDate
|
||||
* @param array|null $labels
|
||||
* @param int|null $milestone
|
||||
* @return array
|
||||
*/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
string $title,
|
||||
string $assignee = null,
|
||||
array $assignees = null,
|
||||
string $body = null,
|
||||
bool $closed = null,
|
||||
\Datetime $dueDate = null,
|
||||
array $labels = null,
|
||||
int $milestone = null
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'title' => $title,
|
||||
'assignee' => $assignee,
|
||||
'assignees' => $assignees,
|
||||
'body' => $body,
|
||||
'closed' => $closed,
|
||||
'due_date' => $dueDate ? $dueDate->format(\DateTime::ATOM) : null,
|
||||
'labels' => $labels,
|
||||
'milestone' => $milestone,
|
||||
];
|
||||
$options['json'] = $this->removeNullValues($options['json']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
154
Classes/Endpoint/Issues/LabelsTrait.php
Normal file
154
Classes/Endpoint/Issues/LabelsTrait.php
Normal file
@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Labels Trait
|
||||
*/
|
||||
trait LabelsTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return array
|
||||
*/
|
||||
public function getLabels(string $owner, string $repositoryName, int $index): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/labels');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param array $labels
|
||||
* @return array
|
||||
*/
|
||||
public function replaceLabels(string $owner, string $repositoryName, int $index, array $labels): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'labels' => $labels
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/labels', 'PUT', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param array $labels
|
||||
* @return array
|
||||
*/
|
||||
public function addLabels(string $owner, string $repositoryName, int $index, array $labels): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'labels' => $labels
|
||||
];
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/labels', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteAllLabels(string $owner, string $repositoryName, int $index): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/labels', 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteLabel(string $owner, string $repositoryName, int $index, int $id): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/labels/' . $id, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return array
|
||||
*/
|
||||
public function getRepositoryLabels(string $owner, string $repositoryName): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/labels');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function getRepositoryLabel(string $owner, string $repositoryName, int $id): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/labels/' . $id);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function updateRepositoryLabel(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
int $id,
|
||||
string $name = null,
|
||||
string $description = null,
|
||||
string $color = null
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'name' => $name,
|
||||
'description' => $description,
|
||||
'color' => $color,
|
||||
];
|
||||
$options['json'] = $this->removeNullValues($options['json']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/labels/' . $id, 'PATCH', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteRepositoryLabel(string $owner, string $repositoryName, int $id): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/labels/' . $id, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
112
Classes/Endpoint/Issues/MilestonesTrait.php
Normal file
112
Classes/Endpoint/Issues/MilestonesTrait.php
Normal file
@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Milestones Trait
|
||||
*/
|
||||
trait MilestonesTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @return array
|
||||
*/
|
||||
public function getMilestones(string $owner, string $repositoryName): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/milestones');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param string $title
|
||||
* @param string|null $description
|
||||
* @param \DateTime|null $dueDate
|
||||
* @return array
|
||||
*/
|
||||
public function addMilestone(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
string $title,
|
||||
string $description = null,
|
||||
\DateTime $dueDate = null
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'due_date' => $dueDate ? $dueDate->format(\DateTime::ATOM) : null,
|
||||
];
|
||||
$options['json'] = $this->removeNullValues($options['json']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/milestones', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
public function getMilestone(string $owner, string $repositoryName, int $id): array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/milestones/' . $id);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteMilestone(string $owner, string $repositoryName, int $id): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/milestones/' . $id, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $id
|
||||
* @param string|null $title
|
||||
* @param string|null $description
|
||||
* @param \DateTime|null $dueDate
|
||||
* @param string|null $state
|
||||
* @return array
|
||||
*/
|
||||
public function updateMilestone(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
int $id,
|
||||
string $title = null,
|
||||
string $description = null,
|
||||
\DateTime $dueDate = null,
|
||||
string $state = null
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'due_date' => $dueDate ? $dueDate->format(\DateTime::ATOM) : null,
|
||||
'state' => $state,
|
||||
];
|
||||
$options['json'] = $this->removeNullValues($options['json']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/milestones/' . $id, 'PATCH', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
52
Classes/Endpoint/Issues/StopwatchTrait.php
Normal file
52
Classes/Endpoint/Issues/StopwatchTrait.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Stopwatch Trait
|
||||
*/
|
||||
trait StopwatchTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return bool
|
||||
*/
|
||||
public function startStopwatch(string $owner, string $repositoryName, int $index): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/stopwatch/start', 'POST');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return bool
|
||||
*/
|
||||
public function stopStopwatch(string $owner, string $repositoryName, int $index): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/stopwatch/stop', 'POST');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteStopwatch(string $owner, string $repositoryName, int $index): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/stopwatch/delete', 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
83
Classes/Endpoint/Issues/TimesTrait.php
Normal file
83
Classes/Endpoint/Issues/TimesTrait.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Avency\Gitea\Endpoint\Issues;
|
||||
|
||||
use Avency\Gitea\Client;
|
||||
|
||||
/**
|
||||
* Issues Times Trait
|
||||
*/
|
||||
trait TimesTrait
|
||||
{
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return array|null
|
||||
*/
|
||||
public function getTimes(string $owner, string $repositoryName, int $index): ?array
|
||||
{
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/times');
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteAllTimes(string $owner, string $repositoryName, int $index): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/times', 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param int $id
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteTime(string $owner, string $repositoryName, int $index, int $id): bool
|
||||
{
|
||||
$this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/times/' . $id, 'DELETE');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $owner
|
||||
* @param string $repositoryName
|
||||
* @param int $index
|
||||
* @param int $time
|
||||
* @param string|null $username
|
||||
* @param \DateTime|null $createdDate
|
||||
* @return array
|
||||
*/
|
||||
public function addTime(
|
||||
string $owner,
|
||||
string $repositoryName,
|
||||
int $index,
|
||||
int $time,
|
||||
string $username = null,
|
||||
\DateTime $createdDate = null
|
||||
): array
|
||||
{
|
||||
$options['json'] = [
|
||||
'time' => $time,
|
||||
'user_name' => $username,
|
||||
'created' => $createdDate ? $createdDate->format(\DateTime::ATOM) : null,
|
||||
];
|
||||
$options['json'] = $this->removeNullValues($options['json']);
|
||||
|
||||
$response = $this->client->request(self::BASE_URI . '/' . $owner . '/' . $repositoryName . '/issues/' . $index . '/times', 'POST', $options);
|
||||
|
||||
return \GuzzleHttp\json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user