From 9f70df5d51b3ca7a56038b6288c50a1ba311458d Mon Sep 17 00:00:00 2001 From: alex gringo Date: Thu, 20 Jun 2024 15:50:49 +0200 Subject: [PATCH 1/2] [SW] - added class to handle API requests with commands --- src/Api/Commands.php | 15 +++++++++++++++ src/Api/Issue.php | 5 +++++ src/Client.php | 6 ++++++ src/HttpClient/HttpClient.php | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/Api/Commands.php diff --git a/src/Api/Commands.php b/src/Api/Commands.php new file mode 100644 index 0000000..537ae38 --- /dev/null +++ b/src/Api/Commands.php @@ -0,0 +1,15 @@ +addFields( + [] + ); + return $this->post("commands", $parameters); + } +} diff --git a/src/Api/Issue.php b/src/Api/Issue.php index ef607b7..f08aa8d 100644 --- a/src/Api/Issue.php +++ b/src/Api/Issue.php @@ -153,4 +153,9 @@ public function timeTracking(): TimeTracking { return new TimeTracking($this->getClient()); } + + public function command($parameters) + { + return $this->post("commands", $parameters); + } } diff --git a/src/Client.php b/src/Client.php index 7faeb95..9051c9f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -4,6 +4,7 @@ use Oveleon\YouTrack\Api\Issue; use Oveleon\YouTrack\Api\Project; +use Oveleon\YouTrack\Api\Commands; use Oveleon\YouTrack\Api\User; use Oveleon\YouTrack\Api\WorkItem; use Oveleon\YouTrack\HttpClient\HttpClientInterface; @@ -30,6 +31,11 @@ public function issues(): Issue return new Issue($this); } + public function commands(): Commands + { + return new Commands($this); + } + public function projects(): Project { return new Project($this); diff --git a/src/HttpClient/HttpClient.php b/src/HttpClient/HttpClient.php index 74998cc..289d5d1 100644 --- a/src/HttpClient/HttpClient.php +++ b/src/HttpClient/HttpClient.php @@ -11,7 +11,7 @@ use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface as SymfonyHttpClientInterface; -class HttpClient implements HttpClientInterface +final class HttpClient implements HttpClientInterface { private SymfonyHttpClientInterface $client; private string $endpoint; From 0716110af60ca4d99e1db28f65617c3959e365ac Mon Sep 17 00:00:00 2001 From: alex gringo Date: Mon, 24 Jun 2024 11:03:12 +0200 Subject: [PATCH 2/2] [SW] - command method removed from issue entity, updating command to match API standarts --- src/Api/Commands.php | 15 +++++++++++---- src/Api/Issue.php | 5 ----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Api/Commands.php b/src/Api/Commands.php index 537ae38..8f12155 100644 --- a/src/Api/Commands.php +++ b/src/Api/Commands.php @@ -4,12 +4,19 @@ class Commands extends AbstractApi { + protected function defaultFields(): self + { + $this->addFields([ + 'id', + 'idReadable', + 'summary' + ]); + + return $this; + } - public function command($parameters) + public function command($parameters): array { - $this->addFields( - [] - ); return $this->post("commands", $parameters); } } diff --git a/src/Api/Issue.php b/src/Api/Issue.php index f08aa8d..ef607b7 100644 --- a/src/Api/Issue.php +++ b/src/Api/Issue.php @@ -153,9 +153,4 @@ public function timeTracking(): TimeTracking { return new TimeTracking($this->getClient()); } - - public function command($parameters) - { - return $this->post("commands", $parameters); - } }