Skip to content

Instantly share code, notes, and snippets.

@naturalwarren
Last active December 2, 2018 21:17
Show Gist options
  • Save naturalwarren/90b93fe52963f5b36e3f7ffbbaffa01b to your computer and use it in GitHub Desktop.
Save naturalwarren/90b93fe52963f5b36e3f7ffbbaffa01b to your computer and use it in GitHub Desktop.
Custom response class CoinbaseResponse.
/**
* A response class that holds a success and error body type as well
* as a throwable for network errors.
*
* @param T success response body type.
* @param U error response body type.
* @param body set when a call succeeds with a 2xx status code.
* @param errorBody set when a call fails with a non-2xx calls status code.
* @param networkError set when a network error occurs.
*/
data class CoinbaseResponse<T : Any, U : Any>(
val body: T?,
val errorBody: U?,
val networkError: IOException?)
/**
* Sample service that returns a stream of [CoinbaseResponse].
*/
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