class LocationServiceHelper extends BaseHelper {

    public void fetchAllLocations() {
        try {
            HTTPAgent httpAgent = getHttpAgent();
            if (httpAgent == null) {
                throw new IllegalArgumentException(LOCATION_STRUCTURE_URL + " http agent is null");
            }

            String baseUrl = getFormattedBaseUrl();

            JSONObject request = new JSONObject();
            request.put(IS_JURISDICTION, true);
            request.put(AllConstants.SERVER_VERSION, 0);

            Response<String> resp = httpAgent.post(
                    MessageFormat.format("{0}{1}", baseUrl, LOCATION_STRUCTURE_URL),
                    request.toString());

            if (resp.isFailure()) {
                throw new NoHttpResponseException(LOCATION_STRUCTURE_URL + " not returned data");
            }

            List<Location> locations = locationGson.fromJson(
                    resp.payload(),
                    new TypeToken<List<Location>>() {
                    }.getType()
            );

            for (Location location : locations) {
                try {
                    location.setSyncStatus(BaseRepository.TYPE_Synced);

                    locationRepository.addOrUpdate(location);

                    for (LocationTag tag : location.getLocationTags()) {
                        LocationTag locationTag = new LocationTag();
                        locationTag.setLocationId(location.getId());
                        locationTag.setName(tag.getName());

                        locationTagRepository.addOrUpdate(locationTag);
                    }
                } catch (Exception e) {
                    Timber.e(e, "EXCEPTION %s", e.toString());
                }
            }
        } catch (Exception e) {
            Timber.e(e, "EXCEPTION %s", e.toString());
        }
    }

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

}