package flutter.guru.guru_applovin_flutter

import com.google.android.ump.FormError
import androidx.annotation.IntDef

/**
 *  Created by yaqiliu on 2020-03-06.
 */

class AdStatus {
    companion object {
        @JvmStatic
        val CREATED = 0

        @JvmStatic
        val LOADING = 1

        @JvmStatic
        val FAILED = 2

        @JvmStatic
        val LOADED = 3

        @JvmStatic
        val HIDDEN = 4
    }
}

class AdFormats {

    companion object {
        @JvmStatic
        val BANNER = "BANNER"

        @JvmStatic
        val MREC = "MREC"

        @JvmStatic
        val LEADER = "LEADER"

        @JvmStatic
        val INTERSTITIAL = "INTER"

        @JvmStatic
        val REWARDED = "REWARDED"

        @JvmStatic
        val REWARDED_INTERSTITIAL = "REWARDED_INTER"

        @JvmStatic
        val NATIVE = "NATIVE"

        @JvmStatic
        val CROSS_PROMO = "XPROMO"
    }

}

class ConsentResult {
    companion object {
        val ShouldShow = 0
        val NotShow = -1
        val GdprNotApplies = -2
        val Unknown = -3
    }
}

@IntDef(
    ConsentErrorCode.SUCCESS, ConsentErrorCode.INTERNAL_ERROR,
    ConsentErrorCode.INTERNET_ERROR, ConsentErrorCode.INVALID_OPERATION, ConsentErrorCode.TIME_OUT
)
@Retention(AnnotationRetention.SOURCE)
annotation class ConsentErrorCode {
    companion object {
        // Consent Form Not Available
        const val SUCCESS = 0

        const val INTERNAL_ERROR = 1
        const val INTERNET_ERROR = 2
        const val INVALID_OPERATION = 3
        const val TIME_OUT = 4

        fun toConsentErrorCode(error: FormError?): Int {
            return when (error?.errorCode) {
                FormError.ErrorCode.INTERNAL_ERROR -> INTERNAL_ERROR
                FormError.ErrorCode.TIME_OUT -> TIME_OUT
                FormError.ErrorCode.INTERNET_ERROR -> INTERNET_ERROR
                FormError.ErrorCode.INVALID_OPERATION -> INVALID_OPERATION
                else -> SUCCESS
            }
        }
    }
}

@IntDef(ScreenOrientation.PORTRAIT, ScreenOrientation.LANDSCAPE)
annotation class ScreenOrientation {
    companion object {
        const val PORTRAIT = 0
        const val LANDSCAPE = 1
    }
}