package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.EventSourceBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.EventSourceModelImpl;
import com.casic.dcms.mvp.view.IEventSourceView;

/**
 * @author : Pengxh
 * @time : 2021/4/16 9:10
 * @email : 290677893@qq.com
 **/
public class EventSourcePresenterImpl extends BasePresenter implements IEventSourcePresenter, EventSourceModelImpl.OnGetEventSourceListener {

    private IEventSourceView view;
    private EventSourceModelImpl actionModel;

    public EventSourcePresenterImpl(IEventSourceView sourceView) {
        this.view = sourceView;
        actionModel = new EventSourceModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String begTime, String endTime) {
        addSubscription(actionModel.sendRetrofitRequest(begTime, endTime));
    }

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

    @Override
    public void onSuccess(EventSourceBean resultBean) {
        view.obtainEventSourceResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }
}
