package com.gh.gamecenter.entity

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

@Parcelize
class ReserveReminderEntity(
    @SerializedName("sms_config")
    private var _smsConfig: SmsConfig? = null,
    @SerializedName("wechat_config")
    private var _wechatConfig: WechatConfigEntity? = null,
    @SerializedName("calendar_config")
    private var _calendarConfig: CalendarConfig? = null,
    @SerializedName("mirror_type")
    private val _mirrorType: String? = null,
    @SerializedName("wifi_auto_download")
    private val _wifiAutoDownload: Boolean? = null,
    @SerializedName("jpush_id")
    private val _jpushId: String? = null
) : Parcelable {

    val hasSmsConfig: Boolean
        get() = _smsConfig != null

    var smsConfig: SmsConfig
        get() = _smsConfig ?: SmsConfig()
        set(value) {
            _smsConfig = value
        }

    var wechatConfig: WechatConfigEntity
        get() = _wechatConfig ?: WechatConfigEntity()
        set(value) {
            _wechatConfig = value
        }

    val hasCalendarConfig: Boolean
        get() = _calendarConfig != null

    var calendarConfig: CalendarConfig
        get() = _calendarConfig ?: CalendarConfig()
        set(value) {
            _calendarConfig = value
        }

    val mirrorType: String
        get() = _mirrorType ?: ""

    val wifiAutoDownload: Boolean
        get() = _wifiAutoDownload ?: true

    val isEnableAutoDownload: Boolean
        get() = _wifiAutoDownload != null

    val jpushId: String
        get() = _jpushId ?: ""

    companion object {

        private const val ON = "on"
    }

    @Parcelize
    class SmsConfig(
        @SerializedName("notice")
        private var _notice: Boolean? = null,
        @SerializedName("mobile")
        private val _mobile: String? = null,
        @SerializedName("mobile_validated")
        private var _mobileValidated: Boolean? = null
    ) : Parcelable {


        var notice: Boolean
            get() = _notice ?: false
            set(value) {
                _notice = value
            }

        val mobile: String
            get() = _mobile ?: ""

        var mobileValidated: Boolean
            get() = _mobileValidated ?: false
            set(value) {
                _mobileValidated = value
            }

    }

    @Parcelize
    class CalendarConfig(
        @SerializedName("notice")
        private val _notice: Boolean? = null,
        @SerializedName("title")
        private val _title: String? = null,
        @SerializedName("time_start")
        private val _timeStart: Long? = null,
        @SerializedName("time_end")
        private val _timeEnd: Long? = null,
        @SerializedName("advance_seconds")
        private val _advanceSeconds: Long? = null,
        @SerializedName("remark")
        private val _remark: String? = null
    ) : Parcelable {

        val notice: Boolean
            get() = _notice ?: false

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

        val timeStart: Long
            get() = _timeStart ?: 0L

        val timeEnd: Long
            get() = _timeEnd ?: 0L

        val advanceSeconds: Long
            get() = _advanceSeconds ?: 0L

        val remark: String
            get() = _remark ?: ""
    }
}