package com.duben.microtribe.mvp.presenters

import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
import com.duben.microtribe.common.AppConfig
import com.duben.microtribe.manager.AppHttpManager
import com.duben.microtribe.mvp.model.BannerList
import com.duben.microtribe.mvp.model.BaseResponse
import com.duben.microtribe.mvp.model.RecommendBannerList
import com.duben.microtribe.mvp.views.RecommendBannerView
import java.util.HashMap

class RecommendBannerPresenter : BasePresenter<RecommendBannerView>() {

    fun orders() {
        val vo = HashMap<String, Any>()
        vo["vedioId"] = AppConfig.vedioId
        AppHttpManager.getInstance(loanApplication)
            .call(loanService.vedio4Msg(vo),
                object : BaseSubscriber<BaseResponse<RecommendBannerList>>() {
                    override fun onCompleted() {
                        if (isLinkView) return
                    }

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

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

                        val code = baseResponse.status
                        val message = baseResponse.message

                        when (code) {
                            200 -> {
                                view.ordersSuc(baseResponse.data)
                            }
                            else -> {
                                view.showToast(message)
                            }
                        }
                    }
                })
    }
}