Skip to content

Commit 2e79233

Browse files
leeyuentuenTuen Leelesstif
authored
fix deprecated search to search/jql (#554)
Co-authored-by: Tuen Lee <[email protected]> Co-authored-by: KwangSeob Jeong <[email protected]>
1 parent 18f2ab9 commit 2e79233

File tree

3 files changed

+104
-55
lines changed

3 files changed

+104
-55
lines changed

src/Issue/IssueBulkResult.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
namespace JiraRestApi\Issue;
4+
5+
/**
6+
* Issue search result.
7+
*/
8+
class IssueBulkResult
9+
{
10+
/**
11+
* @var string
12+
*/
13+
public $expand;
14+
15+
/**
16+
* @var \JiraRestApi\Issue\Issue[]
17+
*/
18+
public $issues;
19+
20+
/**
21+
* @var array
22+
*/
23+
public $issueErrors;
24+
25+
/**
26+
* @return array
27+
*/
28+
public function getIssueErrors()
29+
{
30+
return $this->issueErrors;
31+
}
32+
33+
/**
34+
* @param array $issueErrors
35+
*/
36+
public function setIssueErrors($issueErrors)
37+
{
38+
$this->issueErrors = $issueErrors;
39+
}
40+
41+
/**
42+
* @return Issue[]
43+
*/
44+
public function getIssues()
45+
{
46+
return $this->issues;
47+
}
48+
49+
/**
50+
* @param Issue[] $issues
51+
*/
52+
public function setIssues($issues)
53+
{
54+
$this->issues = $issues;
55+
}
56+
57+
/**
58+
* @param int $ndx
59+
*
60+
* @return Issue
61+
*/
62+
public function getIssue($ndx)
63+
{
64+
return $this->issues[$ndx];
65+
}
66+
67+
/**
68+
* @return string
69+
*/
70+
public function getExpand()
71+
{
72+
return $this->expand;
73+
}
74+
75+
/**
76+
* @param string $expand
77+
*/
78+
public function setExpand($expand)
79+
{
80+
$this->expand = $expand;
81+
}
82+
}

src/Issue/IssueSearchResult.php

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/**
43
* Created by PhpStorm.
54
* User: keanor
@@ -14,9 +13,8 @@
1413
*/
1514
class IssueSearchResult
1615
{
17-
/**
18-
* @var string
19-
*/
16+
public ?string $nextPageToken = null;
17+
2018
public ?string $expand = null;
2119

2220
/**
@@ -42,49 +40,17 @@ class IssueSearchResult
4240
/**
4341
* @return int
4442
*/
45-
public function getStartAt()
46-
{
47-
return $this->startAt;
48-
}
49-
50-
/**
51-
* @param int $startAt
52-
*/
53-
public function setStartAt($startAt)
54-
{
55-
$this->startAt = $startAt;
56-
}
57-
58-
/**
59-
* @return int
60-
*/
61-
public function getMaxResults()
62-
{
63-
return $this->maxResults;
64-
}
65-
66-
/**
67-
* @param int $maxResults
68-
*/
69-
public function setMaxResults($maxResults)
70-
{
71-
$this->maxResults = $maxResults;
72-
}
73-
74-
/**
75-
* @return int
76-
*/
77-
public function getTotal()
43+
public function getNextPageToken()
7844
{
79-
return $this->total;
45+
return $this->nextPageToken;
8046
}
8147

8248
/**
83-
* @param int $total
49+
* @param string $nextPageToken
8450
*/
85-
public function setTotal($total)
51+
public function setNextPageToken($nextPageToken)
8652
{
87-
$this->total = $total;
53+
$this->nextPageToken = $nextPageToken;
8854
}
8955

9056
/**
@@ -116,7 +82,7 @@ public function getIssue($ndx)
11682
/**
11783
* @return ?string
11884
*/
119-
public function getExpand()
85+
public function getExpand() : ?$string
12086
{
12187
return $this->expand;
12288
}

src/Issue/IssueService.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -534,25 +534,26 @@ public function transition($issueIdOrKey, $transition): ?string
534534
*
535535
* @return IssueSearchResult
536536
*/
537-
public function search(string $jql, int $startAt = 0, int $maxResults = 15, array $fields = [], array $expand = [], bool $validateQuery = true): IssueSearchResult
537+
public function search(string $jql, string $nextPageToken = '', int $maxResults = 50, array $fields = [], string $expand = '', array $reconcileIssues = []): IssueBulkResult
538538
{
539-
$data = json_encode([
540-
'jql' => $jql,
541-
'startAt' => $startAt,
542-
'maxResults' => $maxResults,
543-
'fields' => $fields,
544-
'expand' => $expand,
545-
'validateQuery' => $validateQuery,
546-
]);
539+
$data = [
540+
'jql' => $jql,
541+
'maxResults' => $maxResults,
542+
'fields' => $fields,
543+
'expand' => $expand,
544+
'reconcileIssues' => $reconcileIssues,
545+
];
547546

548-
$ret = $this->exec('search', $data, 'POST');
549-
$json = json_decode($ret);
547+
if ($nextPageToken) {
548+
$data['nextPageToken'] = $nextPageToken;
549+
}
550550

551-
$result = null;
551+
$ret = $this->exec('search//jql', json_encode($data), 'POST');
552+
$json = json_decode($ret);
552553

553554
$result = $this->json_mapper->map(
554555
$json,
555-
new IssueSearchResult()
556+
new IssueBulkResult()
556557
);
557558

558559
return $result;

0 commit comments

Comments
 (0)