Helio
05/11/2021, 7:59 AM{
"status": "OneOf<Pending|Queued|InProgress|Finished|NotBuilt>"
}
If I want to serialise it to Enum, I would have:
@Serializable
enum class Status {
@SerialName("Pending") PENDING,
@SerialName("Queued") QUEUED,
@SerialName("InProgress") IN_PROGRESS,
@SerialName("Finished") FINISHED,
@SerialName("NotBuilt") NOT_BUILT,
}
@Serializable
data class ServerResponseModel(val status: Status)
However, when I get a response from the server, let’s say InProgress
all I need to do is build a new Model and return the status as being IN_PROGRESS
.
What would be the best way to achieve that? Do I need to write a custom serialisation in this case? Also, does it makes sense to create an Enum class
for ServerResponseModel
?
Thanks for your assistance.Paul Griffith
05/12/2021, 5:07 PMPaul Griffith
05/12/2021, 5:09 PMHelio
05/12/2021, 9:27 PMHelio
05/12/2021, 9:29 PMenum classes
. The 1st enum would map the responses from Server, which returns: InProgress
. And another that enum that maps a response from Server to InProgress
to IN_PROGRESS
which is the response I want to send.Paul Griffith
05/12/2021, 9:31 PM@JsonNames
annotation?Paul Griffith
05/12/2021, 9:37 PMHelio
05/12/2021, 11:35 PMHelio
05/13/2021, 4:44 AM