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.main.page.contract.ReportContract

class ReportPresenter:ReportContract.Presenter {
    private val mView: ReportContract.View


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

    override fun report(content: String, userId: String) {
        ApiClient.homeApi.report(content, userId)
            .compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<Any>() {
                override fun onSuccess(result: Any?) {
                    if (result != null) {
                        mView.postSuc("成功")
                    }
                }

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