/**
 * Carrier Module
 *
 * Provides all carrier connector implementations
 */

import { Module } from '@nestjs/common';
import { MaerskConnector } from './maersk/maersk.connector';
import { MSCConnectorAdapter } from './msc/msc.connector';
import { MSCRequestMapper } from './msc/msc.mapper';
import { CMACGMConnectorAdapter } from './cma-cgm/cma-cgm.connector';
import { CMACGMRequestMapper } from './cma-cgm/cma-cgm.mapper';
import { HapagLloydConnectorAdapter } from './hapag-lloyd/hapag-lloyd.connector';
import { HapagLloydRequestMapper } from './hapag-lloyd/hapag-lloyd.mapper';
import { ONEConnectorAdapter } from './one/one.connector';
import { ONERequestMapper } from './one/one.mapper';

@Module({
  providers: [
    // Maersk
    MaerskConnector,

    // MSC
    MSCRequestMapper,
    MSCConnectorAdapter,

    // CMA CGM
    CMACGMRequestMapper,
    CMACGMConnectorAdapter,

    // Hapag-Lloyd
    HapagLloydRequestMapper,
    HapagLloydConnectorAdapter,

    // ONE
    ONERequestMapper,
    ONEConnectorAdapter,

    // Factory that provides all connectors
    {
      provide: 'CarrierConnectors',
      useFactory: (
        maerskConnector: MaerskConnector,
        mscConnector: MSCConnectorAdapter,
        cmacgmConnector: CMACGMConnectorAdapter,
        hapagConnector: HapagLloydConnectorAdapter,
        oneConnector: ONEConnectorAdapter
      ) => {
        return [maerskConnector, mscConnector, cmacgmConnector, hapagConnector, oneConnector];
      },
      inject: [
        MaerskConnector,
        MSCConnectorAdapter,
        CMACGMConnectorAdapter,
        HapagLloydConnectorAdapter,
        ONEConnectorAdapter,
      ],
    },
  ],
  exports: [
    'CarrierConnectors',
    MaerskConnector,
    MSCConnectorAdapter,
    CMACGMConnectorAdapter,
    HapagLloydConnectorAdapter,
    ONEConnectorAdapter,
  ],
})
export class CarrierModule {}
