within the interface
@POST("/data")
Call<IDVerification> postCustomerConfirmation (@Body IDVerification idVerification);
Within the ActivityUI onCreate
Retrofit client = new Retrofit.Builder()
.baseUrl(APIForid.base_url)
.addConverterFactory(GsonConverterFactory.create())
.build();
Calling a control class or asynchronous use
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);
}
}
}
});
}
}
Within the IDVerification class, create a constructor
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());
}
...
Within each class used previously, have your own constructor
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;
}