Kotlin generic post request

192 Views Asked by At

Hio, i´m working on a generic interface for Retrofit API calls in Kotlin. I´m kinda new to Kotlin and i feel like i´m missing something important. i tried to search for a solution but didnt found one.

This is my interface

@JvmSuppressWildcards
interface GenericApiRequest {

@POST("/stuff")
suspend fun <TIn, TOut>getResponse(@Body request: TIn) : TOut
}

This the code where i use it

val response = client.getResponse<RequestDataClass, ResponseDataClass>(RequestDataClass("stuff"))

This is the Error I get:

Parameter type must not include a type variable or wildcard: TIn (parameter #1)
    for method GenericApiRequest.getResponse

I thought it would be solved by the @JvmSuppressWildcards but it didnt helped. Has someone a solution for this?

0

There are 0 best solutions below