package com.gh.gamecenter.feature.entity

import android.os.Parcelable
import com.gh.gamecenter.common.entity.LinkEntity
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

@Parcelize
data class FirstSetting(
    @SerializedName("first_position")
    val firstPosition: String? = null,
    val banner: List<Banner>? = null,
    val card: Card? = null
) : Parcelable {

    val showBannerFirst: Boolean
        get() = firstPosition == FIRST_POSITION_BANNER

    @Parcelize
    data class Banner(
        @SerializedName("id")
        private val _id: String? = null,
        @SerializedName("icon")
        private val _icon: String? = null,
        @SerializedName("link")
        val link: LinkEntity? = null
    ) : Parcelable {

        val id: String
            get() = _id ?: ""

        val icon: String
            get() = _icon ?: ""

    }

    @Parcelize
    data class Card(
        @SerializedName("title")
        private val _title: String? = null,
        @SerializedName("preview")
        private val _preview: List<Preview>? = null
    ) : Parcelable {

        val title: String
            get() = _title ?: ""

        val preview: List<Preview>
            get() = _preview ?: emptyList()

        @Parcelize
        data class Preview(
            @SerializedName("_id")
            private val _id: String? = null,
            @SerializedName("card_name")
            private val _cardName: String? = null,
            @SerializedName("icon")
            private val _icon: String? = null,
            @SerializedName("link")
            var link: LinkEntity? = null
        ) : Parcelable {

            val id: String
                get() = _id ?: ""

            val cardName: String
                get() = _cardName ?: ""

            val icon: String
                get() = _icon ?: ""
        }
    }

    companion object {
        const val FIRST_POSITION_BANNER = "banner"
        const val FIRST_POSITION_CARD = "card"
    }
}