package com.casic.dcms.mvp.presenter;

import com.casic.dcms.bean.UserBean;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.UserDataModelImpl;
import com.casic.dcms.mvp.view.IUserDataView;

public class UserDataPresenterImpl extends BasePresenter implements IUserDataPresenter, UserDataModelImpl.OnObtainUserListener {

    private IUserDataView view;
    private UserDataModelImpl actionModel;

    public UserDataPresenterImpl(IUserDataView userDataView) {
        this.view = userDataView;
        actionModel = new UserDataModelImpl(this);
    }

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

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

    @Override
    public void onSuccess(UserBean userBean) {
        view.obtainUserData(userBean);
    }

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