Skip to content

Instantly share code, notes, and snippets.

@varshabhatia007
Last active May 17, 2019 08:59
Show Gist options
  • Save varshabhatia007/db484f145933b642fba15543665f044c to your computer and use it in GitHub Desktop.
Save varshabhatia007/db484f145933b642fba15543665f044c to your computer and use it in GitHub Desktop.
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