package com.zxhl.cms.pay.presenter

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.video.MemberEntity
import com.zxhl.cms.pay.contract.CoinStoreContract
import com.zxhl.cms.pay.contract.VipPayContract
import com.zxhl.cms.pay.contract.VipPayDialogContract

/**
 * @author (wangXuewei)
 * @datetime 2022-04-13 10:29 GMT+8
 * @detail :
 */
class VipPayDialogPresenter:VipPayDialogContract.Presenter {

    private val mView: VipPayDialogContract.View

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

    override fun getVipPayList() {
        ApiClient.videoInfoApi.getPayConfig("vip1").compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<MemberEntity>() {
                override fun onSuccess(result: MemberEntity?) {
                    if (!result?.goodsList.isNullOrEmpty()){
                        mView.setVipPayList(result?.goodsList)
                    }else{
                        mView.setVipPayList(null)
                    }
                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                    mView.setVipPayList(null)
                }
            })
    }
}