Skip to content

Instantly share code, notes, and snippets.

@enginebai

enginebai/ChainApi.kt

Last active Jul 26, 2018
Embed
What would you like to do?
fun chainApi1AndApi1(): Observable<okhttp3.Response> {
return Api.api1().flatMap { response1 ->
if (response1.isSuccessful) {
var uploadUrl = response.headers().get(ApiUtils.Header.LOCATION)
uploadUrl?.let { url ->
Api.api2(url)
} ?: kotlin.run {
throw Exceptions.propagate(NullPointerException("Media upload URL is empty"))
}
} else
Observable.error(ApiRequestException(response1))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.