-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove private typealiases to fix generated documentation #554
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ import com.revenuecat.purchases.interfaces.ProductChangeListener | |
private typealias DeprecatedPurchaseCompletedFunction = (purchase: Purchase, purchaserInfo: PurchaserInfo) -> Unit | ||
@Deprecated("Purchase replaced with StoreTransaction and PurchaserInfo with CustomerInfo") | ||
private typealias DeprecatedProductChangeCompletedFunction = (purchase: Purchase?, purchaserInfo: PurchaserInfo) -> Unit | ||
private typealias ErrorFunction = (error: PurchasesError) -> Unit | ||
private typealias PurchaseErrorFunction = (error: PurchasesError, userCancelled: Boolean) -> Unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left these 2 here since we don't generate docs from these deprecated functions |
||
|
||
@Deprecated("onCompleted Purchase changed with StoreTransaction") | ||
internal fun deprecatedPurchaseCompletedListener( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,20 +10,12 @@ import com.revenuecat.purchases.interfaces.ReceiveOfferingsCallback | |
import com.revenuecat.purchases.models.StoreProduct | ||
import com.revenuecat.purchases.models.StoreTransaction | ||
|
||
private typealias PurchaseCompletedFunction = (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit | ||
private typealias ProductChangeCompletedFunction = (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we lose some info from not having the typealias name (for example, these 2 typealiases are almost identical). But I think we earn in making sure devs know exactly what the API looks like, so I think it's a good change overall |
||
private typealias ReceiveOfferingsSuccessFunction = (offerings: Offerings) -> Unit | ||
private typealias ReceiveCustomerInfoSuccessFunction = (customerInfo: CustomerInfo) -> Unit | ||
private typealias ReceiveLogInSuccessFunction = (customerInfo: CustomerInfo, created: Boolean) -> Unit | ||
internal typealias ErrorFunction = (error: PurchasesError) -> Unit | ||
internal typealias PurchaseErrorFunction = (error: PurchasesError, userCancelled: Boolean) -> Unit | ||
|
||
internal val ON_ERROR_STUB: ErrorFunction = {} | ||
internal val ON_PURCHASE_ERROR_STUB: PurchaseErrorFunction = { _, _ -> } | ||
internal val ON_ERROR_STUB: (error: PurchasesError) -> Unit = {} | ||
internal val ON_PURCHASE_ERROR_STUB: (error: PurchasesError, userCancelled: Boolean) -> Unit = { _, _ -> } | ||
|
||
internal fun purchaseCompletedCallback( | ||
onSuccess: PurchaseCompletedFunction, | ||
onError: PurchaseErrorFunction | ||
onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit, | ||
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit | ||
) = object : PurchaseCallback { | ||
override fun onCompleted(storeTransaction: StoreTransaction, customerInfo: CustomerInfo) { | ||
onSuccess(storeTransaction, customerInfo) | ||
|
@@ -35,8 +27,8 @@ internal fun purchaseCompletedCallback( | |
} | ||
|
||
internal fun productChangeCompletedListener( | ||
onSuccess: ProductChangeCompletedFunction, | ||
onError: PurchaseErrorFunction | ||
onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit, | ||
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit | ||
) = object : ProductChangeCallback { | ||
override fun onCompleted(purchase: StoreTransaction?, customerInfo: CustomerInfo) { | ||
onSuccess(purchase, customerInfo) | ||
|
@@ -49,7 +41,7 @@ internal fun productChangeCompletedListener( | |
|
||
internal fun getStoreProductsCallback( | ||
onReceived: (storeProducts: List<StoreProduct>) -> Unit, | ||
onError: ErrorFunction | ||
onError: (error: PurchasesError) -> Unit | ||
) = object : GetStoreProductsCallback { | ||
override fun onReceived(storeProducts: List<StoreProduct>) { | ||
onReceived(storeProducts) | ||
|
@@ -61,8 +53,8 @@ internal fun getStoreProductsCallback( | |
} | ||
|
||
internal fun receiveOfferingsCallback( | ||
onSuccess: ReceiveOfferingsSuccessFunction, | ||
onError: ErrorFunction | ||
onSuccess: (offerings: Offerings) -> Unit, | ||
onError: (error: PurchasesError) -> Unit | ||
) = object : ReceiveOfferingsCallback { | ||
override fun onReceived(offerings: Offerings) { | ||
onSuccess(offerings) | ||
|
@@ -74,8 +66,8 @@ internal fun receiveOfferingsCallback( | |
} | ||
|
||
internal fun receiveCustomerInfoCallback( | ||
onSuccess: ReceiveCustomerInfoSuccessFunction?, | ||
onError: ErrorFunction? | ||
onSuccess: (customerInfo: CustomerInfo) -> Unit?, | ||
onError: (error: PurchasesError) -> Unit? | ||
) = object : ReceiveCustomerInfoCallback { | ||
override fun onReceived(customerInfo: CustomerInfo) { | ||
onSuccess?.invoke(customerInfo) | ||
|
@@ -87,8 +79,8 @@ internal fun receiveCustomerInfoCallback( | |
} | ||
|
||
internal fun logInSuccessListener( | ||
onSuccess: ReceiveLogInSuccessFunction?, | ||
onError: ErrorFunction? | ||
onSuccess: (customerInfo: CustomerInfo, created: Boolean) -> Unit?, | ||
onError: (error: PurchasesError) -> Unit? | ||
) = object : LogInCallback { | ||
override fun onReceived(customerInfo: CustomerInfo, created: Boolean) { | ||
onSuccess?.invoke(customerInfo, created) | ||
|
@@ -112,8 +104,8 @@ internal fun logInSuccessListener( | |
*/ | ||
@Suppress("unused") | ||
fun Purchases.getOfferingsWith( | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onSuccess: ReceiveOfferingsSuccessFunction | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onSuccess: (offerings: Offerings) -> Unit | ||
) { | ||
getOfferings(receiveOfferingsCallback(onSuccess, onError)) | ||
} | ||
|
@@ -128,14 +120,14 @@ fun Purchases.getOfferingsWith( | |
fun Purchases.purchaseProductWith( | ||
activity: Activity, | ||
storeProduct: StoreProduct, | ||
onError: PurchaseErrorFunction = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: PurchaseCompletedFunction | ||
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh shoot I just realized we have an inconsistency on the order of the functions. Here we have
But other functions have the Nothing to worry about now but wanted to mention it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh good catch! Yeah... I guess we might want to make it consistent on the next major... But probably we shouldn't change it here. |
||
) { | ||
purchaseProduct(activity, storeProduct, purchaseCompletedCallback(onSuccess, onError)) | ||
} | ||
|
||
/** | ||
* Make a purchase. | ||
* Make a purchase upgrading from a previous sku. | ||
* @param [activity] Current activity | ||
* @param [storeProduct] The storeProduct of the product you wish to purchase | ||
* @param [upgradeInfo] The upgradeInfo you wish to upgrade from, containing the oldSku and the optional prorationMode. | ||
|
@@ -147,14 +139,14 @@ fun Purchases.purchaseProductWith( | |
activity: Activity, | ||
storeProduct: StoreProduct, | ||
upgradeInfo: UpgradeInfo, | ||
onError: PurchaseErrorFunction = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: ProductChangeCompletedFunction | ||
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit | ||
) { | ||
purchaseProduct(activity, storeProduct, upgradeInfo, productChangeCompletedListener(onSuccess, onError)) | ||
} | ||
|
||
/** | ||
* Make a purchase. | ||
* Make a purchase upgrading from a previous sku. | ||
* @param [activity] Current activity | ||
* @param [packageToPurchase] The Package you wish to purchase | ||
* @param [upgradeInfo] The upgradeInfo you wish to upgrade from, containing the oldSku and the optional prorationMode. | ||
|
@@ -166,8 +158,8 @@ fun Purchases.purchasePackageWith( | |
activity: Activity, | ||
packageToPurchase: Package, | ||
upgradeInfo: UpgradeInfo, | ||
onError: PurchaseErrorFunction = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: ProductChangeCompletedFunction | ||
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: (purchase: StoreTransaction?, customerInfo: CustomerInfo) -> Unit | ||
) { | ||
purchasePackage(activity, packageToPurchase, upgradeInfo, productChangeCompletedListener(onSuccess, onError)) | ||
} | ||
|
@@ -182,8 +174,8 @@ fun Purchases.purchasePackageWith( | |
fun Purchases.purchasePackageWith( | ||
activity: Activity, | ||
packageToPurchase: Package, | ||
onError: PurchaseErrorFunction = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: PurchaseCompletedFunction | ||
onError: (error: PurchasesError, userCancelled: Boolean) -> Unit = ON_PURCHASE_ERROR_STUB, | ||
onSuccess: (purchase: StoreTransaction, customerInfo: CustomerInfo) -> Unit | ||
) { | ||
purchasePackage(activity, packageToPurchase, purchaseCompletedCallback(onSuccess, onError)) | ||
} | ||
|
@@ -202,8 +194,8 @@ fun Purchases.purchasePackageWith( | |
* @param [onError] Will be called after the call has completed with an error. | ||
*/ | ||
fun Purchases.restorePurchasesWith( | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onSuccess: ReceiveCustomerInfoSuccessFunction | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onSuccess: (customerInfo: CustomerInfo) -> Unit | ||
) { | ||
restorePurchases(receiveCustomerInfoCallback(onSuccess, onError)) | ||
} | ||
|
@@ -218,8 +210,8 @@ fun Purchases.restorePurchasesWith( | |
@Suppress("unused") | ||
fun Purchases.logInWith( | ||
appUserID: String, | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onSuccess: ReceiveLogInSuccessFunction | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onSuccess: (customerInfo: CustomerInfo, created: Boolean) -> Unit | ||
) { | ||
logIn(appUserID, logInSuccessListener(onSuccess, onError)) | ||
} | ||
|
@@ -232,8 +224,8 @@ fun Purchases.logInWith( | |
*/ | ||
@Suppress("unused") | ||
fun Purchases.logOutWith( | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onSuccess: ReceiveCustomerInfoSuccessFunction | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onSuccess: (customerInfo: CustomerInfo) -> Unit | ||
) { | ||
logOut(receiveCustomerInfoCallback(onSuccess, onError)) | ||
} | ||
|
@@ -246,8 +238,8 @@ fun Purchases.logOutWith( | |
*/ | ||
@Suppress("unused") | ||
fun Purchases.getCustomerInfoWith( | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onSuccess: ReceiveCustomerInfoSuccessFunction | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onSuccess: (customerInfo: CustomerInfo) -> Unit | ||
) { | ||
getCustomerInfo(receiveCustomerInfoCallback(onSuccess, onError)) | ||
} | ||
|
@@ -262,8 +254,8 @@ fun Purchases.getCustomerInfoWith( | |
@Suppress("unused") | ||
fun Purchases.getCustomerInfoWith( | ||
fetchPolicy: CacheFetchPolicy, | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onSuccess: ReceiveCustomerInfoSuccessFunction | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onSuccess: (customerInfo: CustomerInfo) -> Unit | ||
) { | ||
getCustomerInfo(fetchPolicy, receiveCustomerInfoCallback(onSuccess, onError)) | ||
} | ||
|
@@ -276,7 +268,7 @@ fun Purchases.getCustomerInfoWith( | |
@Suppress("unused") | ||
fun Purchases.getSubscriptionSkusWith( | ||
skus: List<String>, | ||
onError: ErrorFunction = ON_ERROR_STUB, | ||
onError: (error: PurchasesError) -> Unit = ON_ERROR_STUB, | ||
onReceiveSkus: (storeProducts: List<StoreProduct>) -> Unit | ||
) { | ||
getSubscriptionSkus(skus, getStoreProductsCallback(onReceiveSkus, onError)) | ||
|
@@ -290,7 +282,7 @@ fun Purchases.getSubscriptionSkusWith( | |
@Suppress("unused") | ||
fun Purchases.getNonSubscriptionSkusWith( | ||
skus: List<String>, | ||
onError: ErrorFunction, | ||
onError: (error: PurchasesError) -> Unit, | ||
onReceiveSkus: (storeProducts: List<StoreProduct>) -> Unit | ||
) { | ||
getNonSubscriptionSkus(skus, getStoreProductsCallback(onReceiveSkus, onError)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed these since otherwise these 2 methods with the same name had almost the same documentation.