Skip to content

Commit

Permalink
Replace get() with HttpClient In IssueCategory API
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Feb 16, 2024
1 parent 19c790f commit b2c70cd
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Redmine/Api/IssueCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}

/**
Expand Down

0 comments on commit b2c70cd

Please sign in to comment.