discord-jadx/app/src/main/java/com/discord/models/domain/ModelSubscription.java

674 lines
24 KiB
Java

package com.discord.models.domain;
import b.d.b.a.a;
import com.discord.models.domain.premium.SubscriptionPlanType;
import com.discord.utilities.time.TimeUtils;
import d0.z.d.m;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public final class ModelSubscription extends HasSubscriptionItems {
private final String canceledAt;
private final String createdAt;
private final String currentPeriodEnd;
private final String currentPeriodStart;
/* renamed from: id reason: collision with root package name */
private final String f2704id;
private final List<SubscriptionItem> items;
private final Integer paymentGateway;
private final String paymentGatewayPlanId;
private final String paymentSourceId;
private final SubscriptionRenewalMutations renewalMutations;
private final int status;
private final String trialEndsAt;
private final String trialId;
private final int type;
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public enum PaymentGateway {
STRIPE(1),
BRAINTREE(2),
APPLE(3),
GOOGLE(4),
UNKNOWN(null);
public static final Companion Companion = new Companion(null);
private final Integer intRepresentation;
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final PaymentGateway from(Integer num) {
PaymentGateway paymentGateway;
PaymentGateway[] values = PaymentGateway.values();
int i = 0;
while (true) {
if (i >= 5) {
paymentGateway = null;
break;
}
paymentGateway = values[i];
if (m.areEqual(paymentGateway.getIntRepresentation(), num)) {
break;
}
i++;
}
return paymentGateway != null ? paymentGateway : PaymentGateway.UNKNOWN;
}
}
PaymentGateway(Integer num) {
this.intRepresentation = num;
}
public final Integer getIntRepresentation() {
return this.intRepresentation;
}
}
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public enum Status {
UNPAID(0),
ACTIVE(1),
PAST_DUE(2),
CANCELED(3),
ACCOUNT_HOLD(6);
public static final Companion Companion = new Companion(null);
private final int intRepresentation;
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final Status from(int i) {
Status status;
Status[] values = Status.values();
int i2 = 0;
while (true) {
if (i2 >= 5) {
status = null;
break;
}
status = values[i2];
if (status.getIntRepresentation() == i) {
break;
}
i2++;
}
if (status != null) {
return status;
}
throw new IllegalArgumentException(a.p("unsupported subscription status: ", i));
}
}
Status(int i) {
this.intRepresentation = i;
}
public final int getIntRepresentation() {
return this.intRepresentation;
}
public final boolean isAccountHold() {
return this == ACCOUNT_HOLD;
}
public final boolean isCanceled() {
return this == CANCELED;
}
}
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public static final class SubscriptionAdditionalPlan {
private final long planId;
private final int quantity;
public SubscriptionAdditionalPlan(long j, int i) {
this.planId = j;
this.quantity = i;
}
public static /* synthetic */ SubscriptionAdditionalPlan copy$default(SubscriptionAdditionalPlan subscriptionAdditionalPlan, long j, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
j = subscriptionAdditionalPlan.planId;
}
if ((i2 & 2) != 0) {
i = subscriptionAdditionalPlan.quantity;
}
return subscriptionAdditionalPlan.copy(j, i);
}
public final long component1() {
return this.planId;
}
public final int component2() {
return this.quantity;
}
public final SubscriptionAdditionalPlan copy(long j, int i) {
return new SubscriptionAdditionalPlan(j, i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof SubscriptionAdditionalPlan)) {
return false;
}
SubscriptionAdditionalPlan subscriptionAdditionalPlan = (SubscriptionAdditionalPlan) obj;
return this.planId == subscriptionAdditionalPlan.planId && this.quantity == subscriptionAdditionalPlan.quantity;
}
public final long getPlanId() {
return this.planId;
}
public final int getQuantity() {
return this.quantity;
}
public int hashCode() {
long j = this.planId;
return (((int) (j ^ (j >>> 32))) * 31) + this.quantity;
}
public String toString() {
StringBuilder R = a.R("SubscriptionAdditionalPlan(planId=");
R.append(this.planId);
R.append(", quantity=");
return a.A(R, this.quantity, ")");
}
}
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public static final class SubscriptionItem {
/* renamed from: id reason: collision with root package name */
private final long f2705id;
private final long planId;
private final int quantity;
public SubscriptionItem(long j, long j2, int i) {
this.f2705id = j;
this.planId = j2;
this.quantity = i;
}
public static /* synthetic */ SubscriptionItem copy$default(SubscriptionItem subscriptionItem, long j, long j2, int i, int i2, Object obj) {
if ((i2 & 1) != 0) {
j = subscriptionItem.f2705id;
}
if ((i2 & 2) != 0) {
j2 = subscriptionItem.planId;
}
if ((i2 & 4) != 0) {
i = subscriptionItem.quantity;
}
return subscriptionItem.copy(j, j2, i);
}
public final long component1() {
return this.f2705id;
}
public final long component2() {
return this.planId;
}
public final int component3() {
return this.quantity;
}
public final SubscriptionItem copy(long j, long j2, int i) {
return new SubscriptionItem(j, j2, i);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof SubscriptionItem)) {
return false;
}
SubscriptionItem subscriptionItem = (SubscriptionItem) obj;
return this.f2705id == subscriptionItem.f2705id && this.planId == subscriptionItem.planId && this.quantity == subscriptionItem.quantity;
}
public final long getId() {
return this.f2705id;
}
public final long getPlanId() {
return this.planId;
}
public final int getQuantity() {
return this.quantity;
}
public int hashCode() {
long j = this.f2705id;
long j2 = this.planId;
return (((((int) (j ^ (j >>> 32))) * 31) + ((int) (j2 ^ (j2 >>> 32)))) * 31) + this.quantity;
}
public String toString() {
StringBuilder R = a.R("SubscriptionItem(id=");
R.append(this.f2705id);
R.append(", planId=");
R.append(this.planId);
R.append(", quantity=");
return a.A(R, this.quantity, ")");
}
}
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public static final class SubscriptionRenewalMutations extends HasSubscriptionItems {
private final List<SubscriptionItem> items;
private final String paymentGatewayPlanId;
public SubscriptionRenewalMutations(List<SubscriptionItem> list, String str) {
m.checkNotNullParameter(list, "items");
this.items = list;
this.paymentGatewayPlanId = str;
}
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ SubscriptionRenewalMutations copy$default(SubscriptionRenewalMutations subscriptionRenewalMutations, List list, String str, int i, Object obj) {
if ((i & 1) != 0) {
list = subscriptionRenewalMutations.getItems();
}
if ((i & 2) != 0) {
str = subscriptionRenewalMutations.paymentGatewayPlanId;
}
return subscriptionRenewalMutations.copy(list, str);
}
public final List<SubscriptionItem> component1() {
return getItems();
}
public final String component2() {
return this.paymentGatewayPlanId;
}
public final SubscriptionRenewalMutations copy(List<SubscriptionItem> list, String str) {
m.checkNotNullParameter(list, "items");
return new SubscriptionRenewalMutations(list, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof SubscriptionRenewalMutations)) {
return false;
}
SubscriptionRenewalMutations subscriptionRenewalMutations = (SubscriptionRenewalMutations) obj;
return m.areEqual(getItems(), subscriptionRenewalMutations.getItems()) && m.areEqual(this.paymentGatewayPlanId, subscriptionRenewalMutations.paymentGatewayPlanId);
}
@Override // com.discord.models.domain.HasSubscriptionItems
public List<SubscriptionItem> getItems() {
return this.items;
}
public final String getPaymentGatewayPlanId() {
return this.paymentGatewayPlanId;
}
public int hashCode() {
List<SubscriptionItem> items = getItems();
int i = 0;
int hashCode = (items != null ? items.hashCode() : 0) * 31;
String str = this.paymentGatewayPlanId;
if (str != null) {
i = str.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder R = a.R("SubscriptionRenewalMutations(items=");
R.append(getItems());
R.append(", paymentGatewayPlanId=");
return a.H(R, this.paymentGatewayPlanId, ")");
}
}
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public enum Type {
PREMIUM,
GUILD;
public static final Companion Companion = new Companion(null);
/* compiled from: ModelSubscription.kt */
/* loaded from: classes.dex */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final Type from(int i) {
if (i == 1) {
return Type.PREMIUM;
}
if (i == 2) {
return Type.GUILD;
}
throw new IllegalArgumentException(a.p("unsupported subscription type: ", i));
}
}
}
public ModelSubscription(String str, String str2, String str3, String str4, String str5, String str6, Integer num, String str7, String str8, SubscriptionRenewalMutations subscriptionRenewalMutations, List<SubscriptionItem> list, String str9, int i, int i2) {
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_ID);
m.checkNotNullParameter(str2, "createdAt");
m.checkNotNullParameter(str4, "currentPeriodStart");
m.checkNotNullParameter(str5, "currentPeriodEnd");
m.checkNotNullParameter(list, "items");
this.f2704id = str;
this.createdAt = str2;
this.canceledAt = str3;
this.currentPeriodStart = str4;
this.currentPeriodEnd = str5;
this.paymentSourceId = str6;
this.paymentGateway = num;
this.trialId = str7;
this.trialEndsAt = str8;
this.renewalMutations = subscriptionRenewalMutations;
this.items = list;
this.paymentGatewayPlanId = str9;
this.status = i;
this.type = i2;
}
private final int component13() {
return this.status;
}
private final int component14() {
return this.type;
}
public static /* synthetic */ ModelSubscription copy$default(ModelSubscription modelSubscription, String str, String str2, String str3, String str4, String str5, String str6, Integer num, String str7, String str8, SubscriptionRenewalMutations subscriptionRenewalMutations, List list, String str9, int i, int i2, int i3, Object obj) {
return modelSubscription.copy((i3 & 1) != 0 ? modelSubscription.f2704id : str, (i3 & 2) != 0 ? modelSubscription.createdAt : str2, (i3 & 4) != 0 ? modelSubscription.canceledAt : str3, (i3 & 8) != 0 ? modelSubscription.currentPeriodStart : str4, (i3 & 16) != 0 ? modelSubscription.currentPeriodEnd : str5, (i3 & 32) != 0 ? modelSubscription.paymentSourceId : str6, (i3 & 64) != 0 ? modelSubscription.paymentGateway : num, (i3 & 128) != 0 ? modelSubscription.trialId : str7, (i3 & 256) != 0 ? modelSubscription.trialEndsAt : str8, (i3 & 512) != 0 ? modelSubscription.renewalMutations : subscriptionRenewalMutations, (i3 & 1024) != 0 ? modelSubscription.getItems() : list, (i3 & 2048) != 0 ? modelSubscription.paymentGatewayPlanId : str9, (i3 & 4096) != 0 ? modelSubscription.status : i, (i3 & 8192) != 0 ? modelSubscription.type : i2);
}
public final String component1() {
return this.f2704id;
}
public final SubscriptionRenewalMutations component10() {
return this.renewalMutations;
}
public final List<SubscriptionItem> component11() {
return getItems();
}
public final String component12() {
return this.paymentGatewayPlanId;
}
public final String component2() {
return this.createdAt;
}
public final String component3() {
return this.canceledAt;
}
public final String component4() {
return this.currentPeriodStart;
}
public final String component5() {
return this.currentPeriodEnd;
}
public final String component6() {
return this.paymentSourceId;
}
public final Integer component7() {
return this.paymentGateway;
}
public final String component8() {
return this.trialId;
}
public final String component9() {
return this.trialEndsAt;
}
public final ModelSubscription copy(String str, String str2, String str3, String str4, String str5, String str6, Integer num, String str7, String str8, SubscriptionRenewalMutations subscriptionRenewalMutations, List<SubscriptionItem> list, String str9, int i, int i2) {
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_ID);
m.checkNotNullParameter(str2, "createdAt");
m.checkNotNullParameter(str4, "currentPeriodStart");
m.checkNotNullParameter(str5, "currentPeriodEnd");
m.checkNotNullParameter(list, "items");
return new ModelSubscription(str, str2, str3, str4, str5, str6, num, str7, str8, subscriptionRenewalMutations, list, str9, i, i2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ModelSubscription)) {
return false;
}
ModelSubscription modelSubscription = (ModelSubscription) obj;
return m.areEqual(this.f2704id, modelSubscription.f2704id) && m.areEqual(this.createdAt, modelSubscription.createdAt) && m.areEqual(this.canceledAt, modelSubscription.canceledAt) && m.areEqual(this.currentPeriodStart, modelSubscription.currentPeriodStart) && m.areEqual(this.currentPeriodEnd, modelSubscription.currentPeriodEnd) && m.areEqual(this.paymentSourceId, modelSubscription.paymentSourceId) && m.areEqual(this.paymentGateway, modelSubscription.paymentGateway) && m.areEqual(this.trialId, modelSubscription.trialId) && m.areEqual(this.trialEndsAt, modelSubscription.trialEndsAt) && m.areEqual(this.renewalMutations, modelSubscription.renewalMutations) && m.areEqual(getItems(), modelSubscription.getItems()) && m.areEqual(this.paymentGatewayPlanId, modelSubscription.paymentGatewayPlanId) && this.status == modelSubscription.status && this.type == modelSubscription.type;
}
public final long getAccountHoldEstimatedExpirationTimestamp() {
return TimeUtils.addDaysToDate(this.currentPeriodEnd, 30);
}
public final String getCanceledAt() {
return this.canceledAt;
}
public final String getCreatedAt() {
return this.createdAt;
}
public final String getCurrentPeriodEnd() {
return this.currentPeriodEnd;
}
public final String getCurrentPeriodStart() {
return this.currentPeriodStart;
}
public final String getId() {
return this.f2704id;
}
@Override // com.discord.models.domain.HasSubscriptionItems
public List<SubscriptionItem> getItems() {
return this.items;
}
public final Integer getPaymentGateway() {
return this.paymentGateway;
}
public final String getPaymentGatewayPlanId() {
return this.paymentGatewayPlanId;
}
public final String getPaymentSourceId() {
return this.paymentSourceId;
}
public final SubscriptionPlanType getPlanType() {
return SubscriptionPlanType.Companion.from(getPremiumBasePlanId());
}
public final SubscriptionRenewalMutations getRenewalMutations() {
return this.renewalMutations;
}
public final Status getStatus() {
return Status.Companion.from(this.status);
}
public final String getTrialEndsAt() {
return this.trialEndsAt;
}
public final String getTrialId() {
return this.trialId;
}
public final Type getType() {
return Type.Companion.from(this.type);
}
public final boolean hasAnyOfPlans(Set<Long> set) {
m.checkNotNullParameter(set, "planIds");
List<SubscriptionItem> items = getItems();
if ((items instanceof Collection) && items.isEmpty()) {
return false;
}
for (SubscriptionItem subscriptionItem : items) {
if (set.contains(Long.valueOf(subscriptionItem.getPlanId()))) {
return true;
}
}
return false;
}
public final boolean hasPlan(long j) {
boolean z2;
List<SubscriptionItem> items = getItems();
if (!(items instanceof Collection) || !items.isEmpty()) {
for (SubscriptionItem subscriptionItem : items) {
if (subscriptionItem.getPlanId() == j) {
z2 = true;
continue;
} else {
z2 = false;
continue;
}
if (z2) {
return true;
}
}
}
return false;
}
public int hashCode() {
String str = this.f2704id;
int i = 0;
int hashCode = (str != null ? str.hashCode() : 0) * 31;
String str2 = this.createdAt;
int hashCode2 = (hashCode + (str2 != null ? str2.hashCode() : 0)) * 31;
String str3 = this.canceledAt;
int hashCode3 = (hashCode2 + (str3 != null ? str3.hashCode() : 0)) * 31;
String str4 = this.currentPeriodStart;
int hashCode4 = (hashCode3 + (str4 != null ? str4.hashCode() : 0)) * 31;
String str5 = this.currentPeriodEnd;
int hashCode5 = (hashCode4 + (str5 != null ? str5.hashCode() : 0)) * 31;
String str6 = this.paymentSourceId;
int hashCode6 = (hashCode5 + (str6 != null ? str6.hashCode() : 0)) * 31;
Integer num = this.paymentGateway;
int hashCode7 = (hashCode6 + (num != null ? num.hashCode() : 0)) * 31;
String str7 = this.trialId;
int hashCode8 = (hashCode7 + (str7 != null ? str7.hashCode() : 0)) * 31;
String str8 = this.trialEndsAt;
int hashCode9 = (hashCode8 + (str8 != null ? str8.hashCode() : 0)) * 31;
SubscriptionRenewalMutations subscriptionRenewalMutations = this.renewalMutations;
int hashCode10 = (hashCode9 + (subscriptionRenewalMutations != null ? subscriptionRenewalMutations.hashCode() : 0)) * 31;
List<SubscriptionItem> items = getItems();
int hashCode11 = (hashCode10 + (items != null ? items.hashCode() : 0)) * 31;
String str9 = this.paymentGatewayPlanId;
if (str9 != null) {
i = str9.hashCode();
}
return ((((hashCode11 + i) * 31) + this.status) * 31) + this.type;
}
public final boolean isAppleSubscription() {
return PaymentGateway.Companion.from(this.paymentGateway) == PaymentGateway.APPLE;
}
public final boolean isGoogleSubscription() {
return PaymentGateway.Companion.from(this.paymentGateway) == PaymentGateway.GOOGLE;
}
public final boolean isMobileManaged() {
return isAppleSubscription() || isGoogleSubscription();
}
public final boolean isNonePlan() {
return getPlanType() == SubscriptionPlanType.NONE_MONTH || getPlanType() == SubscriptionPlanType.NONE_YEAR || getPlanType() == SubscriptionPlanType.NONE_3_MONTH || getPlanType() == SubscriptionPlanType.NONE_6_MONTH;
}
public String toString() {
StringBuilder R = a.R("ModelSubscription(id=");
R.append(this.f2704id);
R.append(", createdAt=");
R.append(this.createdAt);
R.append(", canceledAt=");
R.append(this.canceledAt);
R.append(", currentPeriodStart=");
R.append(this.currentPeriodStart);
R.append(", currentPeriodEnd=");
R.append(this.currentPeriodEnd);
R.append(", paymentSourceId=");
R.append(this.paymentSourceId);
R.append(", paymentGateway=");
R.append(this.paymentGateway);
R.append(", trialId=");
R.append(this.trialId);
R.append(", trialEndsAt=");
R.append(this.trialEndsAt);
R.append(", renewalMutations=");
R.append(this.renewalMutations);
R.append(", items=");
R.append(getItems());
R.append(", paymentGatewayPlanId=");
R.append(this.paymentGatewayPlanId);
R.append(", status=");
R.append(this.status);
R.append(", type=");
return a.A(R, this.type, ")");
}
}