Most of my API calls return something like this:
{
"message": str,
"status": str,
"different_name_depending_on_endpoint":{
// bunch of stuff
},
}
How can I make the name that goes in the "different_name_depending_on_endpoint" key generic? Like so :
data class ReturnAPI<T>(
@SerializedName("message")
val message: String,
@SerializedName("status")
val status: String,
@SerializedName("how do I make this generic")
val data: T
)
Otherwise for every endpoint I have to create a separate data class for the api return, and a separate data class for the data field, which is impractical. There must be a way to make it generic, right? Or to tell Retrofit to try to fill the data field with whatever else is in the JSON file that isn't message or status.