diff --git a/src/Redmine/Api/IssueCategory.php b/src/Redmine/Api/IssueCategory.php index a5edd727..bd635ba1 100644 --- a/src/Redmine/Api/IssueCategory.php +++ b/src/Redmine/Api/IssueCategory.php @@ -7,6 +7,8 @@ use Redmine\Exception\MissingParameterException; use Redmine\Exception\SerializerException; use Redmine\Exception\UnexpectedResponseException; +use Redmine\Http\HttpFactory; +use Redmine\Serializer\JsonSerializer; use Redmine\Serializer\PathSerializer; use Redmine\Serializer\XmlSerializer; @@ -127,11 +129,26 @@ public function getIdByName($project, $name) * * @param int $id the issue category id * - * @return array information about the category + * @return array|false|string information about the category as array or false|string on error */ public function show($id) { - return $this->get('/issue_categories/' . urlencode(strval($id)) . '.json'); + $this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeJsonRequest( + 'GET', + '/issue_categories/' . urlencode(strval($id)) . '.json', + )); + + $body = $this->lastResponse->getContent(); + + if ('' === $body) { + return false; + } + + try { + return JsonSerializer::createFromString($body)->getNormalized(); + } catch (SerializerException $e) { + return 'Error decoding body as JSON: ' . $e->getPrevious()->getMessage(); + } } /**