diff --git a/src/Redmine/Api/Issue.php b/src/Redmine/Api/Issue.php index 566f45f2..f8b8ebc7 100644 --- a/src/Redmine/Api/Issue.php +++ b/src/Redmine/Api/Issue.php @@ -7,6 +7,7 @@ use Redmine\Exception; use Redmine\Exception\SerializerException; use Redmine\Exception\UnexpectedResponseException; +use Redmine\Http\HttpFactory; use Redmine\Serializer\JsonSerializer; use Redmine\Serializer\PathSerializer; use Redmine\Serializer\XmlSerializer; @@ -132,7 +133,7 @@ public function all(array $params = []) * @param int $id the issue id * @param array $params extra associated data * - * @return array information about the issue + * @return array|false|string information about the issue as array or false|string on error */ public function show($id, array $params = []) { @@ -140,9 +141,22 @@ public function show($id, array $params = []) $params['include'] = implode(',', $params['include']); } - return $this->get( + $this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeJsonRequest( + 'GET', PathSerializer::create('/issues/' . urlencode(strval($id)) . '.json', $params)->getPath() - ); + )); + + $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(); + } } /**