Github: add getCurrentUser function

This commit is contained in:
Aleksey Pivovarov
2013-07-29 19:17:12 +04:00
parent 04ccefa818
commit b1ee555f4b
3 changed files with 9 additions and 3 deletions
@@ -212,7 +212,7 @@ public class GithubShareAction extends DumbAwareAction {
}
// check access to private repos (network)
final GithubUserDetailed userInfo = GithubApiUtil.getCurrentUserInfo(auth);
final GithubUserDetailed userInfo = GithubApiUtil.getCurrentUserDetailed(auth);
githubInfoRef.set(new GithubInfo(auth, userInfo, names));
}
catch (IOException e) {
@@ -232,7 +232,7 @@ public class GithubUtil {
}
private static void testConnection(@NotNull GithubAuthData auth, @Nullable String login) throws IOException {
GithubUserDetailed user = GithubApiUtil.getCurrentUserInfo(auth);
GithubUserDetailed user = GithubApiUtil.getCurrentUserDetailed(auth);
if (login != null && !login.equalsIgnoreCase(user.getLogin())) {
throw new GithubAuthenticationException("Wrong login");
}
@@ -404,7 +404,13 @@ public class GithubApiUtil {
}
@NotNull
public static GithubUserDetailed getCurrentUserInfo(@NotNull GithubAuthData auth) throws IOException {
public static GithubUser getCurrentUser(@NotNull GithubAuthData auth) throws IOException {
JsonElement result = getRequest(auth, "/user");
return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUser.class);
}
@NotNull
public static GithubUserDetailed getCurrentUserDetailed(@NotNull GithubAuthData auth) throws IOException {
JsonElement result = getRequest(auth, "/user");
return createDataFromRaw(fromJson(result, GithubUserRaw.class), GithubUserDetailed.class);
}