Created
April 17, 2018 15:24
-
-
Save vvsevolodovich/69457b324f5df68dd0e007c453a97a69 to your computer and use it in GitHub Desktop.
Single.fromCallable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun login(auth: Authorization): Single<GithubUser> = Single.fromCallable { | |
val response = get("https://api.github.com/user", auth = auth) | |
if (response.statusCode != 200) { | |
throw RuntimeException("Incorrect login or password") | |
} | |
val jsonObject = response.jsonObject | |
with(jsonObject) { | |
return@with GithubUser(getString("login"), getInt("id"), | |
getString("repos_url"), getString("name")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment