I have the following object:
{
codigo : "1",
nome : "Carlos"
}
Java class (POJO)
public class usuario{
@SerializedName("codigo")
private int codigo;
@SerializedName("nome")
private String nome;
/* ... */
}
The call
Call<Usuario> getUsuario(@Query("codigo")
How do I call this object using retrofit?
I'm trying like this:
private void getUsuario ( Service service, int codigo ){
Call<Usuario> userCall = service.getUsuario( codigo );
userCall.enqueue(new Callback<Usuario>() {
@Override
public void onResponse(Call<Usuario> call, Response<Usuario> response) {
Log.i("User body",response.toString());
if( response.isSuccessful() ){
//Não sei o que fazer
}
}
@Override
public void onFailure(Call<Usuario> call, Throwable t) {
Log.i("onFailure Usuario", t.getMessage());
}
});
}