package it.integry.integrywmsnative;

import android.app.Application;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import it.integry.integrywmsnative.core.context.AppContext;
import it.integry.integrywmsnative.core.context.MainContext;
import it.integry.integrywmsnative.core.data_recover.ColliDataRecoverService;
import it.integry.integrywmsnative.core.data_store.db.AppDatabase;
import it.integry.integrywmsnative.core.menu.MenuRESTConsumer;
import it.integry.integrywmsnative.core.menu.MenuService;
import it.integry.integrywmsnative.core.rest.consumers.ArticoloRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.BarcodeRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.ColliMagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.DepositoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.EntityRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.GestSetupRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MagazzinoRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.MesRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.OrdiniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PosizioniRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.PrinterRESTConsumer;
import it.integry.integrywmsnative.core.rest.consumers.SystemRESTConsumer;
import it.integry.integrywmsnative.gest.prod_fabbisogno_linee_prod.rest.ProdFabbisognoLineeProdRESTConsumer;

@Module
public class MainApplicationModule {

    private final Application mApplication;

    public MainApplicationModule(Application application) {
        this.mApplication = application;
    }

    @Provides
    @Singleton
    Application providesApplication() {
        return mApplication;
    }

    @Provides
    @Singleton
    AppContext providesAppContext() {
        return new AppContext(mApplication);
    }

    @Provides
    @Singleton
    MainContext providesMainContextNew(MenuService menuService, AppDatabase appDatabase) {
        return new MainContext(mApplication.getApplicationContext(), menuService, appDatabase);
    }

    @Provides
    @Singleton
    ColliDataRecoverService provideColliDataRecoverService() {
        ColliDataRecoverService colliDataRecoverService = new ColliDataRecoverService(mApplication.getApplicationContext());
        colliDataRecoverService.init();
        return colliDataRecoverService;
    }

    @Provides
    @Singleton
    MenuService provideMenuService(MenuRESTConsumer menuRESTConsumer) {
        return new MenuService(menuRESTConsumer);
    }

    @Provides
    @Singleton
    OrdiniRESTConsumer provideOrdiniRESTConsumer(SystemRESTConsumer systemRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
        return new OrdiniRESTConsumer(systemRESTConsumer, entityRESTConsumer);
    }

    @Provides
    @Singleton
    GestSetupRESTConsumer provideGestSetupRESTConsumer() {
        return new GestSetupRESTConsumer();
    }

    @Provides
    @Singleton
    ArticoloRESTConsumer provideArticoloRESTConsumer() {
        return new ArticoloRESTConsumer();
    }

    @Provides
    @Singleton
    DepositoRESTConsumer provideDepositoRESTConsumer(EntityRESTConsumer entityRESTConsumer) {
        return new DepositoRESTConsumer(entityRESTConsumer);
    }

    @Provides
    @Singleton
    MenuRESTConsumer provideMenuRESTConsumer() {
        return new MenuRESTConsumer();
    }

    @Provides
    @Singleton
    MagazzinoRESTConsumer provideMagazzinoRESTConsumer() {
        return new MagazzinoRESTConsumer();
    }

    @Provides
    @Singleton
    MesRESTConsumer provideMesRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
        return new MesRESTConsumer(systemRESTConsumer);
    }

    @Provides
    @Singleton
    EntityRESTConsumer provideEntityRESTConsumer() {
        return new EntityRESTConsumer();
    }

    @Provides
    @Singleton
    ColliMagazzinoRESTConsumer provideColliMagazzinoRESTConsumer(SystemRESTConsumer systemRESTConsumer, ArticoloRESTConsumer articoloRESTConsumer, EntityRESTConsumer entityRESTConsumer) {
        return new ColliMagazzinoRESTConsumer(systemRESTConsumer, articoloRESTConsumer, entityRESTConsumer);
    }

    @Provides
    @Singleton
    BarcodeRESTConsumer provideBarcodeRESTConsumer() {
        return new BarcodeRESTConsumer();
    }

    @Provides
    @Singleton
    PrinterRESTConsumer providePrinterRESTConsumer() {
        return new PrinterRESTConsumer();
    }

    @Provides
    @Singleton
    SystemRESTConsumer provideSystemRESTConsumer() {
        return new SystemRESTConsumer();
    }

    @Provides
    @Singleton
    PosizioniRESTConsumer providesPosizioniRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
        return new PosizioniRESTConsumer(systemRESTConsumer);
    }

    @Provides
    @Singleton
    ProdFabbisognoLineeProdRESTConsumer providesProdFabbisognoLineeProdRESTConsumer(SystemRESTConsumer systemRESTConsumer) {
        return new ProdFabbisognoLineeProdRESTConsumer(systemRESTConsumer);
    }


}
