class PurchaseManager {

    @NonNull
    public Observable<Set<AvailablePurchase>> getAllAvailablePurchases() {
        return Observable.combineLatest(getAvailableConsumablePurchases(), getAvailableSubscriptions(),
                (BiFunction<Set<AvailablePurchase>, Set<AvailablePurchase>, Set<AvailablePurchase>>)
                        (consumablePurchases, subscriptions) -> {
                    final HashSet<AvailablePurchase> combinedSet = new HashSet<>();
                    combinedSet.addAll(consumablePurchases);
                    combinedSet.addAll(subscriptions);
                    return combinedSet;
                })
                .map(inAppPurchases -> {
                        final Set<AvailablePurchase> trimmedInAppPurchases = new HashSet<>();
                        for (final AvailablePurchase availablePurchase : inAppPurchases) {
                            if (availablePurchase.getInAppPurchase() != null) {
                                trimmedInAppPurchases.add(availablePurchase);
                            } else {
                                Logger.debug(PurchaseManager.this, "Omitting {} from available purchases as we're tracking it as owned.", availablePurchase.getInAppPurchase());
                            }
                        }
                    return trimmedInAppPurchases;
                })
                .subscribeOn(subscribeOnScheduler);
    }

    @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);

}