-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There's more things we could test, but this is a start.
- Loading branch information
Showing
6 changed files
with
341 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...venuecatui/src/main/kotlin/com/revenuecat/purchases/ui/revenuecatui/data/PurchasesType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.revenuecat.purchases.ui.revenuecatui.data | ||
|
||
import com.revenuecat.purchases.CacheFetchPolicy | ||
import com.revenuecat.purchases.CustomerInfo | ||
import com.revenuecat.purchases.Offerings | ||
import com.revenuecat.purchases.PurchaseParams | ||
import com.revenuecat.purchases.PurchaseResult | ||
import com.revenuecat.purchases.Purchases | ||
import com.revenuecat.purchases.awaitCustomerInfo | ||
import com.revenuecat.purchases.awaitOfferings | ||
import com.revenuecat.purchases.awaitPurchase | ||
import com.revenuecat.purchases.awaitRestore | ||
|
||
/** | ||
* Abstraction over [Purchases] that can be mocked. | ||
*/ | ||
internal interface PurchasesType { | ||
suspend fun awaitPurchase(purchaseParams: PurchaseParams.Builder): PurchaseResult | ||
|
||
suspend fun awaitRestore(): CustomerInfo | ||
|
||
suspend fun awaitOfferings(): Offerings | ||
|
||
suspend fun awaitCustomerInfo( | ||
fetchPolicy: CacheFetchPolicy = CacheFetchPolicy.default(), | ||
): CustomerInfo | ||
} | ||
|
||
internal class PurchasesImpl(private val purchases: Purchases = Purchases.sharedInstance) : PurchasesType { | ||
override suspend fun awaitPurchase(purchaseParams: PurchaseParams.Builder): PurchaseResult { | ||
return purchases.awaitPurchase(purchaseParams.build()) | ||
} | ||
|
||
override suspend fun awaitRestore(): CustomerInfo { | ||
return purchases.awaitRestore() | ||
} | ||
|
||
override suspend fun awaitOfferings(): Offerings { | ||
return purchases.awaitOfferings() | ||
} | ||
|
||
override suspend fun awaitCustomerInfo(fetchPolicy: CacheFetchPolicy): CustomerInfo { | ||
return purchases.awaitCustomerInfo(fetchPolicy) | ||
} | ||
} |
Oops, something went wrong.