package com.android.billingclient.api; import android.text.TextUtils; import com.firemonkeys.cloudcellapi.Consts; import com.tapjoy.TapjoyConstants; import com.unity3d.ads.core.domain.HandleInvocationsFromAdViewer; import com.unity3d.ads.metadata.InAppPurchaseMetaData; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONObject; /* loaded from: classes.dex */ public final class ProductDetails { public final String zza; public final JSONObject zzb; public final String zzc; public final String zzd; public final String zze; public final String zzf; public final String zzg; public final String zzh; public final String zzi; public final String zzj; public final String zzk; public final List zzl; public final List zzm; public static final class OneTimePurchaseOfferDetails { public final String zza; public final long zzb; public final String zzc; public final String zzd; public final String zze; public final com.google.android.gms.internal.play_billing.zzu zzf; public final Long zzg; public final zzbg zzh; public final zzbi zzi; public final zzbh zzj; public OneTimePurchaseOfferDetails(JSONObject jSONObject) { this.zza = jSONObject.optString("formattedPrice"); this.zzb = jSONObject.optLong("priceAmountMicros"); this.zzc = jSONObject.optString("priceCurrencyCode"); this.zzd = jSONObject.optString("offerIdToken"); this.zze = jSONObject.optString(TapjoyConstants.TJC_PLACEMENT_OFFER_ID); jSONObject.optInt("offerType"); JSONArray optJSONArray = jSONObject.optJSONArray("offerTags"); ArrayList arrayList = new ArrayList(); if (optJSONArray != null) { for (int i = 0; i < optJSONArray.length(); i++) { arrayList.add(optJSONArray.getString(i)); } } this.zzf = com.google.android.gms.internal.play_billing.zzu.zzj(arrayList); this.zzg = jSONObject.has("fullPriceMicros") ? Long.valueOf(jSONObject.optLong("fullPriceMicros")) : null; JSONObject optJSONObject = jSONObject.optJSONObject("discountDisplayInfo"); this.zzh = optJSONObject == null ? null : new zzbg(optJSONObject); JSONObject optJSONObject2 = jSONObject.optJSONObject("validTimeWindow"); this.zzi = optJSONObject2 == null ? null : new zzbi(optJSONObject2); JSONObject optJSONObject3 = jSONObject.optJSONObject("limitedQuantityInfo"); this.zzj = optJSONObject3 != null ? new zzbh(optJSONObject3) : null; } public String getFormattedPrice() { return this.zza; } public long getPriceAmountMicros() { return this.zzb; } public String getPriceCurrencyCode() { return this.zzc; } public final String zza() { return this.zzd; } } public static final class PricingPhase { public final String zza; public final long zzb; public final String zzc; public final String zzd; public final int zze; public final int zzf; public PricingPhase(JSONObject jSONObject) { this.zzd = jSONObject.optString("billingPeriod"); this.zzc = jSONObject.optString("priceCurrencyCode"); this.zza = jSONObject.optString("formattedPrice"); this.zzb = jSONObject.optLong("priceAmountMicros"); this.zzf = jSONObject.optInt("recurrenceMode"); this.zze = jSONObject.optInt("billingCycleCount"); } public String getFormattedPrice() { return this.zza; } public long getPriceAmountMicros() { return this.zzb; } public String getPriceCurrencyCode() { return this.zzc; } } public static class PricingPhases { public final List zza; public PricingPhases(JSONArray jSONArray) { ArrayList arrayList = new ArrayList(); if (jSONArray != null) { for (int i = 0; i < jSONArray.length(); i++) { JSONObject optJSONObject = jSONArray.optJSONObject(i); if (optJSONObject != null) { arrayList.add(new PricingPhase(optJSONObject)); } } } this.zza = arrayList; } public List getPricingPhaseList() { return this.zza; } } public static final class SubscriptionOfferDetails { public final String zza; public final String zzb; public final String zzc; public final PricingPhases zzd; public final List zze; public final zzbf zzf; public SubscriptionOfferDetails(JSONObject jSONObject) { this.zza = jSONObject.optString("basePlanId"); String optString = jSONObject.optString(TapjoyConstants.TJC_PLACEMENT_OFFER_ID); this.zzb = true == optString.isEmpty() ? null : optString; this.zzc = jSONObject.getString("offerIdToken"); this.zzd = new PricingPhases(jSONObject.getJSONArray("pricingPhases")); JSONObject optJSONObject = jSONObject.optJSONObject("installmentPlanDetails"); this.zzf = optJSONObject != null ? new zzbf(optJSONObject) : null; ArrayList arrayList = new ArrayList(); JSONArray optJSONArray = jSONObject.optJSONArray("offerTags"); if (optJSONArray != null) { for (int i = 0; i < optJSONArray.length(); i++) { arrayList.add(optJSONArray.getString(i)); } } this.zze = arrayList; } public String getOfferToken() { return this.zzc; } public PricingPhases getPricingPhases() { return this.zzd; } } public ProductDetails(String str) { this.zza = str; JSONObject jSONObject = new JSONObject(str); this.zzb = jSONObject; String optString = jSONObject.optString(InAppPurchaseMetaData.KEY_PRODUCT_ID); this.zzc = optString; String optString2 = jSONObject.optString("type"); this.zzd = optString2; if (TextUtils.isEmpty(optString)) { throw new IllegalArgumentException("Product id cannot be empty."); } if (TextUtils.isEmpty(optString2)) { throw new IllegalArgumentException("Product type cannot be empty."); } this.zze = jSONObject.optString("title"); this.zzf = jSONObject.optString("name"); this.zzg = jSONObject.optString("description"); this.zzi = jSONObject.optString("packageDisplayName"); this.zzj = jSONObject.optString("iconUrl"); this.zzh = jSONObject.optString("skuDetailsToken"); this.zzk = jSONObject.optString("serializedDocid"); JSONArray optJSONArray = jSONObject.optJSONArray("subscriptionOfferDetails"); if (optJSONArray != null) { ArrayList arrayList = new ArrayList(); for (int i = 0; i < optJSONArray.length(); i++) { arrayList.add(new SubscriptionOfferDetails(optJSONArray.getJSONObject(i))); } this.zzl = arrayList; } else { this.zzl = (optString2.equals(Consts.ITEM_TYPE_SUBSCRIPTION) || optString2.equals("play_pass_subs")) ? new ArrayList() : null; } JSONObject optJSONObject = this.zzb.optJSONObject("oneTimePurchaseOfferDetails"); JSONArray optJSONArray2 = this.zzb.optJSONArray("oneTimePurchaseOfferDetailsList"); ArrayList arrayList2 = new ArrayList(); if (optJSONArray2 != null) { for (int i2 = 0; i2 < optJSONArray2.length(); i2++) { arrayList2.add(new OneTimePurchaseOfferDetails(optJSONArray2.getJSONObject(i2))); } this.zzm = arrayList2; return; } if (optJSONObject == null) { this.zzm = null; } else { arrayList2.add(new OneTimePurchaseOfferDetails(optJSONObject)); this.zzm = arrayList2; } } public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ProductDetails) { return TextUtils.equals(this.zza, ((ProductDetails) obj).zza); } return false; } public String getDescription() { return this.zzg; } public OneTimePurchaseOfferDetails getOneTimePurchaseOfferDetails() { List list = this.zzm; if (list == null || list.isEmpty()) { return null; } return (OneTimePurchaseOfferDetails) this.zzm.get(0); } public String getProductId() { return this.zzc; } public String getProductType() { return this.zzd; } public List getSubscriptionOfferDetails() { return this.zzl; } public String getTitle() { return this.zze; } public int hashCode() { return this.zza.hashCode(); } public String toString() { return "ProductDetails{jsonString='" + this.zza + "', parsedJson=" + this.zzb.toString() + ", productId='" + this.zzc + "', productType='" + this.zzd + "', title='" + this.zze + "', productDetailsToken='" + this.zzh + "', subscriptionOfferDetails=" + String.valueOf(this.zzl) + "}"; } public final String zza() { return this.zzb.optString(HandleInvocationsFromAdViewer.KEY_PACKAGE_NAME); } public final String zzb() { return this.zzh; } public String zzc() { return this.zzk; } }