正在查看: Perplexity v2.48.1 应用的 OfferingsFactory.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Perplexity v2.48.1 应用的 OfferingsFactory.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.revenuecat.purchases.common.offerings;
import bl.f;
import com.mapbox.common.location.e;
import com.revenuecat.purchases.Offerings;
import com.revenuecat.purchases.ProductType;
import com.revenuecat.purchases.PurchasesError;
import com.revenuecat.purchases.PurchasesErrorCode;
import com.revenuecat.purchases.common.BillingAbstract;
import com.revenuecat.purchases.common.Dispatcher;
import com.revenuecat.purchases.common.LogIntent;
import com.revenuecat.purchases.common.LogUtilsKt;
import com.revenuecat.purchases.common.LogWrapperKt;
import com.revenuecat.purchases.common.OfferingParser;
import com.revenuecat.purchases.models.StoreProduct;
import gm.j;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.serialization.SerializationException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@Metadata(d1 = {"\u0000T\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\"\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010$\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\u001d\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bJ6\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\f2\u0012\u0010\r\u001a\u000e\u0012\u0004\u0012\u00020\u000f\u0012\u0004\u0012\u00020\n0\u000e2\u0012\u0010\u0010\u001a\u000e\u0012\u0004\u0012\u00020\u0011\u0012\u0004\u0012\u00020\n0\u000eJ\u0016\u0010\u0012\u001a\b\u0012\u0004\u0012\u00020\u00140\u00132\u0006\u0010\u000b\u001a\u00020\fH\u0002JP\u0010\u0015\u001a\u00020\n2\f\u0010\u0016\u001a\b\u0012\u0004\u0012\u00020\u00140\u00132$\u0010\u0017\u001a \u0012\u0016\u0012\u0014\u0012\u0004\u0012\u00020\u0014\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u001a0\u00190\u0018\u0012\u0004\u0012\u00020\n0\u000e2\u0012\u0010\r\u001a\u000e\u0012\u0004\u0012\u00020\u000f\u0012\u0004\u0012\u00020\n0\u000eH\u0002R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\u001b"}, d2 = {"Lcom/revenuecat/purchases/common/offerings/OfferingsFactory;", "", "billing", "Lcom/revenuecat/purchases/common/BillingAbstract;", "offeringParser", "Lcom/revenuecat/purchases/common/OfferingParser;", "dispatcher", "Lcom/revenuecat/purchases/common/Dispatcher;", "(Lcom/revenuecat/purchases/common/BillingAbstract;Lcom/revenuecat/purchases/common/OfferingParser;Lcom/revenuecat/purchases/common/Dispatcher;)V", "createOfferings", "", "offeringsJSON", "Lorg/json/JSONObject;", "onError", "Lkotlin/Function1;", "Lcom/revenuecat/purchases/PurchasesError;", "onSuccess", "Lcom/revenuecat/purchases/common/offerings/OfferingsResultData;", "extractProductIdentifiers", "", "", "getStoreProductsById", "productIds", "onCompleted", "", "", "Lcom/revenuecat/purchases/models/StoreProduct;", "purchases_defaultsRelease"}, k = 1, mv = {1, 8, 0}, xi = 48)
@SourceDebugExtension
public final class OfferingsFactory {
private final BillingAbstract billing;
private final Dispatcher dispatcher;
private final OfferingParser offeringParser;
public OfferingsFactory(BillingAbstract billingAbstract, OfferingParser offeringParser, Dispatcher dispatcher) {
Intrinsics.h(billingAbstract, "billing");
Intrinsics.h(offeringParser, "offeringParser");
Intrinsics.h(dispatcher, "dispatcher");
this.billing = billingAbstract;
this.offeringParser = offeringParser;
this.dispatcher = dispatcher;
}
private final Set<String> extractProductIdentifiers(JSONObject offeringsJSON) {
JSONArray jSONArray = offeringsJSON.getJSONArray("offerings");
LinkedHashSet linkedHashSet = new LinkedHashSet();
int length = jSONArray.length();
for (int i = 0; i < length; i++) {
JSONArray jSONArray2 = jSONArray.getJSONObject(i).getJSONArray("packages");
int length2 = jSONArray2.length();
for (int i2 = 0; i2 < length2; i2++) {
String optString = jSONArray2.getJSONObject(i2).optString("platform_product_identifier");
Intrinsics.g(optString, "it");
if (j.b0(optString)) {
optString = null;
}
if (optString != null) {
linkedHashSet.add(optString);
}
}
}
return linkedHashSet;
}
private final void getStoreProductsById(Set<String> productIds, Function1<? super Map<String, ? extends List<? extends StoreProduct>>, Unit> onCompleted, final Function1<? super PurchasesError, Unit> onError) {
this.billing.queryProductDetailsAsync(ProductType.SUBS, productIds, new OfferingsFactory$getStoreProductsById$1(this, productIds, onCompleted, onError), new Function1<PurchasesError, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
public final void invoke(PurchasesError purchasesError) {
Intrinsics.h(purchasesError, "it");
onError.invoke(purchasesError);
}
});
}
public final void createOfferings(final JSONObject offeringsJSON, Function1<? super PurchasesError, Unit> onError, final Function1<? super OfferingsResultData, Unit> onSuccess) {
final Function1<? super PurchasesError, Unit> function1;
JSONException jSONException;
Intrinsics.h(offeringsJSON, "offeringsJSON");
Intrinsics.h(onError, "onError");
Intrinsics.h(onSuccess, "onSuccess");
try {
final Set<String> extractProductIdentifiers = extractProductIdentifiers(offeringsJSON);
if (extractProductIdentifiers.isEmpty()) {
try {
onError.invoke(new PurchasesError(PurchasesErrorCode.ConfigurationError, "There are no products registered in the RevenueCat dashboard for your offerings. If you don't want to use the offerings system, you can safely ignore this message. To configure offerings and their products, follow the instructions in https://rev.cat/how-to-configure-offerings.\nMore information: https://rev.cat/why-are-offerings-empty"));
return;
} catch (JSONException e) {
jSONException = e;
function1 = onError;
LogWrapperKt.log(LogIntent.RC_ERROR, String.format("JSONException when building Offerings object. Message: %s", Arrays.copyOf(new Object[]{jSONException.getLocalizedMessage()}, 1)));
function1.invoke(new PurchasesError(PurchasesErrorCode.UnexpectedBackendResponseError, jSONException.getLocalizedMessage()));
}
}
function1 = onError;
try {
getStoreProductsById(extractProductIdentifiers, new Function1<Map<String, ? extends List<? extends StoreProduct>>, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((Map<String, ? extends List<? extends StoreProduct>>) obj);
return Unit.a;
}
public final void invoke(Map<String, ? extends List<? extends StoreProduct>> map) {
OfferingParser offeringParser;
Intrinsics.h(map, "productsById");
try {
Set<String> set = extractProductIdentifiers;
ArrayList arrayList = new ArrayList();
for (Object obj : set) {
if (!map.containsKey((String) obj)) {
arrayList.add(obj);
}
}
Set r1 = f.r1(arrayList);
Set set2 = !r1.isEmpty() ? r1 : null;
if (set2 != null) {
LogWrapperKt.log(LogIntent.GOOGLE_WARNING, String.format("Could not find ProductDetails for %s \nThere is a problem with your configuration in Play Store Developer Console. More info here: https://errors.rev.cat/configuring-products", Arrays.copyOf(new Object[]{f.M0(set2, ", ", (String) null, (String) null, (Function1) null, 62)}, 1)));
}
offeringParser = this.offeringParser;
Offerings createOfferings = offeringParser.createOfferings(offeringsJSON, map);
if (createOfferings.getAll().isEmpty()) {
function1.invoke(new PurchasesError(PurchasesErrorCode.ConfigurationError, "There's a problem with your configuration. None of the products registered in the RevenueCat dashboard could be fetched from the Play Store.\nMore information: https://rev.cat/why-are-offerings-empty"));
} else {
LogUtilsKt.verboseLog(String.format("Offerings object created: %s", Arrays.copyOf(new Object[]{createOfferings}, 1)));
onSuccess.invoke(new OfferingsResultData(createOfferings, extractProductIdentifiers, r1));
}
} catch (Exception e2) {
if (!(e2 instanceof JSONException ? true : e2 instanceof SerializationException)) {
throw e2;
}
e.D(new Object[]{e2.getLocalizedMessage()}, 1, "JSONException when building Offerings object. Message: %s", LogIntent.RC_ERROR);
function1.invoke(new PurchasesError(PurchasesErrorCode.UnexpectedBackendResponseError, e2.getLocalizedMessage()));
}
}
}, new Function1<PurchasesError, Unit>() {
{
super(1);
}
public Object invoke(Object obj) {
invoke((PurchasesError) obj);
return Unit.a;
}
public final void invoke(PurchasesError purchasesError) {
Intrinsics.h(purchasesError, "error");
function1.invoke(purchasesError);
}
});
} catch (JSONException e2) {
e = e2;
jSONException = e;
LogWrapperKt.log(LogIntent.RC_ERROR, String.format("JSONException when building Offerings object. Message: %s", Arrays.copyOf(new Object[]{jSONException.getLocalizedMessage()}, 1)));
function1.invoke(new PurchasesError(PurchasesErrorCode.UnexpectedBackendResponseError, jSONException.getLocalizedMessage()));
}
} catch (JSONException e3) {
e = e3;
function1 = onError;
}
}
}