import { NgModule, ModuleWithProviders, SkipSelf, Optional } from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';

import { ActivityLogsService } from './api/activityLogs.service';
import { AffiliatesService } from './api/affiliates.service';
import { AnalyticsService } from './api/analytics.service';
import { AnnouncementsService } from './api/announcements.service';
import { AppropriatenessQuestionnaireService } from './api/appropriatenessQuestionnaire.service';
import { AssetConverterService } from './api/assetConverter.service';
import { AssetManagerService } from './api/assetManager.service';
import { BusinessesService } from './api/businesses.service';
import { CryptoAddressesWatchlistService } from './api/cryptoAddressesWatchlist.service';
import { DevSpaceService } from './api/devSpace.service';
import { DynamicPoliciesService } from './api/dynamicPolicies.service';
import { FileManagerCDNService } from './api/fileManagerCDN.service';
import { FintracService } from './api/fintrac.service';
import { FireblocksService } from './api/fireblocks.service';
import { InternalReportsService } from './api/internalReports.service';
import { IrocService } from './api/iroc.service';
import { LogsService } from './api/logs.service';
import { LossNotificationsService } from './api/lossNotifications.service';
import { MFAResetService } from './api/mFAReset.service';
import { MigrationsService } from './api/migrations.service';
import { MissingDepositsService } from './api/missingDeposits.service';
import { PhoneBlacklistService } from './api/phoneBlacklist.service';
import { PoliciesService } from './api/policies.service';
import { PromoCodesService } from './api/promoCodes.service';
import { ReconciliationService } from './api/reconciliation.service';
import { RecurringPurchasesService } from './api/recurringPurchases.service';
import { RegulationReportsService } from './api/regulationReports.service';
import { ReportsService } from './api/reports.service';
import { StakingService } from './api/staking.service';
import { SupportCenterService } from './api/supportCenter.service';
import { TransfersService } from './api/transfers.service';
import { TrustedContactsService } from './api/trustedContacts.service';
import { UserManagerService } from './api/userManager.service';
import { WebhooksService } from './api/webhooks.service';

@NgModule({
  imports:      [],
  declarations: [],
  exports:      [],
  providers: []
})
export class ApiModule {
    public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> {
        return {
            ngModule: ApiModule,
            providers: [ { provide: Configuration, useFactory: configurationFactory } ]
        };
    }

    constructor( @Optional() @SkipSelf() parentModule: ApiModule,
                 @Optional() http: HttpClient) {
        if (parentModule) {
            throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
        }
        if (!http) {
            throw new Error('You need to import the HttpClientModule in your AppModule! \n' +
            'See also https://github.com/angular/angular/issues/20575');
        }
    }
}
