mg6maciej
11/25/2015, 12:41 PMinterface PasswordAuthApi {
@GET("/oauth/v2/token?grant_type=password")
fun call(
@Query("username") email: String,
@Query("password") password: String): Observable<AuthApiDto>
}
and in tests we have something like this:
val authApiStub = object : PasswordAuthApi {
override fun call(email: String, password: String): Observable<AuthApiDto> {
return Observable.just(AuthApiDto("access_token", 4096, "refresh_token"))
}
}
instead of simply something like:
val authApiStub: PasswordAuthApi = { email, password ->
Observable.just(AuthApiDto("access_token", 4096, "refresh_token"))
}
Also @voddan mentioned it earlier, I would be happy if this was implemented with as
. This was actually the first thing I tried before I learned Kotlin interfaces are not supported. This is also how you do it in Groovy.
val authApiStub = { email, password ->
Observable.just(AuthApiDto("access_token", 4096, "refresh_token"))
} as PasswordAuthApi
I know I can simply create my Retrofit interfaces in Java as a workaround. I would prefer to have 100% code in one language tho.