Coming from a Typescript world, it would be someth...
# announcements
k
Coming from a Typescript world, it would be something like
Copy code
interface Response extends CommonResponseParams {
 // API endpoint specific params
}
🧵 1
s
you can also just take the interface approach in Kotlin, works about as well
k
From my understandings, data class does not contain methods. A class name should be a noun. An abstract class needs abstract method. These are basic in java - kotlin. Why do you need abstract class in this case?
k
Thanks for the responses thus far guys! I don't need a abstract class specifically, I just want a way to avoid repeating myself many times for Common API parameters. I have tried using interfaces but I cannot use the @SerialisedName GSON decorator within an interface. Also, if I do implement interfaces, would I have to initialize it with a value? Ultimately I want to convert a JSON response to a Kotlin Object so I cannot initialize any vals in the data class itself as that is done when I call
Gson().fromJson(responseBody, MyObject::class.java)
Perhaps there is a better approach for what I am trying to implement? Please do tell me your suggestions! Thanks so much guys!