package com.airlock.iam.transactionapproval.infrastructure.factory;

import com.airlock.iam.base.domain.model.event.EventCreationData;
import com.airlock.iam.base.infrastructure.event.factory.EventCreationDataFactory;
import com.airlock.iam.base.infrastructure.event.factory.EventCreationDataFactoryImpl;
import com.airlock.iam.common.domain.model.event.UserEventFactory;
import com.airlock.iam.common.infrastructure.event.OutboxEventPublisher;
import com.airlock.iam.common.infrastructure.event.UserEventFactoryImpl;
import com.airlock.iam.factor.domain.model.airlock2fa.event.Airlock2FADeviceEventFactory;
import com.airlock.iam.factor.infrastructure.event.Airlock2FADeviceEventFactoryImpl;
import com.google.inject.Exposed;
import com.google.inject.PrivateModule;
import com.google.inject.Provides;
import com.google.inject.TypeLiteral;
import java.util.Optional;

public final class TransactionApprovalDomainEventsModule extends PrivateModule {
   @Provides
   @Exposed
   EventCreationData provideEventCreationData(EventCreationDataFactory factory) {
      return factory.newEventCreationData();
   }

   protected void configure() {
      this.bind(EventCreationDataFactory.class).to(EventCreationDataFactoryImpl.class);
      this.bind(UserEventFactory.class).to(UserEventFactoryImpl.class);
      this.expose(UserEventFactory.class);
      this.bind(Airlock2FADeviceEventFactory.class).to(Airlock2FADeviceEventFactoryImpl.class);
      this.expose(Airlock2FADeviceEventFactory.class);
      this.bind(new TypeLiteral<Optional<OutboxEventPublisher>>() {}).toInstance(Optional.empty());
      this.expose(new TypeLiteral<Optional<OutboxEventPublisher>>() {});
   }
}
