Search in sources :

Example 6 with WebResponse

use of org.hisp.dhis.android.core.imports.WebResponse 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;
}
Also used : WebResponse(org.hisp.dhis.android.core.imports.WebResponse) TrackedEntityInstancePayload(org.hisp.dhis.android.core.trackedentity.TrackedEntityInstancePayload) TrackedEntityInstance(org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance)

Example 7 with WebResponse

use of org.hisp.dhis.android.core.imports.WebResponse in project dhis2-android-sdk by dhis2.

the class TrackedEntityInstancePostCallRealIntegrationShould method postTrackedEntityInstances.

private void postTrackedEntityInstances() throws Exception {
    Response response;
    Call<Response<WebResponse>> call = d2.syncTrackedEntityInstances();
    response = call.call();
    assertThat(response.isSuccessful()).isTrue();
}
Also used : Response(retrofit2.Response) WebResponse(org.hisp.dhis.android.core.imports.WebResponse)

Aggregations

WebResponse (org.hisp.dhis.android.core.imports.WebResponse)7 Response (retrofit2.Response)4 EnrollmentImportHandler (org.hisp.dhis.android.core.enrollment.EnrollmentImportHandler)1 EventImportHandler (org.hisp.dhis.android.core.event.EventImportHandler)1 WebResponseHandler (org.hisp.dhis.android.core.imports.WebResponseHandler)1 TrackedEntityInstance (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstance)1 TrackedEntityInstanceImportHandler (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstanceImportHandler)1 TrackedEntityInstancePayload (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstancePayload)1