Skip to content

Commit 2dc34f7

Browse files
committed
Replace get() with HttpClient in Issue API
1 parent b2c70cd commit 2dc34f7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Redmine/Api/Issue.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Redmine\Exception;
88
use Redmine\Exception\SerializerException;
99
use Redmine\Exception\UnexpectedResponseException;
10+
use Redmine\Http\HttpFactory;
1011
use Redmine\Serializer\JsonSerializer;
1112
use Redmine\Serializer\PathSerializer;
1213
use Redmine\Serializer\XmlSerializer;
@@ -132,17 +133,30 @@ public function all(array $params = [])
132133
* @param int $id the issue id
133134
* @param array $params extra associated data
134135
*
135-
* @return array information about the issue
136+
* @return array|false|string information about the issue as array or false|string on error
136137
*/
137138
public function show($id, array $params = [])
138139
{
139140
if (isset($params['include']) && is_array($params['include'])) {
140141
$params['include'] = implode(',', $params['include']);
141142
}
142143

143-
return $this->get(
144+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeJsonRequest(
145+
'GET',
144146
PathSerializer::create('/issues/' . urlencode(strval($id)) . '.json', $params)->getPath()
145-
);
147+
));
148+
149+
$body = $this->lastResponse->getContent();
150+
151+
if ('' === $body) {
152+
return false;
153+
}
154+
155+
try {
156+
return JsonSerializer::createFromString($body)->getNormalized();
157+
} catch (SerializerException $e) {
158+
return 'Error decoding body as JSON: ' . $e->getPrevious()->getMessage();
159+
}
146160
}
147161

148162
/**

0 commit comments

Comments
 (0)