dentro da interface
@POST("/data")
Call<IDVerification> postCustomerConfirmation (@Body IDVerification idVerification);
Dentro do onCreate da ActivityUI
Retrofit client = new Retrofit.Builder()
.baseUrl(APIForid.base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Chamar uma classe de controle ou uso assíncrono
public void sendIDVerification(IDVerification idVerification) {
sendIDVerificationUI.showSending();
if(idVerification != null) {
Call<IDVerification> call = apiForid.postCustomerConfirmation(idVerification);
call.enqueue(new Callback<IDVerification>() {
@Override
public void onResponse(Response<IDVerification> response, Retrofit retrofit) {
if (response.isSuccess()) {
sendIDVerificationUI.finishSendingVerification();
}
}
@Override
public void onFailure(Throwable t) {
if(t.toString() != null) {
String message = t.getMessage();
if (message.contains("timeout") || message.contains("ETIMEDOUT")) {
sendIDVerificationUI.onSendIdVerificationError(0);
} else if (message.contains("Unable to resolve host")) {
sendIDVerificationUI.onSendIdVerificationError(0);
} else if (message.contains("Failed to connect")) {
sendIDVerificationUI.onSendIdVerificationError(0);
} else if (message.contains("SocketTimeout") ){
sendIDVerificationUI.onSendIdVerificationError(0);
}
}
}
});
}
}
Dentro da classe IDVerification criar um construtor
public IDVerification(FacebookProfile facebookProfile, Customer customer, Location location, Picture picture, Audio audio) {
if(facebookProfile != null) {
this.facebookProfile = new FacebookProfile(facebookProfile.getName(),
facebookProfile.getEducation_history(),
facebookProfile.getBirthday(),
facebookProfile.getHometown(),
facebookProfile.getEmail(),
facebookProfile.getLocation());
}
...
Dentro de cada classe usada anteriormente, ter seu próprio construtor
public FacebookProfile (String name, String education_history, String birthday, String hometown, String email, String location){
this.name = name;
this.education_history = education_history;
this.birthday = birthday;
this.hometown = hometown;
this.email = email;
this.location = location;
}
@POST
e um parâmetro com a anotação de@Body
? Chegou a testar isso?