class PurchaseManager {

    @SuppressLint("CheckResult")
    @SuppressWarnings("ResultOfMethodCallIgnored")
    public void initialize(@NonNull Application application) {
        Logger.debug(PurchaseManager.this, "Initializing the purchase manager");
        application.registerActivityLifecycleCallbacks(new PurchaseManagerActivityLifecycleCallbacks(this));

        // Pre-load all of our purchases into memory
        Observable.fromCallable(purchaseWallet::getActiveLocalInAppPurchases)
                .subscribeOn(subscribeOnScheduler)
                .subscribe();

        // Initialize our purchase set to update our wallet
        getAllOwnedPurchases()
                .subscribeOn(subscribeOnScheduler)
                .subscribe(managedProducts -> Logger.debug(PurchaseManager.this, "Successfully initialized all user owned purchases {}.", managedProducts),
                        throwable -> Logger.error(PurchaseManager.this, "Failed to initialize all user owned purchases.", throwable));

        // Fetch all of our remote subscriptions and notify if appropriate
        remoteSubscriptionManager.getNewRemoteSubscriptions()
                .subscribe(newInAppSubscriptions -> {
                    for (RemoteSubscription newRemoteSubscription : newInAppSubscriptions) {
                        for (final PurchaseEventsListener listener : listeners) {
                            listener.onPurchaseSuccess(newRemoteSubscription.getInAppPurchase(), PurchaseSource.Remote);
                        }
                    }
                }, throwable -> Logger.error(this, "Failed to fetch our remote subscriptions"));
    }

    @Inject public  PurchaseManager(@NonNull Context context,
                           @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                           @NonNull PurchaseWallet purchaseWallet,
                           @NonNull Analytics analytics);
    @VisibleForTesting  PurchaseManager(@NonNull Context context,
                    @NonNull RemoteSubscriptionManager remoteSubscriptionManager,
                    @NonNull PurchaseWallet purchaseWallet,
                    @NonNull Analytics analytics,
                    @NonNull Scheduler subscribeOnScheduler,
                    @NonNull Scheduler observeOnScheduler);

}