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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions src/Issue/IssueBulkResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php

namespace JiraRestApi\Issue;

/**
* Issue search result.
*/
class IssueBulkResult
{
/**
* @var string
*/
public $expand;

/**
* @var \JiraRestApi\Issue\Issue[]
*/
public $issues;

/**
* @var array
*/
public $issueErrors;

/**
* @return array
*/
public function getIssueErrors()
{
return $this->issueErrors;
}

/**
* @param array $issueErrors
*/
public function setIssueErrors($issueErrors)
{
$this->issueErrors = $issueErrors;
}

/**
* @return Issue[]
*/
public function getIssues()
{
return $this->issues;
}

/**
* @param Issue[] $issues
*/
public function setIssues($issues)
{
$this->issues = $issues;
}

/**
* @param int $ndx
*
* @return Issue
*/
public function getIssue($ndx)
{
return $this->issues[$ndx];
}

/**
* @return string
*/
public function getExpand()
{
return $this->expand;
}

/**
* @param string $expand
*/
public function setExpand($expand)
{
$this->expand = $expand;
}
}
77 changes: 7 additions & 70 deletions src/Issue/IssueSearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,74 +16,27 @@ class IssueSearchResult
/**
* @var string
*/
public $expand;

/**
* @var int
*/
public $startAt;

/**
* @var int
*/
public $maxResults;

/**
* @var int
*/
public $total;
public $nextPageToken;

/**
* @var \JiraRestApi\Issue\Issue[]
*/
public $issues;

/**
* @return int
*/
public function getStartAt()
{
return $this->startAt;
}

/**
* @param int $startAt
*/
public function setStartAt($startAt)
{
$this->startAt = $startAt;
}

/**
* @return int
*/
public function getMaxResults()
{
return $this->maxResults;
}

/**
* @param int $maxResults
*/
public function setMaxResults($maxResults)
{
$this->maxResults = $maxResults;
}

/**
* @return int
* @return string
*/
public function getTotal()
public function getNextPageToken()
{
return $this->total;
return $this->nextPageToken;
}

/**
* @param int $total
* @param string $nextPageToken
*/
public function setTotal($total)
public function setNextPageToken($nextPageToken)
{
$this->total = $total;
$this->nextPageToken = $nextPageToken;
}

/**
Expand Down Expand Up @@ -111,20 +64,4 @@ public function getIssue($ndx)
{
return $this->issues[$ndx];
}

/**
* @return string
*/
public function getExpand()
{
return $this->expand;
}

/**
* @param string $expand
*/
public function setExpand($expand)
{
$this->expand = $expand;
}
}
85 changes: 71 additions & 14 deletions src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,36 +523,93 @@ public function transition($issueIdOrKey, $transition): ?string
* Search issues.
*
* @param string $jql
* @param int $startAt
* @param string $nextPageToken
* @param int $maxResults
* @param array $fields
* @param array $expand
* @param bool $validateQuery
* @param string $expand
* @param array $reconcileIssues
*
* @throws \JsonMapper_Exception
* @throws JiraException
*
* @return IssueSearchResult
*/
public function search(string $jql, int $startAt = 0, int $maxResults = 15, array $fields = [], array $expand = [], bool $validateQuery = true): IssueSearchResult
public function search(string $jql, string $nextPageToken = '', int $maxResults = 50, array $fields = [], string $expand = '', array $reconcileIssues = []): IssueSearchResult
{
$data = [
'jql' => $jql,
'maxResults' => $maxResults,
'fields' => $fields,
'expand' => $expand,
'reconcileIssues' => $reconcileIssues,
];

if ($nextPageToken) {
$data['nextPageToken'] = $nextPageToken;
}

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

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

return $result;
}

/**
* Search issues.
*
* @param string $jql
*
* @throws \JsonMapper_Exception
* @throws JiraException
*
* @return string[] array of count
*
* @phpstan-return array<string>
*/
public function searchApproximateCount(string $jql): array
{
$data = json_encode([
'jql' => $jql,
'startAt' => $startAt,
'maxResults' => $maxResults,
'fields' => $fields,
'expand' => $expand,
'validateQuery' => $validateQuery,
'jql' => $jql,
]);

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

return json_decode($ret, true);
}

/**
* Bulk fetch issues.
*
* @param array $issueIdsOrKeys
* @param array $fields
* @param array $expand
* @param bool $fieldsByKeys
*
* @throws \JsonMapper_Exception
* @throws JiraException
*
* @return IssueBulkResult
*/
public function bulkFetch(array $issueIdsOrKeys, array $fields = [], array $expand = [], bool $fieldsByKeys = false): IssueBulkResult
{
$data = json_encode([
'issueIdsOrKeys' => $issueIdsOrKeys,
'fields' => $fields,
'expand' => $expand,
'fieldsByKeys' => $fieldsByKeys,
]);
$ret = $this->exec('issue//bulkfetch', $data, 'POST');

$result = null;
$json = json_decode($ret);

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

return $result;
Expand Down