package com.mints.goodmoney.mvp.presenters

import com.mints.goodmoney.manager.AppHttpManager
import com.mints.goodmoney.mvp.model.BaseResponse
import com.mints.goodmoney.mvp.model.MainVedioMsgBean
import com.mints.goodmoney.mvp.views.HorizChannelView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable

class HorizChannelPresenter : BasePresenter<HorizChannelView>() {


    fun getSmallHomeVedioBaseMsg() {
        AppHttpManager.getInstance(loanApplication)
                .call(loanService.smallHomeVedioBaseMsg,
                        object : BaseSubscriber<BaseResponse<MainVedioMsgBean>>() {
                            override fun onCompleted() {
                                if (isLinkView) return
                            }

                            override fun onError(e: Throwable) {
                                if (isLinkView) return
                            }

                            override fun onNext(baseResponse: BaseResponse<MainVedioMsgBean>) {
                                if (isLinkView) return

                                val code = baseResponse.getStatus()
                                val message = baseResponse.getMessage()
                                when (code) {
                                    200 -> view.getHomeVedioMsgSuc(baseResponse.data)
                                    else -> view.showToast(message)
                                }
                            }
                        })
    }

}