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

import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

import javax.inject.Singleton;

import it.integry.integrywmsnative.core.expansion.RunnableArgs;
import it.integry.integrywmsnative.core.model.MtbDepo;

@Singleton
public class DepositoRESTConsumer extends _BaseRESTConsumer {

    private final EntityRESTConsumer entityRESTConsumer;
    private final SystemRESTConsumer systemRESTConsumer;

    public DepositoRESTConsumer(EntityRESTConsumer entityRESTConsumer, SystemRESTConsumer systemRESTConsumer) {
        this.entityRESTConsumer = entityRESTConsumer;
        this.systemRESTConsumer = systemRESTConsumer;
    }

    public void getAll(RunnableArgs<List<MtbDepo>> onComplete, RunnableArgs<Exception> onFailed) {
        Type typeOfObjectsList = new TypeToken<ArrayList<MtbDepo>>() {
        }.getType();
        this.systemRESTConsumer.processSql("SELECT * FROM mtb_depo", typeOfObjectsList, onComplete, onFailed);
    }
}
