File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ $iss = new IssueService(new ArrayConfiguration(
177177- [ Get User Info] ( #get-user-info )
178178- [ Find Users] ( #find-users )
179179- [ Find Assignable Users] ( #find-assignable-users )
180+ - [ Find Users by query] ( #find-users-by-query )
180181- [ Delete User] ( #delete-user )
181182
182183### Group
@@ -1804,6 +1805,35 @@ try {
18041805
18051806```
18061807
1808+
1809+ #### Find users by query
1810+
1811+ [ See Jira API reference] ( https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-user-search-query-get )
1812+
1813+ Returns a list of users that match the search string.
1814+
1815+ ``` php
1816+ <?php
1817+ require 'vendor/autoload.php';
1818+
1819+ use JiraRestApi\JiraException;
1820+ use JiraRestApi\User\UserService;
1821+
1822+ try {
1823+ $us = new UserService();
1824+
1825+ $paramArray = [
1826+ 'query' => 'is watcher of TEST',
1827+ ];
1828+
1829+ $users = $us->findUsersByQuery($paramArray);
1830+ var_dump($users);
1831+ } catch (JiraException $e) {
1832+ print("Error Occured! " . $e->getMessage());
1833+ }
1834+
1835+ ```
1836+
18071837#### delete User
18081838
18091839[ See Jira API reference] ( https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/user-removeUser )
Original file line number Diff line number Diff line change @@ -115,6 +115,39 @@ public function findAssignableUsers($paramArray)
115115 $ users = [];
116116
117117 foreach ($ userData as $ user ) {
118+ $ users [] = $ this ->json_mapper ->map (
119+ $ user ,
120+ new User ()
121+ );
122+ }
123+
124+ return $ users ;
125+ }
126+
127+ /**
128+ * Returns a list of users that match with a specific query.
129+ *
130+ * @param array $paramArray
131+ *
132+ * @throws \JiraRestApi\JiraException
133+ * @throws \JsonMapper_Exception
134+ *
135+ * @return User[]
136+ *
137+ * @see https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-user-search-query-get
138+ */
139+ public function findUsersByQuery ($ paramArray )
140+ {
141+ $ queryParam = '? ' .http_build_query ($ paramArray );
142+
143+ $ ret = $ this ->exec ($ this ->uri .'/search/query ' .$ queryParam , null );
144+
145+ $ this ->log ->info ("Result= \n" .$ ret );
146+
147+ $ userData = json_decode ($ ret );
148+ $ users = [];
149+
150+ foreach ($ userData ->values as $ user ) {
118151 $ users [] = $ this ->json_mapper ->map (
119152 $ user , new User ()
120153 );
You can’t perform that action at this time.
0 commit comments