package com.zxhl.main.page.view

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.SignEntity
import com.zxhl.cms.net.model.chat.SignReceiveEntity

class SignPresenter : SignContract.Presenter {
    private val mView: SignContract.View


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

    override fun getSingList() {
        ApiClient.homeApi.getSingList()
            .compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<SignEntity>() {
                override fun onSuccess(result: SignEntity?) {
                    mView.setSignList(result)
                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                    Log.e("MXL", "error" + errorMsg + "code" + code + e)
                }
            })
    }

    override fun signReceive() {
        ApiClient.homeApi.getSignReceive()
            .compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<SignReceiveEntity>() {
                override fun onSuccess(result: SignReceiveEntity?) {
                    mView.getReceiveSuc(result)
                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                    mView.getReceiveFail()
                    Log.e("MXL", "error" + errorMsg + "code" + code + e)
                }
            })
    }
}