Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list() methods and deprecate all() methods #329

Merged
merged 29 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
58a0546
Add CustomFields::list(), deprecate all()
Art4 Sep 28, 2023
34ef6e4
Add Group::list(), deprecate all()
Art4 Sep 28, 2023
909aec0
test deprecation warnings
Art4 Sep 28, 2023
c72e9a4
Add Issue::list(), deprecate all()
Art4 Sep 28, 2023
3881b1f
Merge branch 'v2.x' into 277-deprecate-all-and-listings-methods
Art4 Oct 9, 2023
046d779
Add IssueCategory::list(), deprecate all()
Art4 Oct 9, 2023
d36bb72
Merge branch 'v2.x' into 277-deprecate-all-and-listings-methods
Art4 Oct 9, 2023
00bff3d
Add IssuePriority::list(), deprecate all()
Art4 Oct 9, 2023
6abb8b9
Add IssueRelation::list(), deprecate all()
Art4 Oct 9, 2023
4e5cc67
Set new list() methods as final
Art4 Oct 9, 2023
bf61171
Add IssueStatus::list() method, deprecate all() method
Art4 Oct 9, 2023
0110640
Add Membership::list() method, deprecate all() method
Art4 Oct 9, 2023
8358b48
rename list() methods if parameter is required
Art4 Oct 9, 2023
a31c99d
fix tests
Art4 Oct 9, 2023
3155355
Add News::list() and listByProject() methdos, deprecate all() method
Art4 Oct 9, 2023
0ef7eb5
Add tests for exceptions
Art4 Oct 9, 2023
6b36dd3
Add Project::list() method, deprecate all() method
Art4 Oct 10, 2023
34db28d
simplify covers tags
Art4 Oct 10, 2023
0fb1493
Add Query::list() method, deprecate all() method
Art4 Oct 10, 2023
a6e0966
Add Role::list() method, deprecate all() method
Art4 Oct 10, 2023
e0d2105
Add method Search::listByQuery(), deprecate search() method
Art4 Oct 10, 2023
71464f1
Add method TimeEntry::list(), deprecate all() method
Art4 Oct 10, 2023
b9e1165
Add TimeEntryActivity::list() method, deprecate all() method
Art4 Oct 10, 2023
590c415
Add Tracker::list() method, deprecate all() method
Art4 Oct 10, 2023
97786ea
test for correct requested url
Art4 Oct 10, 2023
1bcaf88
Add User::list() method, deprecated all() method
Art4 Oct 10, 2023
e361cc1
Add Version::listByProject() method, deprecate all() method
Art4 Oct 10, 2023
62e54a3
Add Wiki::listByProject() method, deprecate all() method
Art4 Oct 11, 2023
151d20e
Update docs
Art4 Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ parameters:

scanDirectories:
- vendor

treatPhpDocTypesAsCertain: false
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/kbsali/php-redmine-api/compare/v2.3.0...v2.x)

### Added

- New method `Redmine\Api\CustomField::list()` to list custom fields.
- New method `Redmine\Api\Group::list()` to list groups.
- New method `Redmine\Api\Issue::list()` to list issues.
- New method `Redmine\Api\IssueCategory::listByProject()` to list issue categories from a project.
- New method `Redmine\Api\IssuePriority::list()` to list issue priorities.
- New method `Redmine\Api\IssueRelation::listByIssueId()` to list relations from an issue.
- New method `Redmine\Api\IssueStatus::list()` to list issue statuses.
- New method `Redmine\Api\Membership::listByProject()` to list memberships from a project.
- New method `Redmine\Api\News::list()` to list news from all project.
- New method `Redmine\Api\News::listByProject()` to list news from a project.
- New method `Redmine\Api\Project::list()` to list projects.
- New method `Redmine\Api\Query::list()` to list projects.
- New method `Redmine\Api\Role::list()` to list roles.
- New method `Redmine\Api\Search::listByQuery()` to list search results by query.
- New method `Redmine\Api\TimeEntry::list()` to list time entries.
- New method `Redmine\Api\TimeEntryActivity::list()` to list time entry activities.
- New method `Redmine\Api\Tracker::list()` to list trackers.
- New method `Redmine\Api\User::list()` to list users.
- New method `Redmine\Api\Version::listByProject()` to list versions from a project.
- New method `Redmine\Api\Wiki::listByProject()` to list wiki pages from a project.

### Deprecated

- `Redmine\Api\CustomField::all()` is deprecated, use `Redmine\Api\CustomField::list()` instead
- `Redmine\Api\Group::all()` is deprecated, use `Redmine\Api\Group::list()` instead
- `Redmine\Api\Issue::all()` is deprecated, use `Redmine\Api\Issue::list()` instead
- `Redmine\Api\IssueCategory::all()` is deprecated, use `Redmine\Api\IssueCategory::listByProject()` instead
- `Redmine\Api\IssuePriority::all()` is deprecated, use `Redmine\Api\IssuePriority::list()` instead
- `Redmine\Api\IssueRelation::all()` is deprecated, use `Redmine\Api\IssueRelation::listByIssueId()` instead
- `Redmine\Api\IssueStatus::all()` is deprecated, use `Redmine\Api\IssueStatus::list()` instead
- `Redmine\Api\Membership::all()` is deprecated, use `Redmine\Api\Membership::listByProject()` instead
- `Redmine\Api\News::all()` is deprecated, use `Redmine\Api\News::list()` or `Redmine\Api\News::listByProject()` instead
- `Redmine\Api\Project::all()` is deprecated, use `Redmine\Api\Project::list()` instead
- `Redmine\Api\Query::all()` is deprecated, use `Redmine\Api\Query::list()` instead
- `Redmine\Api\Role::all()` is deprecated, use `Redmine\Api\Role::list()` instead
- `Redmine\Api\Search::search()` is deprecated, use `Redmine\Api\Search::listByQuery()` instead
- `Redmine\Api\TimeEntry::all()` is deprecated, use `Redmine\Api\TimeEntry::list()` instead
- `Redmine\Api\TimeEntryActivity::all()` is deprecated, use `Redmine\Api\TimeEntryActivity::list()` instead
- `Redmine\Api\Tracker::all()` is deprecated, use `Redmine\Api\Tracker::list()` instead
- `Redmine\Api\User::all()` is deprecated, use `Redmine\Api\User::list()` instead
- `Redmine\Api\Version::all()` is deprecated, use `Redmine\Api\Version::listByProject()` instead
- `Redmine\Api\Wiki::all()` is deprecated, use `Redmine\Api\Wiki::listByProject()` instead

## [v2.3.0](https://github.com/kbsali/php-redmine-api/compare/v2.2.0...v2.3.0) - 2023-10-09

### Added
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ You can now use the `getApi()` method to create and get a specific Redmine API.
```php
<?php

$client->getApi('user')->all();
$client->getApi('user')->list();
$client->getApi('user')->listing();

$client->getApi('issue')->create([
Expand All @@ -319,7 +319,7 @@ $client->getApi('issue')->create([
'description' => 'a long description blablabla',
'assigned_to_id' => 123, // or 'assigned_to' => 'user1' OR 'groupXX'
]);
$client->getApi('issue')->all([
$client->getApi('issue')->list([
'limit' => 1000
]);
```
Expand Down
58 changes: 29 additions & 29 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ To check for failed requests you can afterwards check the status code via `$clie
```php
// ----------------------------
// Trackers
$client->getApi('tracker')->all();
$client->getApi('tracker')->list();
$client->getApi('tracker')->listing();

// ----------------------------
// Issue statuses
$client->getApi('issue_status')->all();
$client->getApi('issue_status')->list();
$client->getApi('issue_status')->listing();
$client->getApi('issue_status')->getIdByName('New');

// ----------------------------
// Project
$client->getApi('project')->all();
$client->getApi('project')->all([
$client->getApi('project')->list();
$client->getApi('project')->list([
'limit' => 10,
]);
$client->getApi('project')->listing();
Expand All @@ -257,7 +257,7 @@ $client->getApi('project')->remove($projectId);

// ----------------------------
// Users
$client->getApi('user')->all();
$client->getApi('user')->list();
$client->getApi('user')->listing();
$client->getApi('user')->getCurrentUser([
'include' => [
Expand Down Expand Up @@ -290,15 +290,15 @@ $client->getApi('user')->create([
// ----------------------------
// Issues
$client->getApi('issue')->show($issueId);
$client->getApi('issue')->all([
$client->getApi('issue')->list([
'limit' => 100,
]);
$client->getApi('issue')->all(['category_id' => $categoryId]);
$client->getApi('issue')->all(['tracker_id' => $trackerId]);
$client->getApi('issue')->all(['status_id' => 'closed']);
$client->getApi('issue')->all(['assigned_to_id' => $userId]);
$client->getApi('issue')->all(['project_id' => 'test']);
$client->getApi('issue')->all([
$client->getApi('issue')->list(['category_id' => $categoryId]);
$client->getApi('issue')->list(['tracker_id' => $trackerId]);
$client->getApi('issue')->list(['status_id' => 'closed']);
$client->getApi('issue')->list(['assigned_to_id' => $userId]);
$client->getApi('issue')->list(['project_id' => 'test']);
$client->getApi('issue')->list([
'offset' => 100,
'limit' => 100,
'sort' => 'id',
Expand Down Expand Up @@ -375,7 +375,7 @@ $client->getApi('issue')->create([

// ----------------------------
// Issue categories
$client->getApi('issue_category')->all('project1');
$client->getApi('issue_category')->listByProject('project1');
$client->getApi('issue_category')->listing($projectId);
$client->getApi('issue_category')->show($categoryId);
$client->getApi('issue_category')->getIdByName($projectId, 'Administration');
Expand All @@ -392,7 +392,7 @@ $client->getApi('issue_category')->remove($categoryId, [

// ----------------------------
// Versions
$client->getApi('version')->all('test');
$client->getApi('version')->listByProject('test');
$client->getApi('version')->listing('test');
$client->getApi('version')->show($versionId);
$client->getApi('version')->getIdByName('test', 'v2');
Expand All @@ -413,24 +413,24 @@ file_put_contents('example.png', $file_content);

// ----------------------------
// News
$client->getApi('news')->all('test');
$client->getApi('news')->all();
$client->getApi('news')->list();
$client->getApi('news')->listByProject('test');

// ----------------------------
// Roles
$client->getApi('role')->all();
$client->getApi('role')->list();
$client->getApi('role')->show(1);
$client->getApi('role')->listing();

// ----------------------------
// Queries
$client->getApi('query')->all();
$client->getApi('query')->list();

// ----------------------------
// Time entries
$client->getApi('time_entry')->all();
$client->getApi('time_entry')->list();
$client->getApi('time_entry')->show($timeEntryId);
$client->getApi('time_entry')->all([
$client->getApi('time_entry')->list([
'issue_id' => 1234,
'project_id' => 1234,
'spent_on' => '2015-04-13',
Expand Down Expand Up @@ -470,17 +470,17 @@ $client->getApi('time_entry')->remove($timeEntryId);

// ----------------------------
// Time entry activities
$client->getApi('time_entry_activity')->all();
$client->getApi('time_entry_activity')->list();

// ----------------------------
// Issue relations
$client->getApi('issue_relation')->all($issueId);
$client->getApi('issue_relation')->listByIssueId($issueId);
$client->getApi('issue_relation')->show($issueRelationId);
$client->getApi('issue_relation')->remove($issueRelationId);

// ----------------------------
// Group (of members)
$client->getApi('group')->all();
$client->getApi('group')->list();
$client->getApi('group')->listing();
$client->getApi('group')->show($groupId, ['include' => 'users,memberships']);
$client->getApi('group')->remove($groupId);
Expand All @@ -493,7 +493,7 @@ $client->getApi('group')->create([

// ----------------------------
// Project memberships
$client->getApi('membership')->all($projectId);
$client->getApi('membership')->listByProject($projectId);
$client->getApi('membership')->create($projectId, [
'user_id' => null,
'role_ids' => [],
Expand All @@ -502,11 +502,11 @@ $client->getApi('membership')->remove($membershipId);

// ----------------------------
// Issue priorities
$client->getApi('issue_priority')->all();
$client->getApi('issue_priority')->list();

// ----------------------------
// Wiki
$client->getApi('wiki')->all('testProject');
$client->getApi('wiki')->listByProject('testProject');
$client->getApi('wiki')->show('testProject', 'about');
$client->getApi('wiki')->show('testProject', 'about', $version);
$client->getApi('wiki')->create('testProject', 'about', [
Expand All @@ -523,19 +523,19 @@ $client->getApi('wiki')->remove('testProject', 'about');

// ----------------------------
// Issues' stats (see https://github.com/kbsali/php-redmine-api/issues/44)
$issues['all'] = $client->getApi('issue')->all([
$issues['all'] = $client->getApi('issue')->list([
'limit' => 1,
'tracker_id' => 1,
'status_id' => '*',
])['total_count'];

$issues['opened'] = $client->getApi('issue')->all([
$issues['opened'] = $client->getApi('issue')->list([
'limit' => 1,
'tracker_id' => 1,
'status_id' => 'open',
])['total_count'];

$issues['closed'] = $client->getApi('issue')->all([
$issues['closed'] = $client->getApi('issue')->list([
'limit' => 1,
'tracker_id' => 1,
'status_id' => 'closed',
Expand Down
22 changes: 20 additions & 2 deletions src/Redmine/Api/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,31 @@ class CustomField extends AbstractApi
*
* @return array list of custom fields found
*/
public function all(array $params = [])
final public function list(array $params = []): array
{
$this->customFields = $this->retrieveData('/custom_fields.json', $params);

return $this->customFields;
}

/**
* List custom fields.
*
* @deprecated since v2.4.0, use list() instead.
*
* @see http://www.redmine.org/projects/redmine/wiki/Rest_CustomFields#GET
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
*
* @return array list of custom fields found
*/
public function all(array $params = [])
{
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::list()` instead.', E_USER_DEPRECATED);

return $this->list($params);
}

/**
* Returns an array of custom fields with name/id pairs.
*
Expand All @@ -40,7 +58,7 @@ public function all(array $params = [])
public function listing($forceUpdate = false, array $params = [])
{
if (empty($this->customFields) || $forceUpdate) {
$this->all($params);
$this->list($params);
}
$ret = [];
foreach ($this->customFields['custom_fields'] as $e) {
Expand Down
22 changes: 20 additions & 2 deletions src/Redmine/Api/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,31 @@ class Group extends AbstractApi
*
* @return array list of groups found
*/
public function all(array $params = [])
final public function list(array $params = []): array
{
$this->groups = $this->retrieveData('/groups.json', $params);

return $this->groups;
}

/**
* List groups.
*
* @deprecated since v2.4.0, use list() instead.
*
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Groups#GET
*
* @param array $params optional parameters to be passed to the api (offset, limit, ...)
*
* @return array list of groups found
*/
public function all(array $params = [])
{
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::list()` instead.', E_USER_DEPRECATED);

return $this->list($params);
}

/**
* Returns an array of groups with name/id pairs.
*
Expand All @@ -44,7 +62,7 @@ public function all(array $params = [])
public function listing($forceUpdate = false)
{
if (empty($this->groups) || $forceUpdate) {
$this->all();
$this->list();
}
$ret = [];
foreach ($this->groups['groups'] as $e) {
Expand Down
30 changes: 29 additions & 1 deletion src/Redmine/Api/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,39 @@ class Issue extends AbstractApi
*
* @return array list of issues found
*/
public function all(array $params = [])
final public function list(array $params = []): array
{
return $this->retrieveData('/issues.json', $params);
}

/**
* List issues.
*
* @deprecated since v2.4.0, use list() instead.
*
* @see http://www.redmine.org/projects/redmine/wiki/Rest_Issues
* available $params :
* - offset: skip this number of issues in response (optional)
* - limit: number of issues per page (optional)
* - sort: column to sort with. Append :desc to invert the order.
* - project_id: get issues from the project with the given id, where id is either project id or project identifier
* - tracker_id: get issues from the tracker with the given id
* - status_id: get issues with the given status id only. Possible values: open, closed, * to get open and closed issues, status id
* - assigned_to_id: get issues which are assigned to the given user id
* - cf_x: get issues with the given value for custom field with an ID of x. (Custom field must have 'used as a filter' checked.)
* - query_id : id of the previously saved query
*
* @param array $params the additional parameters (cf available $params above)
*
* @return array list of issues found
*/
public function all(array $params = [])
{
@trigger_error('`'.__METHOD__.'()` is deprecated since v2.4.0, use `'.__CLASS__.'::list()` instead.', E_USER_DEPRECATED);

return $this->list($params);
}

/**
* Get extended information about an issue gitven its id.
*
Expand Down
Loading