package com.cooleshow.usercenter.presenter;

import com.cooleshow.base.presenter.BasePresenter;
import com.cooleshow.base.rx.BaseObserver;
import com.cooleshow.usercenter.data.api.UserApi;
import com.cooleshow.usercenter.presenter.contract.BindPasswordContract;


/**
 * Author by pq, Date on 2022/4/19.
 */
public class BindPasswordPresenter extends BasePresenter<BindPasswordContract.BindPwdView> implements BindPasswordContract.Presenter {

    @Override
    public void onBindPwd(String pwd) {
        if (getView() != null) {
            getView().showLoading();
        }
        addSubscribe(create(UserApi.class).bindPassword(pwd), new BaseObserver<Object>(getView()) {
            @Override
            protected void onSuccess(Object data) {
                if (getView() != null) {
                    getView().onBindSuccess();
                }
            }

            @Override
            public void onError(Throwable e) {
                super.onError(e);
            }
        });
    }
}
