import { NgModule } from '@angular/core';

import { PrintConfiguration } from '@swagger/print';
import { OmsConfiguration } from '@swagger/oms';
import { IsaConfiguration } from '@swagger/isa';
import { CrmConfiguration } from '@swagger/crm';
import { CheckoutConfiguration } from '@swagger/checkout';
import { AvConfiguration } from '@swagger/availability';
import { CatConfiguration } from '@swagger/cat';
import { EisConfiguration } from '@swagger/eis';

import { AppConfiguration } from './app-configuration';

export function catConfigurationFactory(config: AppConfiguration) {
  return config.swagger.api;
}

export function avConfigurationFactory(config: AppConfiguration) {
  return config.swagger.av;
}

export function checkoutConfigurationFactory(config: AppConfiguration) {
  return config.swagger.checkout;
}

export function crmConfigurationFactory(config: AppConfiguration) {
  return config.swagger.crm;
}

export function isaConfigurationFactory(config: AppConfiguration) {
  return config.swagger.isa;
}

export function omsConfigurationFactory(config: AppConfiguration) {
  return config.swagger.oms;
}

export function printConfigurationFactory(config: AppConfiguration) {
  return config.swagger.print;
}

export function eisConfigurationFactory(config: AppConfiguration) {
  return config.swagger.eis;
}

@NgModule({
  providers: [
    { provide: CatConfiguration, useFactory: catConfigurationFactory, deps: [AppConfiguration] },
    { provide: AvConfiguration, useFactory: avConfigurationFactory, deps: [AppConfiguration] },
    { provide: CheckoutConfiguration, useFactory: checkoutConfigurationFactory, deps: [AppConfiguration] },
    { provide: CrmConfiguration, useFactory: crmConfigurationFactory, deps: [AppConfiguration] },
    { provide: IsaConfiguration, useFactory: isaConfigurationFactory, deps: [AppConfiguration] },
    { provide: OmsConfiguration, useFactory: omsConfigurationFactory, deps: [AppConfiguration] },
    { provide: PrintConfiguration, useFactory: printConfigurationFactory, deps: [AppConfiguration] },
    { provide: EisConfiguration, useFactory: eisConfigurationFactory, deps: [AppConfiguration] },
  ],
})
export class AppSwaggerModule {}
