class OcrInformationalTooltipInteractor {

    @NonNull
    public Observable<OcrTooltipMessageType> getShowOcrTooltip() {
        // configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)
        return stateTracker.shouldShowOcrInfo()
                .subscribeOn(Schedulers.computation())
                .flatMapObservable(shouldShowTooltip -> {
                    if (shouldShowTooltip) {
                        if (!configurationManager.isEnabled(ConfigurableResourceFeature.Ocr)) {
                            Logger.info(OcrInformationalTooltipInteractor.this, "OCR is not configured. Disabling the tooltip");
                            return Observable.empty();
                        }
                        if (ocrPurchaseTracker.getRemainingScans() > 0 && ocrPurchaseTracker.getRemainingScans() <= SCANS_LEFT_TO_INFORM) {
                            return Observable.just(OcrTooltipMessageType.LimitedScansRemaining);
                        }
                        if (identityManager.isLoggedIn()) {
                            if (ocrPurchaseTracker.hasAvailableScans()) {
                                return Observable.empty();
                            } else {
                                return Observable.just(OcrTooltipMessageType.NoScansRemaining);
                            }
                        } else {
                            return Observable.just(OcrTooltipMessageType.NotConfigured);
                        }
                    } else {
                        return Observable.empty();
                    }
                })
                .doOnNext(ocrTooltipMessageType -> {
                    Logger.info(OcrInformationalTooltipInteractor.this, "Displaying OCR Tooltip: {}", ocrTooltipMessageType);
                    analytics.record(new DefaultDataPointEvent(Events.Ocr.OcrInfoTooltipShown).addDataPoint(new DataPoint("type", ocrTooltipMessageType)));
                });
    }

    @Inject public  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                             @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                             @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                             @NonNull IdentityManager identityManager,
                                             @NonNull ConfigurationManager configurationManager);
    @VisibleForTesting  OcrInformationalTooltipInteractor(@NonNull Analytics analytics,
                                      @NonNull OcrInformationalTooltipStateTracker stateTracker,
                                      @NonNull OcrPurchaseTracker ocrPurchaseTracker,
                                      @NonNull IdentityManager identityManager,
                                      @NonNull ConfigurationManager configurationManager,
                                      @NonNull Scheduler scheduler);

}