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

import com.casic.dcms.bean.PhoneBookBean;
import com.casic.dcms.listener.OnGetPhoneBookListener;
import com.casic.dcms.mvp.BasePresenter;
import com.casic.dcms.mvp.model.impl.PhoneBookModelImpl;
import com.casic.dcms.mvp.presenter.IPhoneBookPresenter;
import com.casic.dcms.mvp.view.IPhoneBookView;

public class PhoneBookPresenterImpl extends BasePresenter implements IPhoneBookPresenter, OnGetPhoneBookListener {

    private final IPhoneBookView view;
    private final PhoneBookModelImpl actionModel;

    public PhoneBookPresenterImpl(IPhoneBookView phoneBookView) {
        this.view = phoneBookView;
        actionModel = new PhoneBookModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String deptid) {
        addSubscription(actionModel.sendPhoneBookRequest(deptid));
    }

    @Override
    public void onSuccess(PhoneBookBean resultBean) {
        view.obtainPhoneBookResult(resultBean);
    }

    @Override
    public void onFailure(Throwable throwable) {

    }

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