class LocationServiceHelper extends BaseHelper {

    public void syncUpdatedLocationsToServer() {
        HTTPAgent httpAgent = getHttpAgent();
        List<Location> locations = locationRepository.getAllUnsynchedLocation();
        if (!locations.isEmpty()) {
            String jsonPayload = locationGson.toJson(locations);
            String baseUrl = getFormattedBaseUrl();

            String isJurisdictionParam = "?" + IS_JURISDICTION + "=true";
            Response<String> response = httpAgent.postWithJsonResponse(
                    MessageFormat.format("{0}{1}{2}",
                            baseUrl,
                            CREATE_STRUCTURE_URL,
                            isJurisdictionParam),
                    jsonPayload);
            if (response.isFailure()) {
                Timber.e("Failed to create new locations on server: %s", response.payload());
                return;
            }

            Set<String> unprocessedIds = new HashSet<>();
            if (StringUtils.isNotBlank(response.payload())) {
                if (response.payload().startsWith(LOCATIONS_NOT_PROCESSED)) {
                    unprocessedIds.addAll(Arrays.asList(response.payload().substring(LOCATIONS_NOT_PROCESSED.length()).split(",")));
                }
                for (Location location : locations) {
                    if (!unprocessedIds.contains(location.getId()))
                        locationRepository.markLocationsAsSynced(location.getId());
                }
            }
        }
    }

    public  LocationServiceHelper(LocationRepository locationRepository, LocationTagRepository locationTagRepository, StructureRepository structureRepository);

}