package com.gh.gamecenter.entity

import com.gh.gamecenter.common.entity.LinkEntity
import com.google.gson.annotations.SerializedName

class RecommendPopupEntity(
    @SerializedName("_id")
    val id: String = "",
    val notice: RecommendNotice = RecommendNotice(),
    @SerializedName("package")
    val recommendPackage: RecommendPackage,
    @SerializedName("popup")
    val popupDetail: PopupDetail = PopupDetail()
)

class RecommendNotice(
    val plan: String = "",// 通知的方案, 一次once, 累计次数count, 每周一次weekly, 每天一次daily, 每次always
    val times: Int = 0// 累计约定的次数
)

class RecommendPackage(
    @SerializedName("download_type")
    private val downloadType: ArrayList<String> = arrayListOf(), // 下载类型, 下载download, 更新upgrade, 插件化to_plugin
    @SerializedName("min_size")
    val minSize: Long = 0,// 安装包最小值
    @SerializedName("name_rule")
    val nameRule: String = "",//包名限制规则, 全部all, 安装的installed, 未安装uninstalled
    val details: ArrayList<String> = arrayListOf()//安装或者未安装的明细包名
) {
    fun getDownloadType(): List<String> {
        return downloadType.map {
            //对应GameUtils.getDownloadBtnText返回的数据
            when (it) {
                "download" -> "下载"
                "upgrade" -> "更新"
                "to_plugin" -> "插件化"
                else -> ""
            }
        }.toList()
    }
}

class PopupDetail(
    val duration: Long = 0,
    val text: String = "",
    val images: ArrayList<String> = arrayListOf(),
    @SerializedName("jump")
    val link: LinkEntity? = null
)

class RecommendRecord(
    var popupId: String = "",
    var showTime: Long = 0L,
    var count: Int = 0
)