Skip to content

Instantly share code, notes, and snippets.

@javipacheco
Created November 9, 2017 11:18
Show Gist options
  • Save javipacheco/4d1bebe967d485aaff4a386c00964bec to your computer and use it in GitHub Desktop.
Save javipacheco/4d1bebe967d485aaff4a386c00964bec to your computer and use it in GitHub Desktop.
retrofit Call to Service
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