package com.adealink.weparty.module.account.data

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize
import java.util.Locale

enum class UserKickReason(val value: Long) {
    //客户端自定义的
    REASON_LOCAL_KICK_TOKEN_EXPIRE(-1),//token过期
    REASON_LOCAL_KICK_BLOCK(-2),//封禁账号
    REASON_LOGIN_CHANGE_GENDER(-3), //性别变更

    //服务端定义的
    REASON_KICK_ONLINE_BY_MULTIPOINT_LOGIN(1),
    REASON_BE_BLOCK(2)//被封禁
}

data class BannerInfoRes(
    @SerializedName("reason") val reason: String,
    @SerializedName("expire") val expire: Long,
)


@Parcelize
data class SmsCountryInfo(
    @SerializedName("areaCode") val areaCode: String,
    @SerializedName("countryCode") val countryCode: String,
    @SerializedName("countryName") var countryName: String,
    @SerializedName("flag") val flag: String,
    @SerializedName("supportSms") val supportSms: Boolean,
    @SerializedName("supportWhatsapp") val supportWhatsapp: Boolean,
    var localeName: String = ""
) : Parcelable {
    fun fill(): SmsCountryInfo {
        localeName = countryName
        val locale = Locale("", this.countryCode)
        val lc = locale.displayCountry
        if (lc.isNotEmpty()) {
            localeName = lc
        }

        if (isChinaRegion(this.countryCode)) {
            val cLocale = Locale("", "CN")
            val clc = cLocale.displayCountry
            if (clc.isNotEmpty()) {
                localeName = "$clc/$localeName"
            }
            countryName = "China/$countryName"
        }
        return this
    }

    private fun isChinaRegion(cc: String): Boolean {
        return "TW" == cc || "MO" == cc || "HK" == cc
    }
}


data class GetSmsCountryReq(
    @SerializedName("deviceId") val deviceId: String,
    @SerializedName("newDeviceId") val newDeviceId: String,
)


enum class GetVerifyCodeReason(val value: Int) {
    REGISTER(0), //注册
    RESET_PASSWORD(1),  //设置密码或者重置密码
    BIND_PHONE(2),  //绑定手机
    CHANGE_BIND_PHONE(3),//修改绑定手机
    FORGET_PASSWORD(4), //忘记密码
    BIND_PHONE_FROM_CERTIFICATION(5);//来自认证中心

    companion object {
        fun map(value: Int?): GetVerifyCodeReason {
            return GetVerifyCodeReason.values().firstOrNull { it.value == value } ?: REGISTER
        }
    }
}