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

import com.casic.dcms.bean.ActionResultBean;
import com.casic.dcms.listener.OnActionResultListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.CleanToiletModelImpl;
import com.casic.dcms.mvp.presenter.ICleanToiletPresenter;
import com.casic.dcms.mvp.view.IPublicToiletView;

public class CleanToiletPresenterImpl extends BasePresenter implements ICleanToiletPresenter, OnActionResultListener {

    private final IPublicToiletView view;
    private final CleanToiletModelImpl actionModel;

    public CleanToiletPresenterImpl(IPublicToiletView toiletView) {
        this.view = toiletView;
        actionModel = new CleanToiletModelImpl(this);
    }

    @Override
    public void onSuccess(ActionResultBean resultBean) {
        view.obtainCleanResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }

    @Override
    public void onReadyRetrofitRequest(String toiletId, String userId, String lng, String lat,
                                       String startTime, String endTime, String photo, String workContent) {
        addSubscription(actionModel.sendCleanToiletRequest(toiletId, userId, lng, lat, startTime, endTime,
                photo, workContent));
    }

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