Commit 409e5ea8 authored by 六幻's avatar 六幻
Browse files

rewrite findUsers method.

parent 604c8388
package com.messners.gitlab.api;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import com.messners.gitlab.api.models.User;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import com.messners.gitlab.api.models.User;
public class UserApi extends AbstractApi {
UserApi (GitLabApi gitLabApi) {
......@@ -79,18 +76,10 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException
*/
public List<User> findUsers(String emailOrUsername) throws GitLabApiException {
URL url;
try {
url = new URL(getApiClient().getApiUrl("users").toString()+"?search="+emailOrUsername);
} catch (MalformedURLException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
Response response = get(Response.Status.OK, null, url);
return (response.readEntity(new GenericType<List<User>>() {}));
Form formData = new Form();
addFormParam(formData, "search", emailOrUsername, true);
Response response = get(Response.Status.OK, formData.asMap(), "users");
return (response.readEntity(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