I am new to Android development and learning how to use Retrofit and I am having a hard time to deal with inconsistency response from the server.
There are more than two kinds of responses will be returned from the server.
May I know how to deal with this kind of server response? Should I create different data class to handle it based on the server response?
Server Response
Result - Success
{
"status": true,
"result": {
"id": 1,
"name": "User",
"email": "user@gmail.com"
}
}
Result - Fail
{
"status": false,
"result": []
}
Android Model
public class User implements Serializable {
private boolean status;
private ResultModel result;
public static class ResultModel implements Serializable{
private String id;
private String name;
private String email;
}
}