package com.casic.dcms.mvp.presenter.impl;

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.listener.OnActionResultListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.LoginOutActionModelImpl;
import com.casic.dcms.mvp.presenter.ILoginOutPresenter;
import com.casic.dcms.mvp.view.ILoginOutView;

public class LoginOutPresenterImpl extends BasePresenter implements ILoginOutPresenter, OnActionResultListener {

    private final ILoginOutView view;
    private final LoginOutActionModelImpl actionModel;

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

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

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

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

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