Created
November 9, 2017 11:18
-
-
Save javipacheco/4d1bebe967d485aaff4a386c00964bec to your computer and use it in GitHub Desktop.
retrofit Call to Service
This file contains 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
package akme | |
import retrofit2.Call | |
fun <T> Call<T>.toService(): Service<T> { | |
val response= this.execute() | |
return if (response.isSuccessful) { | |
ServiceRight { response.body() } | |
} else { | |
ServiceLeft<T>(AkmeException.ApiException("")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment