I'm building an android app in Kotlin, and the response comes in two different structures for success and error. My question is, can I combine those two responses together and create a data class, or should I create a sealed class for that? Success response:
{
"access_token": "xxxxxxxxxxxxxxxxxxxx",
"token_type": "bearer"
}
Error response:
{
"detail": [
{
"loc": [
"body"
],
"msg": "Invalid credentials",
"type": "invalid-credentials"
}
]
}
So can I write it all like this in a single data class or use a sealed class?
data class Auth (
val access_token: String,
val token_type: String,
val details: Details
)