import { NgModule, ModuleWithProviders } from '@angular/core';
import { _MODULE_CONFIG } from './types/token';

import { ExternalApiService } from './services/external-api.service';
import { ModuleConfig } from './types/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]
    };
  }
}
