package com.bc_chat.bc_base.presenter

import com.bc_chat.bc_base.contract.ApplyWithdrawContract
import com.bc_chat.bc_base.task.ApplyWithdrawTask
import com.google.gson.JsonObject
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack

/**
 * author：Created by zhaohaoting on 2019/7/19
 * email：526309416@qq.com
 * desc：
 */
class ApplyWithdrawPresenter<VIEW : ApplyWithdrawContract.View>(view: VIEW) : BasePresenter<VIEW>(view), ApplyWithdrawContract.Presenter {
    override fun applyWithdraw(amount: String, user_account: String, platform_name: String, info: String, withdraw_desc: String?) {
        taskHelper.execute<Any>(ApplyWithdrawTask(amount, user_account, platform_name, info, withdraw_desc), object : NetWorkCallBack<JsonObject>() {
            override fun onPreExecute(task: Any?) {
                super.onPreExecute(task)
                view.showLoading(task)
            }

            override fun onPostExecuteSuccess(task: Any?, data: JsonObject?) {
                view.dismissLoading(task)
                view.applyWithdrawSuccess()
            }

            override fun onPostExecuteFailure(task: Any?, exception: java.lang.Exception?) {
                super.onPostExecuteFailure(task, exception)
                view.dismissLoading(task)
                view.applyWithdrawFailure(exception)
            }
        })
    }

}
