package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.LoginOutActionModelImpl;
import com.casic.dcms.mvp.view.ILoginOutView;

public class LoginOutPresenterImpl extends BasePresenter implements ILoginOutPresenter, LoginOutActionModelImpl.OnLoginOutListener {

    private ILoginOutView view;
    private LoginOutActionModelImpl actionModel;

    public LoginOutPresenterImpl(ILoginOutView loginOutView) {
        this.view = loginOutView;
        actionModel = new LoginOutActionModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest() {
        addSubscription(actionModel.sendRetrofitRequest());
    }

    @Override
    public void onSuccess(ActionResultBean resultBean) {
        view.obtainLoginOutResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {
        view.obtainDataFail();
    }

    @Override
    public void disposeRetrofitRequest() {
        unSubscription();
    }
}
