@@ -223,28 +223,31 @@ You can now use the `getApi()` method to create and get a specific Redmine API.
223
223
224
224
To check for failed requests you can afterwards check the status code via ` $client->getLastResponseStatusCode() ` .
225
225
226
+ #### Tracker API
227
+
226
228
``` php
227
- // ----------------------------
228
- // Trackers
229
+
229
230
$client->getApi('tracker')->list();
230
- $client->getApi('tracker')->listing();
231
+ $client->getApi('tracker')->listNames();
232
+ ```
233
+
234
+ #### IssueStatus API
231
235
232
- // ----------------------------
233
- // Issue statuses
236
+ ``` php
234
237
$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
237
243
238
- // ----------------------------
239
- // Project
244
+ ``` php
240
245
$client->getApi('project')->list();
241
246
$client->getApi('project')->list([
242
247
'limit' => 10,
243
248
]);
244
- $client->getApi('project')->listing();
245
- $client->getApi('project')->listing();
249
+ $client->getApi('project')->listNames();
246
250
$client->getApi('project')->show($projectId);
247
- $client->getApi('project')->getIdByName('Elvis');
248
251
$client->getApi('project')->create([
249
252
'name' => 'some name',
250
253
'identifier' => 'the_identifier',
@@ -258,11 +261,13 @@ $client->getApi('project')->reopen($projectId);
258
261
$client->getApi('project')->archive($projectId);
259
262
$client->getApi('project')->unarchive($projectId);
260
263
$client->getApi('project')->remove($projectId);
264
+ ```
261
265
262
- // ----------------------------
263
- // Users
266
+ #### User API
267
+
268
+ ``` php
264
269
$client->getApi('user')->list();
265
- $client->getApi('user')->listing ();
270
+ $client->getApi('user')->listLogins ();
266
271
$client->getApi('user')->getCurrentUser([
267
272
'include' => [
268
273
'memberships',
@@ -271,7 +276,6 @@ $client->getApi('user')->getCurrentUser([
271
276
'status',
272
277
],
273
278
]);
274
- $client->getApi('user')->getIdByUsername('kbsali');
275
279
$client->getApi('user')->show($userId, [
276
280
'include' => [
277
281
'memberships',
@@ -290,9 +294,11 @@ $client->getApi('user')->create([
290
294
'lastname' => 'test',
291
295
292
296
]);
297
+ ```
298
+
299
+ #### Issue API
293
300
294
- // ----------------------------
295
- // Issues
301
+ ``` php
296
302
$client->getApi('issue')->show($issueId);
297
303
$client->getApi('issue')->list([
298
304
'limit' => 100,
@@ -348,8 +354,11 @@ $client->getApi('issue')->update($issueId, [
348
354
'priority_id' => 5,
349
355
'due_date' => date('Y-m-d'),
350
356
]);
357
+ $client->getApi('issue')->addWatcher($issueId, $userId);
358
+ $client->getApi('issue')->removeWatcher($issueId, $userId);
351
359
$client->getApi('issue')->setIssueStatus($issueId, 'Resolved');
352
360
$client->getApi('issue')->addNoteToIssue($issueId, 'some comment');
361
+ $client->getApi('issue')->addNoteToIssue($issueId, 'private note', true);
353
362
$client->getApi('issue')->remove($issueId);
354
363
355
364
// To upload a file + attach it to an existing issue with $issueId
@@ -377,12 +386,42 @@ $client->getApi('issue')->create([
377
386
],
378
387
]);
379
388
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
382
422
$client->getApi('issue_category')->listByProject('project1');
383
- $client->getApi('issue_category')->listing ($projectId);
423
+ $client->getApi('issue_category')->listNamesByProject ($projectId);
384
424
$client->getApi('issue_category')->show($categoryId);
385
- $client->getApi('issue_category')->getIdByName($projectId, 'Administration');
386
425
$client->getApi('issue_category')->create('otherProject', [
387
426
'name' => 'test category',
388
427
]);
@@ -393,45 +432,64 @@ $client->getApi('issue_category')->remove($categoryId);
393
432
$client->getApi('issue_category')->remove($categoryId, [
394
433
'reassign_to_id' => $userId,
395
434
]);
435
+ ```
396
436
397
- // ----------------------------
398
- // Versions
437
+ #### Version API
438
+
439
+ ``` php
399
440
$client->getApi('version')->listByProject('test');
400
- $client->getApi('version')->listing ('test');
441
+ $client->getApi('version')->listNamesByProject ('test');
401
442
$client->getApi('version')->show($versionId);
402
- $client->getApi('version')->getIdByName('test', 'v2');
403
443
$client->getApi('version')->create('test', [
404
444
'name' => 'v3432',
405
445
]);
406
446
$client->getApi('version')->update($versionId, [
407
447
'name' => 'v1121',
408
448
]);
409
449
$client->getApi('version')->remove($versionId);
450
+ ```
451
+
452
+ #### Attachment API
410
453
411
- // ----------------------------
412
- // Attachments
454
+ ``` php
413
455
$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
+ ]);
414
462
415
463
$file_content = $client->getApi('attachment')->download($attachmentId);
416
464
file_put_contents('example.png', $file_content);
417
465
418
- // ----------------------------
419
- // News
466
+ $client->getApi('attachment')->remove($attachmentId);
467
+ ```
468
+
469
+ #### News API
470
+
471
+ ``` php
420
472
$client->getApi('news')->list();
421
473
$client->getApi('news')->listByProject('test');
474
+ ```
475
+
476
+ #### Role API
422
477
423
- // ----------------------------
424
- // Roles
478
+ ``` php
425
479
$client->getApi('role')->list();
480
+ $client->getApi('role')->listNames();
426
481
$client->getApi('role')->show(1);
427
- $client->getApi('role')->listing();
482
+ ```
428
483
429
- // ----------------------------
430
- // Queries
484
+ #### Query API
485
+
486
+ ``` php
431
487
$client->getApi('query')->list();
488
+ ```
489
+
490
+ #### TimeEntry API
432
491
433
- // ----------------------------
434
- // Time entries
492
+ ``` php
435
493
$client->getApi('time_entry')->list();
436
494
$client->getApi('time_entry')->show($timeEntryId);
437
495
$client->getApi('time_entry')->list([
@@ -471,21 +529,32 @@ $client->getApi('time_entry')->update($timeEntryId, [
471
529
],
472
530
]);
473
531
$client->getApi('time_entry')->remove($timeEntryId);
532
+ ```
474
533
475
- // ----------------------------
476
- // Time entry activities
534
+ #### TimeEntryActivity API
535
+
536
+ ``` php
477
537
$client->getApi('time_entry_activity')->list();
538
+ $client->getApi('time_entry_activity')->listNames();
539
+ ```
540
+
541
+ #### IssueRelation API
478
542
479
- // ----------------------------
480
- // Issue relations
543
+ ``` php
481
544
$client->getApi('issue_relation')->listByIssueId($issueId);
482
545
$client->getApi('issue_relation')->show($issueRelationId);
546
+ $client->getApi('issue_relation')->create($issueId, [
547
+ 'relation_type' => 'relates',
548
+ 'issue_to_id' => $issueToId,
549
+ ]);
483
550
$client->getApi('issue_relation')->remove($issueRelationId);
551
+ ```
484
552
485
- // ----------------------------
486
- // Group (of members)
553
+ #### Group of members API
554
+
555
+ ``` php
487
556
$client->getApi('group')->list();
488
- $client->getApi('group')->listing ();
557
+ $client->getApi('group')->listNames ();
489
558
$client->getApi('group')->show($groupId, ['include' => 'users,memberships']);
490
559
$client->getApi('group')->remove($groupId);
491
560
$client->getApi('group')->addUser($groupId, $userId);
@@ -513,22 +582,33 @@ $client->getApi('group')->update($groupId, [
513
582
],
514
583
],
515
584
]);
585
+ ```
586
+
587
+ #### Project Membership API
516
588
517
- // ----------------------------
518
- // Project memberships
589
+ ``` php
519
590
$client->getApi('membership')->listByProject($projectId);
520
591
$client->getApi('membership')->create($projectId, [
521
592
'user_id' => 1,
522
593
'role_ids' => [5],
523
594
]);
595
+ $client->getApi('membership')->update($membershipId, [
596
+ 'user_id' => 1,
597
+ 'role_ids' => [5],
598
+ ]);
524
599
$client->getApi('membership')->remove($membershipId);
600
+ $client->getApi('membership')->removeMember($projectId, $userId);
601
+ ```
602
+
603
+ #### IssuePriority API
525
604
526
- // ----------------------------
527
- // Issue priorities
605
+ ``` php
528
606
$client->getApi('issue_priority')->list();
607
+ ```
529
608
530
- // ----------------------------
531
- // Wiki
609
+ #### Wiki API
610
+
611
+ ``` php
532
612
$client->getApi('wiki')->listByProject('testProject');
533
613
$client->getApi('wiki')->show('testProject', 'about');
534
614
$client->getApi('wiki')->show('testProject', 'about', $version);
@@ -543,63 +623,20 @@ $client->getApi('wiki')->update('testProject', 'about', [
543
623
'version' => null,
544
624
]);
545
625
$client->getApi('wiki')->remove('testProject', 'about');
626
+ ```
546
627
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
560
629
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
+ ```
566
633
567
- print_r($issues);
568
- /*
569
- Array
570
- (
571
- [all] => 8
572
- [opened] => 7
573
- [closed] => 1
574
- )
575
- */
634
+ #### CustomField API
576
635
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
+ ```
603
640
604
641
If some features are missing in ` getApi() ` you are welcome to create a PR. Besides, it is always possible to use the low-level API.
605
642
0 commit comments