package cn.yyxx.eyuangame.core.entity

import org.json.JSONException
import org.json.JSONObject

/**
 * @author #Suyghur.
 * Created on 2021/06/17
 */
class SdkBackLoginInfo private constructor() {

    var userId = ""
    var token = ""
    var isRegUser = false
    var phoneNum = ""
    var hasBindAccount = false
    var loginType = -1


    fun reset() {
        this.userId = ""
        this.token = ""
        this.isRegUser = false
        this.phoneNum = ""
        this.hasBindAccount = false
        this.loginType = -1
    }

    fun toJsonString(): String {
        val jsonObject = JSONObject()
        try {
            jsonObject.put("uid", userId)
            jsonObject.put("token", token)
        } catch (e: JSONException) {
            e.printStackTrace()
        }
        return jsonObject.toString()
    }

    override fun toString(): String {
        return "SdkBackLoginInfo(userId='$userId', token='$token', isRegUser=$isRegUser, phoneNum=$phoneNum, hasBindAccount=$hasBindAccount, loginType=$loginType)"
    }


    companion object {
        val instance: SdkBackLoginInfo by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            SdkBackLoginInfo()
        }
    }
}