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

import com.casic.dcms.bean.CaseDetailBean;
import com.casic.dcms.listener.OnGetCaseDetailListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.CaseDetailModelImpl;
import com.casic.dcms.mvp.presenter.ICaseDetailPresenter;
import com.casic.dcms.mvp.view.ICaseDetailView;

public class CaseDetailPresenterImpl extends BasePresenter implements ICaseDetailPresenter, OnGetCaseDetailListener {

    private final ICaseDetailView view;
    private final CaseDetailModelImpl actionModel;

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

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

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

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

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