Last active
May 17, 2019 08:59
-
-
Save varshabhatia007/db484f145933b642fba15543665f044c to your computer and use it in GitHub Desktop.
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
interface CustomerRepo { | |
fun fetchCustomerDetail(): Single<CustomerDetail> | |
} | |
class CustomerRepoImpl( | |
private val customerEndPoint: CustomerEndPoint): CustomerRepo | |
{ | |
override fun fetchCustomerDetail(): Single<CustomerDetail> { | |
return customerEndPoint | |
.getCustomerData() | |
.flatMap { response -> | |
response.body()?.let { | |
Single.just(it.data) | |
} | |
?: Single.error(HttpException(response)) | |
} | |
.subscribeOn(Schedulers.io()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment