Skip to content

Commit

Permalink
feat: endpoint to find workloads by IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Lipenský committed Oct 3, 2024
1 parent 06c20a4 commit 349ccde
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,26 @@ public function getWorklogById(string $issueIdOrKey, int $workLogId): Worklog
);
}

/**
* @param array<int> $ids
*
* @return array<Worklog>
*/
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.
*
Expand Down
16 changes: 16 additions & 0 deletions tests/WorkLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 349ccde

Please sign in to comment.