package com.gh.common.util

import android.annotation.SuppressLint
import com.gh.gamecenter.common.constant.Constants
import com.gh.gamecenter.common.utils.singleToMain
import com.gh.gamecenter.common.retrofit.BiResponse
import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.retrofit.RetrofitManager
import com.google.gson.JsonObject

object CertificationSwitchHelper {

    @JvmStatic
    @SuppressLint("CheckResult")
    fun getCertificationSwitch() {
        RetrofitManager.getInstance().api
            .certificationSwitch
            .compose(singleToMain())
            .subscribe(object : BiResponse<JsonObject>() {
                override fun onSuccess(data: JsonObject) {
                    SPUtils.setBoolean(
                        Constants.SP_CERTIFICATION_SWITCH,
                        data["authentication_display_switch"].asString == "on"
                    )
                }
            })
    }
}