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.ChangeShopInfoModelImpl;
import com.casic.dcms.mvp.presenter.IChangeShopInfoPresenter;
import com.casic.dcms.mvp.view.IShopInfoChangeView;

public class ShopChangePresenterImpl extends BasePresenter implements IChangeShopInfoPresenter, OnActionResultListener {

    private final IShopInfoChangeView view;
    private final ChangeShopInfoModelImpl actionModel;

    public ShopChangePresenterImpl(IShopInfoChangeView changeShopView) {
        this.view = changeShopView;
        actionModel = new ChangeShopInfoModelImpl(this);
    }

    @Override
    public void onReadyRetrofitRequest(String merchantId, String merchantName, String contactName, String contactPhone,
                                       String images) {
        view.showProgress();
        addSubscription(actionModel.sendChangeShopInfoRequest(merchantId, merchantName, contactName, contactPhone, images));
    }

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

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

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