Skip to content
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

Refactor presentedOfferingIdentifier into presentedOfferingContext object #1612

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.revenuecat.purchases.Package;
import com.revenuecat.purchases.PackageType;
import com.revenuecat.purchases.PresentedOfferingContext;
import com.revenuecat.purchases.models.StoreProduct;

@SuppressWarnings({"unused"})
Expand All @@ -11,6 +12,7 @@ static void check(final Package p) {
final PackageType packageType = p.getPackageType();
final StoreProduct product = p.getProduct();
final String offering = p.getOffering();
final PresentedOfferingContext offeringContext = p.getPresentedOfferingContext();
}

static void check(final PackageType type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.revenuecat.apitester.java;

import com.revenuecat.purchases.PresentedOfferingContext;

@SuppressWarnings({"unused"})
final class PresentedOfferingContextAPI {
static void check(final PresentedOfferingContext presentedOfferingContext) {
final String offeringIdentifier = presentedOfferingContext.getOfferingIdentifier();
}

static void checkConstructor(final String offeringIdentifier) {
final PresentedOfferingContext presentedOfferingContext = new PresentedOfferingContext(offeringIdentifier);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.revenuecat.apitester.java;

import com.android.billingclient.api.ProductDetails;
import com.revenuecat.purchases.PresentedOfferingContext;
import com.revenuecat.purchases.ProductType;
import com.revenuecat.purchases.amazon.AmazonStoreProduct;
import com.revenuecat.purchases.amazon.AmazonStoreProductKt;
Expand All @@ -16,7 +17,7 @@

import java.util.Locale;

@SuppressWarnings({"unused"})
@SuppressWarnings({"unused", "deprecation"})
final class StoreProductAPI {
static void check(final StoreProduct product) {
final Locale locale = Locale.getDefault();
Expand All @@ -36,9 +37,13 @@ static void check(final StoreProduct product) {
SubscriptionOptions subscriptionOptions = product.getSubscriptionOptions();
SubscriptionOption defaultOption = product.getDefaultOption();
String presentedOfferingIdentifier = product.getPresentedOfferingIdentifier();
PresentedOfferingContext presentedOfferingContext = product.getPresentedOfferingContext();

GoogleStoreProduct underlyingGoogleProduct = GoogleStoreProductKt.getGoogleProduct(product);
AmazonStoreProduct underlyingAmazonProduct = AmazonStoreProductKt.getAmazonProduct(product);

final StoreProduct copyWithOfferingId = product.copyWithOfferingId("offeringId");
final StoreProduct copyWithContext = product.copyWithPresentedOfferingContext(new PresentedOfferingContext("offeringId"));
}

static void check(final ProductType type) {
Expand Down Expand Up @@ -85,12 +90,14 @@ static void checkGoogleStoreProduct(GoogleStoreProduct googleStoreProduct) {
null,
googleStoreProduct.getType(),
googleStoreProduct.getPrice(),
googleStoreProduct.getName(),
googleStoreProduct.getTitle(),
googleStoreProduct.getDescription(),
null,
null,
null,
googleStoreProduct.getProductDetails(),
null,
null
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.revenuecat.apitester.java;

import com.revenuecat.purchases.PresentedOfferingContext;
import com.revenuecat.purchases.ProductType;
import com.revenuecat.purchases.ProrationMode;
import com.revenuecat.purchases.ReplacementMode;
Expand All @@ -25,6 +26,7 @@ static void check(final StoreTransaction transaction) {
final String signature = transaction.getSignature();
final JSONObject originalJson = transaction.getOriginalJson();
final String presentedOfferingIdentifier = transaction.getPresentedOfferingIdentifier();
final PresentedOfferingContext presentedOfferingContext = transaction.getPresentedOfferingContext();
final String su1 = transaction.getStoreUserID();
final PurchaseType purchaseType = transaction.getPurchaseType();
final String marketplace = transaction.getMarketplace();
Expand All @@ -33,6 +35,24 @@ static void check(final StoreTransaction transaction) {
final ProrationMode prorationMode = transaction.getProrationMode();

StoreTransaction constructedStoreTransaction = new StoreTransaction(
transaction.getOrderId(),
transaction.getProductIds(),
transaction.getType(),
transaction.getPurchaseTime(),
transaction.getPurchaseToken(),
transaction.getPurchaseState(),
transaction.isAutoRenewing(),
transaction.getSignature(),
transaction.getOriginalJson(),
transaction.getPresentedOfferingContext(),
transaction.getStoreUserID(),
transaction.getPurchaseType(),
transaction.getMarketplace(),
transaction.getSubscriptionOptionId(),
transaction.getReplacementMode()
);

StoreTransaction constructedStoreTransactionWithOfferingId = new StoreTransaction(
transaction.getOrderId(),
transaction.getProductIds(),
transaction.getType(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.revenuecat.apitester.java;

import com.android.billingclient.api.ProductDetails;
import com.revenuecat.purchases.PresentedOfferingContext;
import com.revenuecat.purchases.models.GoogleSubscriptionOption;
import com.revenuecat.purchases.models.PricingPhase;
import com.revenuecat.purchases.models.PurchasingData;
Expand All @@ -16,6 +17,7 @@ static void checkSubscriptionOption(SubscriptionOption subscriptionOption) {
List<String> tags = subscriptionOption.getTags();
Boolean isBasePlan = subscriptionOption.isBasePlan();
String presentedOfferingId = subscriptionOption.getPresentedOfferingIdentifier();
PresentedOfferingContext presentedOfferingContext = subscriptionOption.getPresentedOfferingContext();
PurchasingData purchasingData = subscriptionOption.getPurchasingData();
String id = subscriptionOption.getId();
Boolean isPrepaid = subscriptionOption.isPrepaid();
Expand All @@ -30,6 +32,16 @@ static void checkGoogleSubscriptionOption(GoogleSubscriptionOption googleSubscri
ProductDetails productDetails = googleSubscriptionOption.getProductDetails();

GoogleSubscriptionOption constructedGoogleSubOption = new GoogleSubscriptionOption(
productId,
basePlanId,
offerId,
googleSubscriptionOption.getPricingPhases(),
googleSubscriptionOption.getTags(),
productDetails,
offerToken
);

GoogleSubscriptionOption constructedGoogleSubOptionWithOfferingId = new GoogleSubscriptionOption(
productId,
basePlanId,
offerId,
Expand All @@ -39,6 +51,17 @@ static void checkGoogleSubscriptionOption(GoogleSubscriptionOption googleSubscri
offerToken,
googleSubscriptionOption.getPresentedOfferingIdentifier()
);

GoogleSubscriptionOption constructedGoogleSubOptionWithPresentedContext = new GoogleSubscriptionOption(
productId,
basePlanId,
offerId,
googleSubscriptionOption.getPricingPhases(),
googleSubscriptionOption.getTags(),
productDetails,
offerToken,
googleSubscriptionOption.getPresentedOfferingContext()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import com.revenuecat.purchases.models.Period;
import com.revenuecat.purchases.models.Price;
import com.revenuecat.purchases.models.StoreProduct;
import com.revenuecat.purchases.models.TestStoreProduct;

@SuppressWarnings({"unused"})
@SuppressWarnings({"unused", "deprecation"})
final class TestStoreProductAPI {
static void check(final Price price, final Period period) {
static void checkConstructors(final Price price, final Period period) {
new TestStoreProduct(
"id", "title", "description", price, period, null, null
);
Expand All @@ -20,4 +21,8 @@ static void check(final Price price, final Period period) {
"id", "name", "title", "description", price, period, period, price
);
}

static void checkTestStoreProductIsStoreProduct(final TestStoreProduct testStoreProduct) {
StoreProduct storeProduct = testStoreProduct;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.revenuecat.apitester.kotlin

import com.revenuecat.purchases.Package
import com.revenuecat.purchases.PackageType
import com.revenuecat.purchases.PresentedOfferingContext
import com.revenuecat.purchases.models.StoreProduct

@Suppress("unused", "UNUSED_VARIABLE")
Expand All @@ -12,6 +13,7 @@ private class PackageAPI {
val packageType: PackageType = packageType
val product: StoreProduct = product
val offering: String = offering
val presentedOfferingContext: PresentedOfferingContext = presentedOfferingContext
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.revenuecat.apitester.kotlin

import com.revenuecat.purchases.PresentedOfferingContext

@Suppress("unused", "UNUSED_VARIABLE")
private class PresentedOfferingContextAPI {
fun check(presentedOfferingContext: PresentedOfferingContext) {
val offeringIdentifier: String = presentedOfferingContext.offeringIdentifier
}

fun checkConstructor(offeringId: String) {
val presentedOfferingContext = PresentedOfferingContext(offeringId)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.revenuecat.apitester.kotlin

import com.android.billingclient.api.ProductDetails
import com.revenuecat.purchases.PresentedOfferingContext
import com.revenuecat.purchases.ProductType
import com.revenuecat.purchases.amazon.AmazonStoreProduct
import com.revenuecat.purchases.amazon.amazonProduct
Expand All @@ -14,15 +15,15 @@ import com.revenuecat.purchases.models.googleProduct
import org.json.JSONObject
import java.util.Locale

@Suppress("unused", "UNUSED_VARIABLE", "LongMethod")
@Suppress("unused", "UNUSED_VARIABLE", "LongMethod", "DEPRECATION")
private class StoreProductAPI {
fun check(product: StoreProduct) {
val locale = Locale.getDefault()
with(product) {
val storeProductId: String = id
val sku: String = sku
val type: ProductType = type
val price: Price? = price
val price: Price = price
val formattedPricePerMonth: String? = formattedPricePerMonth(locale)
val formattedPricePerMonthNoLocale: String? = formattedPricePerMonth()
val pricePerWeek: Price? = pricePerWeek(locale)
Expand All @@ -38,8 +39,12 @@ private class StoreProductAPI {
val subscriptionOptions: SubscriptionOptions? = subscriptionOptions
val defaultOption: SubscriptionOption? = defaultOption
val presentedOfferingIdentifier: String? = presentedOfferingIdentifier
val presentedOfferingContext: PresentedOfferingContext? = presentedOfferingContext
val underlyingGoogleProduct: GoogleStoreProduct? = googleProduct
val underlyingAmazonProduct: AmazonStoreProduct? = amazonProduct
val copiedProductWithOfferingId: StoreProduct = copyWithOfferingId("offeringId")
val copiedProduct: StoreProduct = copyWithPresentedOfferingContext(null)
val copiedProduct2: StoreProduct = copyWithPresentedOfferingContext(PresentedOfferingContext("offeringId"))
}
}

Expand Down Expand Up @@ -67,6 +72,21 @@ private class StoreProductAPI {
googleStoreProduct.productDetails,
)

val constructedGoogleStoreProductWithNullOfferingId = GoogleStoreProduct(
googleStoreProduct.id,
null,
googleStoreProduct.type,
googleStoreProduct.price,
googleStoreProduct.name,
googleStoreProduct.title,
googleStoreProduct.description,
googleStoreProduct.period,
googleStoreProduct.subscriptionOptions,
googleStoreProduct.defaultOption,
googleStoreProduct.productDetails,
null,
)

val constructedGoogleStoreProductWithOfferingId = GoogleStoreProduct(
googleStoreProduct.id,
null,
Expand All @@ -78,7 +98,7 @@ private class StoreProductAPI {
googleStoreProduct.subscriptionOptions,
googleStoreProduct.defaultOption,
googleStoreProduct.productDetails,
googleStoreProduct.presentedOfferingIdentifier,
"offeringId",
)

val constructedGoogleStoreProductWithName = GoogleStoreProduct(
Expand All @@ -93,7 +113,6 @@ private class StoreProductAPI {
googleStoreProduct.subscriptionOptions,
googleStoreProduct.defaultOption,
googleStoreProduct.productDetails,
googleStoreProduct.presentedOfferingIdentifier,
)

val constructedGoogleStoreProductWithNameButNoOfferingId = GoogleStoreProduct(
Expand Down Expand Up @@ -131,6 +150,38 @@ private class StoreProductAPI {
amazonStoreProduct.originalProductJSON,
)

val constructedAmazonStoreProductWithContext = AmazonStoreProduct(
amazonStoreProduct.id,
amazonStoreProduct.type,
amazonStoreProduct.name,
amazonStoreProduct.title,
amazonStoreProduct.description,
amazonStoreProduct.period,
amazonStoreProduct.price,
amazonStoreProduct.subscriptionOptions,
amazonStoreProduct.defaultOption,
amazonStoreProduct.iconUrl,
amazonStoreProduct.freeTrialPeriod,
amazonStoreProduct.originalProductJSON,
PresentedOfferingContext("offeringId"),
)

val constructedAmazonStoreProductWithNullContext = AmazonStoreProduct(
amazonStoreProduct.id,
amazonStoreProduct.type,
amazonStoreProduct.name,
amazonStoreProduct.title,
amazonStoreProduct.description,
amazonStoreProduct.period,
amazonStoreProduct.price,
amazonStoreProduct.subscriptionOptions,
amazonStoreProduct.defaultOption,
amazonStoreProduct.iconUrl,
amazonStoreProduct.freeTrialPeriod,
amazonStoreProduct.originalProductJSON,
null,
)

val constructedAmazonStoreProductWithOfferingId = AmazonStoreProduct(
amazonStoreProduct.id,
amazonStoreProduct.type,
Expand Down Expand Up @@ -174,7 +225,7 @@ private class StoreProductAPI {
amazonStoreProduct.iconUrl,
amazonStoreProduct.freeTrialPeriod,
amazonStoreProduct.originalProductJSON,
amazonStoreProduct.presentedOfferingIdentifier,
amazonStoreProduct.presentedOfferingContext,
)
val iconUrl: String = amazonStoreProduct.iconUrl
val freeTrialPeriod: Period? = amazonStoreProduct.freeTrialPeriod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.revenuecat.apitester.kotlin

import com.revenuecat.purchases.PresentedOfferingContext
import com.revenuecat.purchases.ProductType
import com.revenuecat.purchases.ProrationMode
import com.revenuecat.purchases.ReplacementMode
Expand All @@ -8,7 +9,7 @@ import com.revenuecat.purchases.models.PurchaseType
import com.revenuecat.purchases.models.StoreTransaction
import org.json.JSONObject

@Suppress("unused", "UNUSED_VARIABLE")
@Suppress("unused", "UNUSED_VARIABLE", "LongMethod")
private class StoreTransactionAPI {
fun check(transaction: StoreTransaction) {
with(transaction) {
Expand All @@ -23,13 +24,32 @@ private class StoreTransactionAPI {
val signature: String? = signature
val originalJson: JSONObject = originalJson
val presentedOfferingIdentifier: String? = presentedOfferingIdentifier
val presentedOfferingContext: PresentedOfferingContext? = presentedOfferingContext
val su1: String? = storeUserID
val purchaseType: PurchaseType = purchaseType
val subscriptionOptionId: String? = subscriptionOptionId
val replacementMode: ReplacementMode? = replacementMode
val prorationMode: ProrationMode? = prorationMode

val constructedStoreTransaction = StoreTransaction(
orderId,
productIds,
type,
purchaseTime,
purchaseToken,
purchaseState,
isAutoRenewing,
signature,
originalJson,
presentedOfferingContext,
storeUserID,
purchaseType,
marketplace,
subscriptionOptionId,
replacementMode,
)

val constructedStoreTransactionWithOfferingId = StoreTransaction(
orderId,
productIds,
type,
Expand Down
Loading