package it.integry.integrywmsnative.core.REST.consumers;

import java.util.List;

import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.CommonModelConsts;
import it.integry.integrywmsnative.core.model.MtbDepo;
import it.integry.integrywmsnative.core.utility.UtilityLogger;
import it.integry.integrywmsnative.generated.callback.Runnable;

public class DepositoRESTConsumer {

    public static void getDepoByCodMdep(String codMdep, RunnableArgs<MtbDepo> onComplete) {

        MtbDepo mtbDepo = new MtbDepo();
        mtbDepo.setCodMdep(codMdep);
        mtbDepo.setOperation(CommonModelConsts.OPERATION.SELECT);
        mtbDepo.setOnlyPkMaster(false);

        EntityRESTConsumer.selectEntity(mtbDepo, new ISimpleOperationCallback<List<MtbDepo>>() {
            @Override
            public void onSuccess(List<MtbDepo> value) {
                if(value != null && value.size() > 0) {
                    onComplete.run(value.get(0));
                }
            }

            @Override
            public void onFailed(Exception ex) {
                UtilityLogger.errorMe(ex);
            }
        }, MtbDepo.class);
    }

}
