How can I adapt the Retrofit 2.0 to call the right model according to the server response.
i.e Json return for Successfully
{
"status": "successful",
"session_id": "123",
}
i.e Json return for Failed
{
"status": "fail",
"message": "Wrong Email",
}
I created login model using http://www.jsonschema2pojo.org.
then I call
@FormUrlEncoded
@POST(Constant.API_LOGIN)
Call<UserLogIn> userLogin(@FieldMap Map<String, String> params);
but if the login failed I would need to use this : ?
@FormUrlEncoded
@POST(Constant.API_LOGIN)
Call<UserLogInFalied> userLogin(@FieldMap Map<String, String> params);
I just need the GSON to map the response to the correct model ? Any advice how to over come this/ Thanks.