class TaskServiceHelper extends BaseHelper {

    public void syncCreatedTaskToServer() {
        HTTPAgent httpAgent = getHttpAgent();
        List<Task> tasks = taskRepository.getAllUnsynchedCreatedTasks();
        if (!tasks.isEmpty()) {
            String jsonPayload = taskGson.toJson(tasks);
            String baseUrl = CoreLibrary.getInstance().context().configuration().dristhiBaseURL();
            Response<String> response = httpAgent.postWithJsonResponse(
                    MessageFormat.format("{0}/{1}",
                            baseUrl,
                            ADD_TASK_URL),
                    jsonPayload);
            if (response.isFailure()) {
                Timber.e("Failed to create new tasks on server.: %s", response.payload());
                return;
            }
            Set<String> unprocessedIds = new HashSet<>();
            if (StringUtils.isNotBlank(response.payload())) {
                if (response.payload().startsWith(TASKS_NOT_PROCESSED)) {
                    unprocessedIds.addAll(Arrays.asList(response.payload().substring(TASKS_NOT_PROCESSED.length()).split(",")));
                }
                for (Task task : tasks) {
                    if (!unprocessedIds.contains(task.getIdentifier()))
                        taskRepository.markTaskAsSynced(task.getIdentifier());
                }
            }

        }
    }

    @VisibleForTesting public  TaskServiceHelper(TaskRepository taskRepository);

}