File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,7 @@ $iss = new IssueService(new ArrayConfiguration(
179
179
- [ Find Assignable Users] ( #find-assignable-users )
180
180
- [ Find Users by query] ( #find-users-by-query )
181
181
- [ Delete User] ( #delete-user )
182
+ - [ Update User] ( #update-user )
182
183
183
184
### Group
184
185
- [ Create Group] ( #create-group )
@@ -1903,6 +1904,42 @@ try {
1903
1904
1904
1905
```
1905
1906
1907
+ #### update User
1908
+
1909
+ [ See Jira API reference] ( https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/user-updateUser )
1910
+
1911
+ Updates user.
1912
+
1913
+ ``` php
1914
+ <?php
1915
+ require 'vendor/autoload.php';
1916
+
1917
+ use JiraRestApi\JiraException;
1918
+ use JiraRestApi\User\UserService;
1919
+
1920
+ try {
1921
+ $us = new UserService();
1922
+
1923
+ $paramArray = ['username' => '
[email protected] '];
1924
+
1925
+ // create new user
1926
+ $user = [
1927
+ 'name'=>'charli',
1928
+ 'password' => 'abracada',
1929
+ 'emailAddress' => '
[email protected] ',
1930
+ 'displayName' => 'Charli of Atlassian',
1931
+ ];
1932
+
1933
+ $updatedUser = $us->update($paramArray, $user)
1934
+
1935
+ var_dump($updatedUser);
1936
+
1937
+ } catch (JiraRestApi\JiraException $e) {
1938
+ print("Error Occured! " . $e->getMessage());
1939
+ }
1940
+
1941
+ ```
1942
+
1906
1943
#### Create Group
1907
1944
1908
1945
[ See Jira API reference] ( https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/group-createGroup )
Original file line number Diff line number Diff line change @@ -222,4 +222,31 @@ public function getUsers($paramArray)
222
222
223
223
return $ users ;
224
224
}
225
+
226
+ /**
227
+ * Function to update an existing user.
228
+ *
229
+ * @param array $paramArray
230
+ * @param User|array $user
231
+ *
232
+ * @throws \JiraRestApi\JiraException
233
+ * @throws \JsonMapper_Exception
234
+ *
235
+ * @return User User class
236
+ */
237
+ public function update ($ paramArray , $ user )
238
+ {
239
+ $ queryParam = '? ' .http_build_query ($ paramArray );
240
+
241
+ $ data = json_encode ($ user );
242
+
243
+ $ this ->log ->info ("Update User ( " .$ queryParam .") = \n" .$ data );
244
+
245
+ $ ret = $ this ->exec ($ this ->uri .$ queryParam , $ data , 'PUT ' );
246
+
247
+ return $ this ->json_mapper ->map (
248
+ json_decode ($ ret ),
249
+ new User ()
250
+ );
251
+ }
225
252
}
You can’t perform that action at this time.
0 commit comments