package com.zxhl.main.page.presenter

import android.util.Log
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.main.page.contract.GoodsReceiveContract

class GoodsReceivePresenter : GoodsReceiveContract.Presenter {

    private val mView: GoodsReceiveContract.View


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

    override fun goodsPickUp(depotId: String?, mobile: String?) {
        ApiClient.homeApi.pickUpGoods(depotId ?: "", mobile ?: "")
            .compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<Any>() {
                override fun onSuccess(result: Any?) {
                    if (result != null) {
                        mView.pickupSuccess()
                    }
                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                    mView.pickupFail()
                    Log.e("MXL", "ERROR" + code + errorMsg + e)
                }
            })
    }
}