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

import com.casic.dcms.bean.OvertimeCaseBean;
import com.casic.dcms.listener.OnGetOvertimeCaseListListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.OvertimeCaseListModelImpl;
import com.casic.dcms.mvp.presenter.IOvertimeCaseListPresenter;
import com.casic.dcms.mvp.view.IOvertimeCaseListView;

public class OvertimeCaseListPresenterImpl extends BasePresenter implements IOvertimeCaseListPresenter,
        OnGetOvertimeCaseListListener {

    private final IOvertimeCaseListView view;
    private final OvertimeCaseListModelImpl actionModel;

    public OvertimeCaseListPresenterImpl(IOvertimeCaseListView overtimeCaseListView) {
        this.view = overtimeCaseListView;
        actionModel = new OvertimeCaseListModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String isOvertime, int offset) {
        addSubscription(actionModel.sendOvertimeCaseListRequest(isOvertime, offset));
    }

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

    @Override
    public void onSuccess(OvertimeCaseBean resultBean) {
        view.obtainOvertimeCaseList(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
