package com.bc_chat.account.presenter

import com.bc_chat.account.contract.ModifyPwdContract
import com.bc_chat.account.task.ModifyPwdTask
import com.google.gson.JsonObject
import com.zhaohaoting.framework.abs.presenter.BasePresenter
import com.zhaohaoting.framework.requset.NetWorkCallBack
import java.lang.Exception

/**
 * author：Created by zhaohaoting on 2019/3/5
 * email：526309416@qq.com
 * desc：修改密码
 */
class ModifyPresenter constructor(view: ModifyPwdContract.View) : BasePresenter<ModifyPwdContract.View>(view), ModifyPwdContract.Presenter {

    override fun modifyPwd(password: String?, newPassword: String?) {
        taskHelper.execute<Any>(ModifyPwdTask(password, newPassword), object : NetWorkCallBack<JsonObject>() {
            override fun onPreExecute(task: Any?) {
                super.onPreExecute(task)
                view.showLoading(task)
            }

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

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