package com.duben.microtribe.mvp.presenters

import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable
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.views.VipEnjoyView


/**
 *  @author Assen
 *  @date 2023/12/5
 *  @desc
 */
class VipEnjoyPresenter : BasePresenter<VipEnjoyView>() {

    fun getVedio4List(page: Int, pageCount: Int) {
        val vo = hashMapOf<String, Any>()
        vo["page"] = page
        vo["size"] = pageCount
        AppHttpManager.getInstance(loanApplication)
            .call(loanService.vedio4List(vo),
                object : BaseSubscriber<BaseResponse<BannerList>>() {
                    override fun onCompleted() {
                        if (isLinkView) return
                    }

                    override fun onError(e: Throwable) {
                        if (isLinkView) return
                        view.showToast(e.message)
                        view.getVedio4ListFail()
                    }

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

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

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

}