Skip to content

Commit 5d2e484

Browse files
author
Tomáš Lipenský
committed
feat: endpoint to find workloads by IDs
1 parent 06c20a4 commit 5d2e484

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/Issue/IssueService.php

+20
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,26 @@ public function getWorklogById(string $issueIdOrKey, int $workLogId): Worklog
700700
);
701701
}
702702

703+
/**
704+
* @param array<int> $ids
705+
*
706+
* @return array<Worklog>
707+
*/
708+
public function getWorklogsByIds(array $ids): array
709+
{
710+
$ret = $this->exec('/worklog/list', json_encode(['ids' => $ids]), 'POST');
711+
712+
$this->log->debug("getWorklogsByIds res=$ret\n");
713+
714+
$worklogsResponse = json_decode($ret, false, 512, JSON_THROW_ON_ERROR);
715+
716+
$worklogs = array_map(function ($worklog) {
717+
return $this->json_mapper->map($worklog, new Worklog());
718+
}, $worklogsResponse);
719+
720+
return $worklogs;
721+
}
722+
703723
/**
704724
* add work log to issue.
705725
*

tests/WorkLogTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ public function testGetWorkLogById($workLogid)
9595
}
9696
}
9797

98+
/**
99+
* @depends testUpdateWorkLogInIssue
100+
*/
101+
public function testGetWorkLogsByIds($workLogid)
102+
{
103+
try {
104+
$issueService = new IssueService();
105+
106+
$worklogs = $issueService->getWorklogsByIds([$workLogid]);
107+
108+
Dumper::dump($worklogs);
109+
} catch (JiraException $e) {
110+
$this->assertTrue(false, 'testGetWorkLogsByIds Failed : '.$e->getMessage());
111+
}
112+
}
113+
98114
/**
99115
* @depends testUpdateWorkLogInIssue
100116
*/

0 commit comments

Comments
 (0)