Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Issue/IssueSearchResult.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Created by PhpStorm.
* User: keanor
Expand Down Expand Up @@ -82,7 +83,7 @@ public function getIssue($ndx)
/**
* @return ?string
*/
public function getExpand() : ?$string
public function getExpand(): ?string
{
return $this->expand;
}
Expand Down
33 changes: 30 additions & 3 deletions src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ public function transition($issueIdOrKey, $transition): ?string
*
* @return IssueSearchResult
*/
public function search(string $jql, string $nextPageToken = '', int $maxResults = 50, array $fields = [], string $expand = '', array $reconcileIssues = []): IssueBulkResult
public function search(string $jql, string $nextPageToken = '', int $maxResults = 50, array $fields = [], string $expand = '', array $reconcileIssues = []): IssueSearchResult
{
$data = [
'jql' => $jql,
Expand All @@ -548,12 +548,39 @@ public function search(string $jql, string $nextPageToken = '', int $maxResults
$data['nextPageToken'] = $nextPageToken;
}

$ret = $this->exec('search//jql', json_encode($data), 'POST');
$ret = $this->exec('search/jql', json_encode($data), 'POST');
$json = json_decode($ret);

$result = $this->json_mapper->map(
$json,
new IssueBulkResult()
new IssueSearchResult()
);

return $result;
}

/**
* Get an approximate count of issues that match a JQL query.
*
* @param string $jql The JQL query string
*
* @throws \JsonMapper_Exception
* @throws JiraException
*
* @return JQLCountResult
*/
public function searchApproximateCount(string $jql): JQLCountResult
{
$data = [
'jql' => $jql,
];

$ret = $this->exec('search/approximate-count', json_encode($data), 'POST');
$json = json_decode($ret);

$result = $this->json_mapper->map(
$json,
new JQLCountResult()
);

return $result;
Expand Down
42 changes: 42 additions & 0 deletions src/Issue/JQLCountResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace JiraRestApi\Issue;

/**
* JQL Count result for approximate count API.
*/
class JQLCountResult implements \JsonSerializable
{
/**
* @var int The approximate count of issues matching the JQL query
*/
public int $count;

/**
* Get the count of issues.
*
* @return int
*/
public function getCount(): int
{
return $this->count;
}

/**
* Set the count of issues.
*
* @param int $count
*/
public function setCount(int $count): void
{
$this->count = $count;
}

#[\ReturnTypeWillChange]
public function jsonSerialize(): array
{
return [
'count' => $this->count
];
}
}