Skip to content

Instantly share code, notes, and snippets.

@naturalwarren
Last active January 9, 2019 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naturalwarren/9ed4414e7b8e466f7d2601d28c0e96ce to your computer and use it in GitHub Desktop.
Save naturalwarren/9ed4414e7b8e466f7d2601d28c0e96ce to your computer and use it in GitHub Desktop.
/**
* A response from the Coinbase API.
*
* In the event that a 2xx is returned [isSuccessful] will be set to true
* and [body] will be set.
* In the event that a non-2xx response is returned [isSuccessful] will be
* set to false and [errorBody] will be set.
* In the event that a request did not result in a response from the monorail
* [networkError] will be set.
*/
class CoinbaseResponse<T : Any, U : Any>(
response: Response<T>?,
val errorBody: U?,
val networkError: IOException?
) {
val body: T? = response?.body()
val isSuccessful = response?.isSuccessful ?: false
val code: Int? = response?.code()
}
interface OAuthApi {
@POST("token")
fun authToken(@Body body: TokenRequestBody):
Single<CoinbaseResponse<AccessToken, OAuthError>>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment