diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index 68d3049..88afa87 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -700,6 +700,26 @@ public function getWorklogById(string $issueIdOrKey, int $workLogId): Worklog ); } + /** + * @param array $ids + * + * @return array + */ + public function getWorklogsByIds(array $ids): array + { + $ret = $this->exec('/worklog/list', json_encode(['ids' => $ids]), 'POST'); + + $this->log->debug("getWorklogsByIds res=$ret\n"); + + $worklogsResponse = json_decode($ret, false, 512, JSON_THROW_ON_ERROR); + + $worklogs = array_map(function ($worklog) { + return $this->json_mapper->map($worklog, new Worklog()); + }, $worklogsResponse); + + return $worklogs; + } + /** * add work log to issue. * diff --git a/tests/WorkLogTest.php b/tests/WorkLogTest.php index a393e44..2da791e 100644 --- a/tests/WorkLogTest.php +++ b/tests/WorkLogTest.php @@ -95,6 +95,22 @@ public function testGetWorkLogById($workLogid) } } + /** + * @depends testUpdateWorkLogInIssue + */ + public function testGetWorkLogsByIds($workLogid) + { + try { + $issueService = new IssueService(); + + $worklogs = $issueService->getWorklogsByIds([$workLogid]); + + Dumper::dump($worklogs); + } catch (JiraException $e) { + $this->assertTrue(false, 'testGetWorkLogsByIds Failed : '.$e->getMessage()); + } + } + /** * @depends testUpdateWorkLogInIssue */