Skip to content

Commit

Permalink
add findUsers method.
Browse files Browse the repository at this point in the history
  • Loading branch information
六幻 committed May 12, 2015
1 parent 3d855d1 commit 0e3aaaa
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/com/messners/gitlab/api/UserApi.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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;
Expand Down Expand Up @@ -75,9 +78,17 @@ public User getUser (int userId) throws GitLabApiException {
* @throws GitLabApiException
*/
public List<User> findUsers(String emailOrUsername) throws GitLabApiException {
Form formData = new Form();
addFormParam(formData, "search", emailOrUsername, true);
ClientResponse response = get(ClientResponse.Status.OK, formData, "users");
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;
}
ClientResponse response = get(ClientResponse.Status.OK, null, url);
return (response.getEntity(new GenericType<List<User>>() {}));
}

Expand Down

0 comments on commit 0e3aaaa

Please sign in to comment.