Commit 0e3aaaa8 authored by 六幻's avatar 六幻
Browse files

add findUsers method.

parent 3d855d1f
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List; import java.util.List;
import com.messners.gitlab.api.models.User; import com.messners.gitlab.api.models.User;
...@@ -75,9 +78,17 @@ public class UserApi extends AbstractApi { ...@@ -75,9 +78,17 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<User> findUsers(String emailOrUsername) throws GitLabApiException { public List<User> findUsers(String emailOrUsername) throws GitLabApiException {
Form formData = new Form(); URL url;
addFormParam(formData, "search", emailOrUsername, true); try {
ClientResponse response = get(ClientResponse.Status.OK, formData, "users"); url = new URL(getApiClient().getApiUrl("users").toString()+"?search="+emailOrUsername);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
ClientResponse response = get(ClientResponse.Status.OK, null, url);
return (response.getEntity(new GenericType<List<User>>() {})); return (response.getEntity(new GenericType<List<User>>() {}));
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment