package com.zxhl.main.page.presenter

import android.util.Log
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.chat.IMSignEntity
import com.zxhl.main.page.contract.ImLoginContract

class ImPresenter :ImLoginContract.Presenter{
    private val mView: ImLoginContract.View

    constructor(mView: ImLoginContract.View) {
        this.mView = mView
    }

    override fun getSign() {
        ApiClient.homeApi.getAdminKey().compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<IMSignEntity>() {
                override fun onSuccess(result: IMSignEntity) {
                    if (result != null) {
                        Log.e("MXL","成功"+result.key.toString())
                        mView.getSignSuc(result.key.toString())
                    }

                }

                override fun onFailure(e: Throwable, code: String, errorMsg: String) {
                    mView.getSignFail()
                    Log.e("MXL","请求失败"+code+errorMsg)
                }
            })
    }
}