package com.gh.gamecenter.entity

import com.google.gson.annotations.SerializedName

class AdConfig(
    @SerializedName("_id")
    val id: String = "",
    val name: String,
    val location: String, // 广告插入位置。光环启动：halo_launch 下载管理：download_manager 游戏搜索：game_search 畅玩启动：helper_launch
    val type: String, // 广告位类型。开屏广告：launch 信息流广告：native banner 广告：banner 插屏广告：interstitial
    val position: Int, // 定位，不存在的时候返回：-1
    @SerializedName("display_rules")
    val displayRule: DisplayRule,
    @SerializedName("third_party_ads")
    val thirdPartyAd: ThirdPartyAd? = null,
    @SerializedName("third_party_ads_1")
    val hotStartThirdPartyAd: ThirdPartyAd? = null, // 热启动开屏广告
    @SerializedName("owner_ads")
    val ownerAd: OwnerAdEntity? = null,
) {
    companion object {
        const val TYPE_LAUNCH = "launch"
        const val TYPE_NATIVE = "native"
        const val TYPE_BANNER = "banner"
        const val TYPE_INTERSTITIAL = "interstitial"
    }

    val typeChinese
        get() = when (type) {
            TYPE_LAUNCH -> "开屏"
            TYPE_NATIVE -> "信息流"
            TYPE_BANNER -> "banner"
            TYPE_INTERSTITIAL -> "插屏"
            else -> ""
        }

    class DisplayRule(
        @SerializedName("ad_source")
        var adSource: String, // 广告位获取广告源。第三方广告：third_party_ads 自有广告：owner_ads
        @SerializedName("on_failed")
        var onFailedAction: String, // 第三方广告获取失败/自有广告为空时。显示自有广告/第三方广告：show 隐藏广告位：hide
        var timeout: Float = 3.5F, // 超时时长, 默认值为3.5
        @SerializedName("ad_free_duration")
        var adFreeDuration: Int = 0, // 安装后免广告时长。为空的时候传递：0
        @SerializedName("ad_display_interval")
        var adDisplayInterval: Int = 0, // 广告展示间隔。为空的时候传递：0
        @SerializedName("hot_start_splash_ad")
        var hotStartSplashAd: HotStartSplashAd? = null, // 热启动开屏广告
    ) {
        class HotStartSplashAd(
            var type: String = "", // 是否展示开屏广告。不显示广告：none    显示第三方广告：third_party_ads
            var timeout: Float = 3.5F // 超时时长, 默认值为3.5
        )
    }

    class ThirdPartyAd(
        @SerializedName("source_name")
        val sourceName: String, // 广告源名。穿山甲、倍孜
        @SerializedName("ad_size")
        val displaySize: String,
        @SerializedName("code_name")
        val slotName: String,
        @SerializedName("code_id")
        val slotId: String
    )
}