Skip to content

Commit b2c70cd

Browse files
committed
Replace get() with HttpClient In IssueCategory API
1 parent 19c790f commit b2c70cd

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/Redmine/Api/IssueCategory.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Redmine\Exception\MissingParameterException;
88
use Redmine\Exception\SerializerException;
99
use Redmine\Exception\UnexpectedResponseException;
10+
use Redmine\Http\HttpFactory;
11+
use Redmine\Serializer\JsonSerializer;
1012
use Redmine\Serializer\PathSerializer;
1113
use Redmine\Serializer\XmlSerializer;
1214

@@ -127,11 +129,26 @@ public function getIdByName($project, $name)
127129
*
128130
* @param int $id the issue category id
129131
*
130-
* @return array information about the category
132+
* @return array|false|string information about the category as array or false|string on error
131133
*/
132134
public function show($id)
133135
{
134-
return $this->get('/issue_categories/' . urlencode(strval($id)) . '.json');
136+
$this->lastResponse = $this->getHttpClient()->request(HttpFactory::makeJsonRequest(
137+
'GET',
138+
'/issue_categories/' . urlencode(strval($id)) . '.json',
139+
));
140+
141+
$body = $this->lastResponse->getContent();
142+
143+
if ('' === $body) {
144+
return false;
145+
}
146+
147+
try {
148+
return JsonSerializer::createFromString($body)->getNormalized();
149+
} catch (SerializerException $e) {
150+
return 'Error decoding body as JSON: ' . $e->getPrevious()->getMessage();
151+
}
135152
}
136153

137154
/**

0 commit comments

Comments
 (0)