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

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

    private val mView: CoinStoreContract.View

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

    override fun getCoinPayList() {
        ApiClient.videoInfoApi.getPayConfig("recharge").compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<MemberEntity>() {
                override fun onSuccess(result: MemberEntity?) {
                    if (!result?.goodsList.isNullOrEmpty()){
                        mView.setCoinPayList(result?.goodsList)
                    }
                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                }
            })
    }

    override fun getUserCoins() {
        mView.setUserCoins(0.0)
    }
}