bluestone / redmine-api
Redmine API client
v1.2.6
2023-11-09 21:56 UTC
Requires
- php: ^8.1
- bluestone/dto: ^1.0
- guzzlehttp/guzzle: ^7.3
Requires (Dev)
- marcocesarato/php-conventional-changelog: ^1.15
- phpunit/phpunit: ^9.5.10
- squizlabs/php_codesniffer: ^3.7
README
Installation
This package requires php:^8.1
.
You can install it via composer:
composer require bluestone/redmine-api
Usage
First of all, you need to construct our service with a Guzzle client like this :
$httpHandler = new \Bluestone\Redmine\HttpHandler( baseUri: 'https://redmine.org' ); $redmine = new \Bluestone\Redmine\Client($httpHandler);
Let's discuss all possibilities one by one.
Get projects
You can grab projects from Redmine API using this method :
$response = $redmine->project()->all(); foreach ($response->items as $project) { echo $project->name; }
Get issues
You can grab issues from Redmine API using this method :
$response = $redmine->issue()->all(); foreach ($response->items as $issue) { echo $issue->subject; }
Get project's versions
You can grab project's versions from Redmine API using this method :
$project = new \Bluestone\Redmine\Entities\Project([ 'id' => 42, ]) $response = $redmine->version()->all($project); foreach ($response->items as $version) { echo $version->name; }
Get time entries
You can grab time entries from Redmine API using this method :
$response = $redmine->timeEntry()->all(); foreach ($response->items as $timeEntry) { echo $timeEntry->hours; }
Get specific issue
You can grab specific issue from Redmine API using this method :
$response = $redmine->issue()->get(1); $issue = $response->items[0]; echo $issue->subject;
Update an issue
You can update an issue from Redmine API using this method :
$issue = new \Bluestone\Redmine\Entities\Issue([ 'id' => 1, 'subject' => 'Hello from API', 'project' => new Project(id: 1), 'note' => 'Update an issue from API', ]); $response = $redmine->issue()->update($issue); if ($response->statusCode === 204) { echo "Well done !" }
Contributing
Redmine API client is an open source project under MIT License and is open for contributions.