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.CancelAlarmModelImpl;
import com.casic.dcms.mvp.presenter.ICancelAlarmPresenter;
import com.casic.dcms.mvp.view.ICancelAlarmView;

public class CancelAlarmPresenterImpl extends BasePresenter implements ICancelAlarmPresenter, OnActionResultListener {

    private final ICancelAlarmView view;
    private final CancelAlarmModelImpl actionModel;

    public CancelAlarmPresenterImpl(ICancelAlarmView cancelAlarmView) {
        this.view = cancelAlarmView;
        actionModel = new CancelAlarmModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String id, String jobStatus, String handleMessage) {
        view.showProgress();
        addSubscription(actionModel.sendSingleCancelRequest(id, jobStatus, handleMessage));
    }

    @Override
    public void onReadyRetrofitRequest(String jobStatus, String handleMessage) {
        view.showProgress();
        addSubscription(actionModel.sendBatchCancelRequest(jobStatus, handleMessage));
    }

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

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

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