package com.sunzee.mvp.main;

import com.sunzee.base.BasePresenter;
import com.sunzee.model.EmailResult;
import com.sunzee.retrofit.ApiCallback;

import java.util.HashMap;
import java.util.Map;

/**
 * 具体的数据交互，逻辑处理，放在 P 里面
 */
public class MainPresenter extends BasePresenter<MainView> {

    public MainPresenter(MainView view) {
        attachView(view);
    }

    // 用bean接收 返回值
    public void testEmail(Map<String,String> param) {
        mvpView.showLoading();
        addSubscription(apiStores.testEmail(param),
                new ApiCallback<EmailResult>() {
                    @Override
                    public void onSuccess(EmailResult model) {
                        mvpView.getDataSuccess(model);
                    }

                    @Override
                    public void onFailure(String msg) {
                        mvpView.getDataFail(msg);
                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }

    // 用map接收 返回值
    public void getOrderStatus(String sn) {
        mvpView.showLoading();
        addSubscription(apiStores.getOrderStatus(sn),
                new ApiCallback<HashMap>() {
                    @Override
                    public void onSuccess(HashMap model) {
                        mvpView.getDataSuccess(model);
                    }

                    @Override
                    public void onFailure(String msg) {
                        mvpView.getDataFail(msg);
                    }


                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }
}
