Traits work well with Retrofit as long as there is no extra method implemented. Depending on return type RetrofitError: TwitchApi.someMethod: HTTP method annotation is required (e.g., @GET, @POST, etc.).
or java.lang.IllegalArgumentException: TwitchApi.someMethod: Must have either a return type or Callback as last argument.
is thrown.
Is there a way to make retrofit ignore a method that is not annotated with any of retrofit.http.GET / PUT / ...
?
public trait SomeApi {
GET("/endpoint")
public fun getSomething(Query("user") user: String): Observable<SomeResponse>
class object {
public fun create(): SomeApi {
val restAdapter = RestAdapter.Builder().setEndpoint("http://localhost").build()
return restAdapter.create<TwitchApi>(javaClass<SomeApi >())
}
}
public fun someMethodThatBreaksRetrofit(user: String) : Int {
return processResponse(getSomething(user))
}
}