# Keep enums within the project.
-keep enum app.cash.paykit.core.models.response.GrantType { *; }
-keep enum app.cash.paykit.core.models.sdk.CashAppPayCurrency { *; }
-keep enum app.cash.paykit.core.impl.RequestType { *; }
-keep enum app.cash.paykit.core.utils.ThreadPurpose { *; }


# Rules for Kotlin Serializer - a transitive dependency of KotlinX Datetime.
# Can probably be removed after datetime is updated.

# Keep `Companion` object fields of serializable classes.
# This avoids serializer lookup through `getDeclaredClasses` as done for named companion objects.
-if @kotlinx.serialization.Serializable class **
-keepclassmembers class <1> {
    static <1>$Companion Companion;
}

# Keep `serializer()` on companion objects (both default and named) of serializable classes.
-if @kotlinx.serialization.Serializable class ** {
    static **$* *;
}
-keepclassmembers class <2>$<3> {
    kotlinx.serialization.KSerializer serializer(...);
}

# Keep `INSTANCE.serializer()` of serializable objects.
-if @kotlinx.serialization.Serializable class ** {
    public static ** INSTANCE;
}
-keepclassmembers class <1> {
    public static <1> INSTANCE;
    kotlinx.serialization.KSerializer serializer(...);
}

# @Serializable and @Polymorphic are used at runtime for polymorphic serialization.
-keepattributes RuntimeVisibleAnnotations,AnnotationDefault

# Don't print notes about potential mistakes or omissions in the configuration for kotlinx-serialization classes
# See also https://github.com/Kotlin/kotlinx.serialization/issues/1900
-dontnote kotlinx.serialization.**

# Serialization core uses `java.lang.ClassValue` for caching inside these specified classes.
# If there is no `java.lang.ClassValue` (for example, in Android), then R8/ProGuard will print a warning.
# However, since in this case they will not be used, we can disable these warnings
-dontwarn kotlinx.serialization.internal.ClassValueReferences

# Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`.
# If you have any, replace classes with those containing named companion objects.
-keepattributes InnerClasses # Needed for `getDeclaredClasses`.

-if @kotlinx.serialization.Serializable class
kotlinx.datetime.Instant$Companion, # <-- List serializable classes with named companions.
kotlinx.datetime.Instant$Companion$serializer
{
    static **$* *;
}
-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.
    static <1>$$serializer INSTANCE;
}

# Keep both serializer and serializable classes to save the attribute InnerClasses
-keepclasseswithmembers, allowshrinking, allowobfuscation, allowaccessmodification class
kotlinx.datetime.Instant$Companion, # <-- List serializable classes with named companions.
kotlinx.datetime.Instant$Companion$serializer
{
    *;
}

-dontwarn kotlinx.serialization.KSerializer
-dontwarn kotlinx.serialization.Serializable
-dontwarn kotlinx.serialization.descriptors.PrimitiveKind$STRING
-dontwarn kotlinx.serialization.descriptors.PrimitiveKind
-dontwarn kotlinx.serialization.descriptors.SerialDescriptor
-dontwarn kotlinx.serialization.descriptors.SerialDescriptorsKt
-dontwarn kotlinx.serialization.internal.AbstractPolymorphicSerializer
-if class app.cash.paykit.core.models.analytics.EventStream2Event
-keepnames class app.cash.paykit.core.models.analytics.EventStream2Event
-if class app.cash.paykit.core.models.analytics.EventStream2Event
-keep class app.cash.paykit.core.models.analytics.EventStream2EventJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.analytics.EventStream2Response
-keepnames class app.cash.paykit.core.models.analytics.EventStream2Response
-if class app.cash.paykit.core.models.analytics.EventStream2Response
-keep class app.cash.paykit.core.models.analytics.EventStream2ResponseJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayload
-keepnames class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayload
-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayload
-keep class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayloadJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}
-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayload
-keepnames class kotlin.jvm.internal.DefaultConstructorMarker
-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayload
-keepclassmembers class app.cash.paykit.core.models.analytics.payloads.AnalyticsCustomerRequestPayload {
    public synthetic <init>(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,app.cash.paykit.core.models.pii.PiiString,app.cash.paykit.core.models.pii.PiiString,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,app.cash.paykit.core.models.pii.PiiString,java.lang.Long,java.lang.Long,java.lang.String,java.lang.String,java.lang.String,app.cash.paykit.core.models.pii.PiiString,java.lang.String,java.lang.String,app.cash.paykit.core.models.pii.PiiString,java.lang.String,java.lang.String,app.cash.paykit.core.models.pii.PiiString,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,int,int,kotlin.jvm.internal.DefaultConstructorMarker);
}

-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsEventListenerPayload
-keepnames class app.cash.paykit.core.models.analytics.payloads.AnalyticsEventListenerPayload
-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsEventListenerPayload
-keep class app.cash.paykit.core.models.analytics.payloads.AnalyticsEventListenerPayloadJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsInitializationPayload
-keepnames class app.cash.paykit.core.models.analytics.payloads.AnalyticsInitializationPayload
-if class app.cash.paykit.core.models.analytics.payloads.AnalyticsInitializationPayload
-keep class app.cash.paykit.core.models.analytics.payloads.AnalyticsInitializationPayloadJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.common.Action
-keepnames class app.cash.paykit.core.models.common.Action
-if class app.cash.paykit.core.models.common.Action
-keep class app.cash.paykit.core.models.common.ActionJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}
-if class app.cash.paykit.core.models.common.Action
-keepnames class kotlin.jvm.internal.DefaultConstructorMarker
-if class app.cash.paykit.core.models.common.Action
-keepclassmembers class app.cash.paykit.core.models.common.Action {
    public synthetic <init>(java.lang.Integer,java.lang.String,java.lang.String,java.lang.String,app.cash.paykit.core.models.pii.PiiString,int,kotlin.jvm.internal.DefaultConstructorMarker);
}

-if class app.cash.paykit.core.models.request.CreateCustomerRequest
-keepnames class app.cash.paykit.core.models.request.CreateCustomerRequest
-if class app.cash.paykit.core.models.request.CreateCustomerRequest
-keep class app.cash.paykit.core.models.request.CreateCustomerRequestJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}
-if class app.cash.paykit.core.models.request.CreateCustomerRequest
-keepnames class kotlin.jvm.internal.DefaultConstructorMarker
-if class app.cash.paykit.core.models.request.CreateCustomerRequest
-keepclassmembers class app.cash.paykit.core.models.request.CreateCustomerRequest {
    public synthetic <init>(java.lang.String,app.cash.paykit.core.models.request.CustomerRequestData,int,kotlin.jvm.internal.DefaultConstructorMarker);
}

-if class app.cash.paykit.core.models.request.CustomerRequestData
-keepnames class app.cash.paykit.core.models.request.CustomerRequestData
-if class app.cash.paykit.core.models.request.CustomerRequestData
-keep class app.cash.paykit.core.models.request.CustomerRequestDataJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.ApiError
-keepnames class app.cash.paykit.core.models.response.ApiError
-if class app.cash.paykit.core.models.response.ApiError
-keep class app.cash.paykit.core.models.response.ApiErrorJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.ApiErrorResponse
-keepnames class app.cash.paykit.core.models.response.ApiErrorResponse
-if class app.cash.paykit.core.models.response.ApiErrorResponse
-keep class app.cash.paykit.core.models.response.ApiErrorResponseJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.AuthFlowTriggers
-keepnames class app.cash.paykit.core.models.response.AuthFlowTriggers
-if class app.cash.paykit.core.models.response.AuthFlowTriggers
-keep class app.cash.paykit.core.models.response.AuthFlowTriggersJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.CustomerProfile
-keepnames class app.cash.paykit.core.models.response.CustomerProfile
-if class app.cash.paykit.core.models.response.CustomerProfile
-keep class app.cash.paykit.core.models.response.CustomerProfileJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.CustomerResponseData
-keepnames class app.cash.paykit.core.models.response.CustomerResponseData
-if class app.cash.paykit.core.models.response.CustomerResponseData
-keep class app.cash.paykit.core.models.response.CustomerResponseDataJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.CustomerTopLevelResponse
-keepnames class app.cash.paykit.core.models.response.CustomerTopLevelResponse
-if class app.cash.paykit.core.models.response.CustomerTopLevelResponse
-keep class app.cash.paykit.core.models.response.CustomerTopLevelResponseJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.Grant
-keepnames class app.cash.paykit.core.models.response.Grant
-if class app.cash.paykit.core.models.response.Grant
-keep class app.cash.paykit.core.models.response.GrantJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}
-if class app.cash.paykit.core.models.response.Grant
-keepnames class kotlin.jvm.internal.DefaultConstructorMarker
-if class app.cash.paykit.core.models.response.Grant
-keepclassmembers class app.cash.paykit.core.models.response.Grant {
    public synthetic <init>(java.lang.String,java.lang.String,app.cash.paykit.core.models.response.GrantType,app.cash.paykit.core.models.common.Action,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,int,kotlin.jvm.internal.DefaultConstructorMarker);
}

-if class app.cash.paykit.core.models.response.Origin
-keepnames class app.cash.paykit.core.models.response.Origin
-if class app.cash.paykit.core.models.response.Origin
-keep class app.cash.paykit.core.models.response.OriginJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}

-if class app.cash.paykit.core.models.response.RequesterProfile
-keepnames class app.cash.paykit.core.models.response.RequesterProfile
-if class app.cash.paykit.core.models.response.RequesterProfile
-keep class app.cash.paykit.core.models.response.RequesterProfileJsonAdapter {
    public <init>(com.squareup.moshi.Moshi);
}
