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

import { ExternalApiService } from './services/external-api.service';

import { _MODULE_CONFIG } from './config/token';
import { ModuleConfig } from './config/module-config';

const SERVICES = [ExternalApiService];

@NgModule({
  declarations: [],
  imports: [],
  exports: [],
})
export class UCapExternalApiModule {
  public static forRoot(
    config: ModuleConfig
  ): ModuleWithProviders<UCapExternalApiModule> {
    return {
      ngModule: UCapExternalApiModule,
      providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES],
    };
  }
}
