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

import { MessageApiService } from './services/message-api.service';

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

const SERVICES = [MessageApiService];

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