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

import com.casic.dcms.bean.ProcessPersonBean;
import com.casic.dcms.listener.OnGetNextProcessListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.ProcessPersonModelImpl;
import com.casic.dcms.mvp.presenter.IProcessPersonPresenter;
import com.casic.dcms.mvp.view.IHandleProcessView;

public class ProcessPersonPresenterImpl extends BasePresenter implements IProcessPersonPresenter, OnGetNextProcessListener {

    private final IHandleProcessView view;
    private final ProcessPersonModelImpl actionModel;

    public ProcessPersonPresenterImpl(IHandleProcessView handleProcessView) {
        this.view = handleProcessView;
        actionModel = new ProcessPersonModelImpl(this);
    }

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

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

    @Override
    public void onSuccess(ProcessPersonBean resultBean) {
        view.obtainResultData(resultBean);
    }

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