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

import com.casic.dcms.bean.PackageOrDeptBean;
import com.casic.dcms.listener.OnGetPackageCaseListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.PackageCaseModelImpl;
import com.casic.dcms.mvp.presenter.IPackageCasePresenter;
import com.casic.dcms.mvp.view.IPackageCaseView;

public class PackageHandledPresenterImpl extends BasePresenter implements IPackageCasePresenter,
        OnGetPackageCaseListener {

    private final IPackageCaseView view;
    private final PackageCaseModelImpl actionModel;

    public PackageHandledPresenterImpl(IPackageCaseView handledView) {
        this.view = handledView;
        actionModel = new PackageCaseModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String isShop, int offset) {
        addSubscription(actionModel.sendPackageCaseRequest(isShop, offset, true));
    }

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

    @Override
    public void onSuccess(PackageOrDeptBean resultBean) {
        view.obtainPackageCaseResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
