import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { BootstrapConfig } from '../../../shared/models/config';
import { ConfigProvider } from '../../config/config-provider.interface';
import { ApiConfigService } from '../../config/api-config.service';

@Injectable({ providedIn: 'root' })
export class ApiBootstrapProvider implements ConfigProvider {
  constructor(
    private readonly http: HttpClient,
    private readonly apiConfig: ApiConfigService
  ) {}

  loadBootstrap(): Observable<BootstrapConfig> {
    return this.http.get<BootstrapConfig>(`${this.apiConfig.getBaseUrl()}/bootstrap`);
  }
}
