use of org.hisp.dhis.android.core.trackedentity.TrackedEntityInstancePayload in project dhis2-android-sdk by dhis2.
the class TrackedEntityInstancePostCall method call.
@Override
public Response<WebResponse> call() throws Exception {
synchronized (this) {
if (isExecuted) {
throw new IllegalStateException("Call is already executed");
}
isExecuted = true;
}
List<TrackedEntityInstance> trackedEntityInstancesToPost = queryDataToSync();
// if size is 0, then no need to do network request
if (trackedEntityInstancesToPost.isEmpty()) {
return null;
}
TrackedEntityInstancePayload trackedEntityInstancePayload = new TrackedEntityInstancePayload();
trackedEntityInstancePayload.trackedEntityInstances = trackedEntityInstancesToPost;
Response<WebResponse> response = trackedEntityInstanceService.postTrackedEntityInstances(trackedEntityInstancePayload).execute();
if (response.isSuccessful()) {
handleWebResponse(response);
}
return response;
}
Aggregations