package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.CaseDetailBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.CaseDetailModelImpl;
import com.casic.dcms.mvp.view.ICaseDetailView;

public class CaseDetailPresenterImpl extends BasePresenter implements ICaseDetailPresenter, CaseDetailModelImpl.OnGetCaseDetailListener {

    private ICaseDetailView view;
    private CaseDetailModelImpl actionModel;

    public CaseDetailPresenterImpl(ICaseDetailView caseDetailView) {
        this.view = caseDetailView;
        actionModel = new CaseDetailModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String id) {
        addSubscription(actionModel.sendRetrofitRequest(id));
    }

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

    @Override
    public void onSuccess(CaseDetailBean resultBean) {
        view.obtainCaseDetailData(resultBean);
    }

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