Skip to content

Commit

Permalink
Aligns naming of the suspending extension functions. (#15)
Browse files Browse the repository at this point in the history
Aligns naming of the suspending extension functions with the official SDK.
  • Loading branch information
JayShortway authored Feb 21, 2024
1 parent fb2ad4e commit 28798b5
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions core/src/commonMain/kotlin/io/shortway/kobankat/ktx/Coroutines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import io.shortway.kobankat.CustomerInfo
import io.shortway.kobankat.Offerings
import io.shortway.kobankat.Package
import io.shortway.kobankat.Purchases
import io.shortway.kobankat.PurchasesError
import io.shortway.kobankat.PurchasesException
import io.shortway.kobankat.PurchasesTransactionException
import io.shortway.kobankat.appUserID
Expand Down Expand Up @@ -75,7 +74,7 @@ public data class SuccessfulLogin(
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.syncPurchases(): CustomerInfo = suspendCoroutine { continuation ->
public suspend fun Purchases.awaitSyncPurchases(): CustomerInfo = suspendCoroutine { continuation ->
syncPurchases(
onError = { continuation.resumeWithException(PurchasesException(it)) },
onSuccess = { continuation.resume(it) }
Expand All @@ -93,7 +92,7 @@ public suspend fun Purchases.syncPurchases(): CustomerInfo = suspendCoroutine {
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.getOfferings(): Offerings = suspendCoroutine { continuation ->
public suspend fun Purchases.awaitOfferings(): Offerings = suspendCoroutine { continuation ->
getOfferings(
onError = { continuation.resumeWithException(PurchasesException(it)) },
onSuccess = { continuation.resume(it) }
Expand All @@ -106,7 +105,7 @@ public suspend fun Purchases.getOfferings(): Offerings = suspendCoroutine { cont
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.getProducts(
public suspend fun Purchases.awaitGetProducts(
productIds: List<String>
): List<StoreProduct> = suspendCoroutine { continuation ->
getProducts(
Expand All @@ -117,13 +116,12 @@ public suspend fun Purchases.getProducts(
}

/**
* App Store only. Use this method to fetch a [PromotionalOffer] to use with
* [purchase].
* App Store only. Use this method to fetch a [PromotionalOffer] to use with [awaitPurchase].
*
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.getPromotionalOffer(
public suspend fun Purchases.awaitPromotionalOffer(
discount: StoreProductDiscount,
storeProduct: StoreProduct,
): PromotionalOffer = suspendCoroutine { continuation ->
Expand Down Expand Up @@ -163,7 +161,7 @@ public suspend fun Purchases.getPromotionalOffer(
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesTransactionException::class, CancellationException::class)
public suspend fun Purchases.purchase(
public suspend fun Purchases.awaitPurchase(
storeProduct: StoreProduct,
isPersonalizedPrice: Boolean? = null,
oldProductId: String? = null,
Expand Down Expand Up @@ -214,7 +212,7 @@ public suspend fun Purchases.purchase(
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesTransactionException::class, CancellationException::class)
public suspend fun Purchases.purchase(
public suspend fun Purchases.awaitPurchase(
packageToPurchase: Package,
isPersonalizedPrice: Boolean? = null,
oldProductId: String? = null,
Expand Down Expand Up @@ -254,7 +252,7 @@ public suspend fun Purchases.purchase(
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesTransactionException::class, CancellationException::class)
public suspend fun Purchases.purchase(
public suspend fun Purchases.awaitPurchase(
subscriptionOption: SubscriptionOption,
isPersonalizedPrice: Boolean? = null,
oldProductId: String? = null,
Expand Down Expand Up @@ -287,10 +285,10 @@ public suspend fun Purchases.purchase(
*
* @throws PurchasesException in case of an error.
*
* @see [getPromotionalOffer]
* @see [awaitPromotionalOffer]
*/
@Throws(PurchasesTransactionException::class, CancellationException::class)
public suspend fun Purchases.purchase(
public suspend fun Purchases.awaitPurchase(
storeProduct: StoreProduct,
promotionalOffer: PromotionalOffer,
): SuccessfulPurchase = suspendCoroutine { continuation ->
Expand Down Expand Up @@ -319,10 +317,10 @@ public suspend fun Purchases.purchase(
*
* @throws PurchasesException in case of an error.
*
* @see [getPromotionalOffer]
* @see [awaitPromotionalOffer]
*/
@Throws(PurchasesTransactionException::class, CancellationException::class)
public suspend fun Purchases.purchase(
public suspend fun Purchases.awaitPurchase(
packageToPurchase: Package,
promotionalOffer: PromotionalOffer,
): SuccessfulPurchase = suspendCoroutine { continuation ->
Expand Down Expand Up @@ -353,7 +351,7 @@ public suspend fun Purchases.purchase(
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.restorePurchases(): CustomerInfo = suspendCoroutine { continuation ->
public suspend fun Purchases.awaitRestore(): CustomerInfo = suspendCoroutine { continuation ->
restorePurchases(
onError = { continuation.resumeWithException(PurchasesException(it)) },
onSuccess = { continuation.resume(it) },
Expand All @@ -368,7 +366,7 @@ public suspend fun Purchases.restorePurchases(): CustomerInfo = suspendCoroutine
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.logIn(
public suspend fun Purchases.awaitLogIn(
newAppUserID: String,
): SuccessfulLogin = suspendCoroutine { continuation ->
logIn(
Expand All @@ -387,7 +385,7 @@ public suspend fun Purchases.logIn(
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.logOut(): CustomerInfo = suspendCoroutine { continuation ->
public suspend fun Purchases.awaitLogOut(): CustomerInfo = suspendCoroutine { continuation ->
logOut(
onError = { continuation.resumeWithException(PurchasesException(it)) },
onSuccess = { continuation.resume(it) },
Expand All @@ -402,7 +400,7 @@ public suspend fun Purchases.logOut(): CustomerInfo = suspendCoroutine { continu
* @throws PurchasesException in case of an error.
*/
@Throws(PurchasesException::class, CancellationException::class)
public suspend fun Purchases.getCustomerInfo(
public suspend fun Purchases.awaitCustomerInfo(
fetchPolicy: CacheFetchPolicy = CacheFetchPolicy.default(),
): CustomerInfo = suspendCoroutine { continuation ->
getCustomerInfo(
Expand Down

0 comments on commit 28798b5

Please sign in to comment.