@@ -223,28 +223,31 @@ You can now use the `getApi()` method to create and get a specific Redmine API.
223223
224224To check for failed requests you can afterwards check the status code via ` $client->getLastResponseStatusCode() ` .
225225
226+ #### Tracker API
227+
226228``` php
227- // ----------------------------
228- // Trackers
229+
229230$client->getApi('tracker')->list();
230- $client->getApi('tracker')->listing();
231+ $client->getApi('tracker')->listNames();
232+ ```
233+
234+ #### IssueStatus API
231235
232- // ----------------------------
233- // Issue statuses
236+ ``` php
234237$client->getApi('issue_status')->list();
235- $client->getApi('issue_status')->listing();
236- $client->getApi('issue_status')->getIdByName('New');
238+ $client->getApi('issue_status')->listNames();
239+
240+ ```
241+
242+ #### Project API
237243
238- // ----------------------------
239- // Project
244+ ``` php
240245$client->getApi('project')->list();
241246$client->getApi('project')->list([
242247 'limit' => 10,
243248]);
244- $client->getApi('project')->listing();
245- $client->getApi('project')->listing();
249+ $client->getApi('project')->listNames();
246250$client->getApi('project')->show($projectId);
247- $client->getApi('project')->getIdByName('Elvis');
248251$client->getApi('project')->create([
249252 'name' => 'some name',
250253 'identifier' => 'the_identifier',
@@ -258,11 +261,13 @@ $client->getApi('project')->reopen($projectId);
258261$client->getApi('project')->archive($projectId);
259262$client->getApi('project')->unarchive($projectId);
260263$client->getApi('project')->remove($projectId);
264+ ```
261265
262- // ----------------------------
263- // Users
266+ #### User API
267+
268+ ``` php
264269$client->getApi('user')->list();
265- $client->getApi('user')->listing ();
270+ $client->getApi('user')->listLogins ();
266271$client->getApi('user')->getCurrentUser([
267272 'include' => [
268273 'memberships',
@@ -271,7 +276,6 @@ $client->getApi('user')->getCurrentUser([
271276 'status',
272277 ],
273278]);
274- $client->getApi('user')->getIdByUsername('kbsali');
275279$client->getApi('user')->show($userId, [
276280 'include' => [
277281 'memberships',
@@ -290,9 +294,11 @@ $client->getApi('user')->create([
290294 'lastname' => 'test',
291295 'mail' => 'test@example.com',
292296]);
297+ ```
298+
299+ #### Issue API
293300
294- // ----------------------------
295- // Issues
301+ ``` php
296302$client->getApi('issue')->show($issueId);
297303$client->getApi('issue')->list([
298304 'limit' => 100,
@@ -348,8 +354,11 @@ $client->getApi('issue')->update($issueId, [
348354 'priority_id' => 5,
349355 'due_date' => date('Y-m-d'),
350356]);
357+ $client->getApi('issue')->addWatcher($issueId, $userId);
358+ $client->getApi('issue')->removeWatcher($issueId, $userId);
351359$client->getApi('issue')->setIssueStatus($issueId, 'Resolved');
352360$client->getApi('issue')->addNoteToIssue($issueId, 'some comment');
361+ $client->getApi('issue')->addNoteToIssue($issueId, 'private note', true);
353362$client->getApi('issue')->remove($issueId);
354363
355364// To upload a file + attach it to an existing issue with $issueId
@@ -377,12 +386,42 @@ $client->getApi('issue')->create([
377386 ],
378387]);
379388
380- // ----------------------------
381- // Issue categories
389+ // Issues' stats (see https://github.com/kbsali/php-redmine-api/issues/44)
390+ $issues['all'] = $client->getApi('issue')->list([
391+ 'limit' => 1,
392+ 'tracker_id' => 1,
393+ 'status_id' => '*',
394+ ])['total_count'];
395+
396+ $issues['opened'] = $client->getApi('issue')->list([
397+ 'limit' => 1,
398+ 'tracker_id' => 1,
399+ 'status_id' => 'open',
400+ ])['total_count'];
401+
402+ $issues['closed'] = $client->getApi('issue')->list([
403+ 'limit' => 1,
404+ 'tracker_id' => 1,
405+ 'status_id' => 'closed',
406+ ])['total_count'];
407+
408+ print_r($issues);
409+ /*
410+ Array
411+ (
412+ [all] => 8
413+ [opened] => 7
414+ [closed] => 1
415+ )
416+ */
417+ ```
418+
419+ #### IssueCategory API
420+
421+ ``` php
382422$client->getApi('issue_category')->listByProject('project1');
383- $client->getApi('issue_category')->listing ($projectId);
423+ $client->getApi('issue_category')->listNamesByProject ($projectId);
384424$client->getApi('issue_category')->show($categoryId);
385- $client->getApi('issue_category')->getIdByName($projectId, 'Administration');
386425$client->getApi('issue_category')->create('otherProject', [
387426 'name' => 'test category',
388427]);
@@ -393,45 +432,64 @@ $client->getApi('issue_category')->remove($categoryId);
393432$client->getApi('issue_category')->remove($categoryId, [
394433 'reassign_to_id' => $userId,
395434]);
435+ ```
396436
397- // ----------------------------
398- // Versions
437+ #### Version API
438+
439+ ``` php
399440$client->getApi('version')->listByProject('test');
400- $client->getApi('version')->listing ('test');
441+ $client->getApi('version')->listNamesByProject ('test');
401442$client->getApi('version')->show($versionId);
402- $client->getApi('version')->getIdByName('test', 'v2');
403443$client->getApi('version')->create('test', [
404444 'name' => 'v3432',
405445]);
406446$client->getApi('version')->update($versionId, [
407447 'name' => 'v1121',
408448]);
409449$client->getApi('version')->remove($versionId);
450+ ```
451+
452+ #### Attachment API
410453
411- // ----------------------------
412- // Attachments
454+ ``` php
413455$client->getApi('attachment')->show($attachmentId);
456+ $client->getApi('attachment')->upload(file_get_contents('example.png'), [
457+ 'filename' => 'example.png',
458+ ]);
459+ $client->getApi('attachment')->update($attachmentId, [
460+ 'filename' => 'example.png',
461+ ]);
414462
415463$file_content = $client->getApi('attachment')->download($attachmentId);
416464file_put_contents('example.png', $file_content);
417465
418- // ----------------------------
419- // News
466+ $client->getApi('attachment')->remove($attachmentId);
467+ ```
468+
469+ #### News API
470+
471+ ``` php
420472$client->getApi('news')->list();
421473$client->getApi('news')->listByProject('test');
474+ ```
475+
476+ #### Role API
422477
423- // ----------------------------
424- // Roles
478+ ``` php
425479$client->getApi('role')->list();
480+ $client->getApi('role')->listNames();
426481$client->getApi('role')->show(1);
427- $client->getApi('role')->listing();
482+ ```
428483
429- // ----------------------------
430- // Queries
484+ #### Query API
485+
486+ ``` php
431487$client->getApi('query')->list();
488+ ```
489+
490+ #### TimeEntry API
432491
433- // ----------------------------
434- // Time entries
492+ ``` php
435493$client->getApi('time_entry')->list();
436494$client->getApi('time_entry')->show($timeEntryId);
437495$client->getApi('time_entry')->list([
@@ -471,21 +529,32 @@ $client->getApi('time_entry')->update($timeEntryId, [
471529 ],
472530]);
473531$client->getApi('time_entry')->remove($timeEntryId);
532+ ```
474533
475- // ----------------------------
476- // Time entry activities
534+ #### TimeEntryActivity API
535+
536+ ``` php
477537$client->getApi('time_entry_activity')->list();
538+ $client->getApi('time_entry_activity')->listNames();
539+ ```
540+
541+ #### IssueRelation API
478542
479- // ----------------------------
480- // Issue relations
543+ ``` php
481544$client->getApi('issue_relation')->listByIssueId($issueId);
482545$client->getApi('issue_relation')->show($issueRelationId);
546+ $client->getApi('issue_relation')->create($issueId, [
547+ 'relation_type' => 'relates',
548+ 'issue_to_id' => $issueToId,
549+ ]);
483550$client->getApi('issue_relation')->remove($issueRelationId);
551+ ```
484552
485- // ----------------------------
486- // Group (of members)
553+ #### Group of members API
554+
555+ ``` php
487556$client->getApi('group')->list();
488- $client->getApi('group')->listing ();
557+ $client->getApi('group')->listNames ();
489558$client->getApi('group')->show($groupId, ['include' => 'users,memberships']);
490559$client->getApi('group')->remove($groupId);
491560$client->getApi('group')->addUser($groupId, $userId);
@@ -513,22 +582,33 @@ $client->getApi('group')->update($groupId, [
513582 ],
514583 ],
515584]);
585+ ```
586+
587+ #### Project Membership API
516588
517- // ----------------------------
518- // Project memberships
589+ ``` php
519590$client->getApi('membership')->listByProject($projectId);
520591$client->getApi('membership')->create($projectId, [
521592 'user_id' => 1,
522593 'role_ids' => [5],
523594]);
595+ $client->getApi('membership')->update($membershipId, [
596+ 'user_id' => 1,
597+ 'role_ids' => [5],
598+ ]);
524599$client->getApi('membership')->remove($membershipId);
600+ $client->getApi('membership')->removeMember($projectId, $userId);
601+ ```
602+
603+ #### IssuePriority API
525604
526- // ----------------------------
527- // Issue priorities
605+ ``` php
528606$client->getApi('issue_priority')->list();
607+ ```
529608
530- // ----------------------------
531- // Wiki
609+ #### Wiki API
610+
611+ ``` php
532612$client->getApi('wiki')->listByProject('testProject');
533613$client->getApi('wiki')->show('testProject', 'about');
534614$client->getApi('wiki')->show('testProject', 'about', $version);
@@ -543,63 +623,20 @@ $client->getApi('wiki')->update('testProject', 'about', [
543623 'version' => null,
544624]);
545625$client->getApi('wiki')->remove('testProject', 'about');
626+ ```
546627
547- // ----------------------------
548- // Issues' stats (see https://github.com/kbsali/php-redmine-api/issues/44)
549- $issues['all'] = $client->getApi('issue')->list([
550- 'limit' => 1,
551- 'tracker_id' => 1,
552- 'status_id' => '*',
553- ])['total_count'];
554-
555- $issues['opened'] = $client->getApi('issue')->list([
556- 'limit' => 1,
557- 'tracker_id' => 1,
558- 'status_id' => 'open',
559- ])['total_count'];
628+ #### Search API
560629
561- $issues['closed'] = $client->getApi('issue')->list([
562- 'limit' => 1,
563- 'tracker_id' => 1,
564- 'status_id' => 'closed',
565- ])['total_count'];
630+ ``` php
631+ $client->getApi('search')->listByQuery('search query', ['limit' => 100]);
632+ ```
566633
567- print_r($issues);
568- /*
569- Array
570- (
571- [all] => 8
572- [opened] => 7
573- [closed] => 1
574- )
575- */
634+ #### CustomField API
576635
577- // ----------------------------
578- // Search
579- $client->getApi('search')->search('Myproject', ['limit' => 100]);
580- ```
581-
582- #### API entry points implementation state:
583-
584- * :heavy_check_mark : Attachments
585- * :heavy_check_mark : Groups
586- * :heavy_check_mark : Custom Fields
587- * :heavy_check_mark : Issues
588- * :heavy_check_mark : Issue Categories
589- * :heavy_check_mark : Issue Priorities
590- * :x : * Issue Relations - only partially implemented*
591- * :heavy_check_mark : Issue Statuses
592- * :heavy_check_mark : News
593- * :heavy_check_mark : Projects
594- * :heavy_check_mark : Project Memberships
595- * :heavy_check_mark : Queries
596- * :heavy_check_mark : Roles
597- * :heavy_check_mark : Time Entries
598- * :heavy_check_mark : Time Entry Activities
599- * :heavy_check_mark : Trackers
600- * :heavy_check_mark : Users
601- * :heavy_check_mark : Versions
602- * :heavy_check_mark : Wiki
636+ ``` php
637+ $client->getApi('custom_field')->list();
638+ $client->getApi('custom_field')->listNames();
639+ ```
603640
604641If some features are missing in ` getApi() ` you are welcome to create a PR. Besides, it is always possible to use the low-level API.
605642
0 commit comments