import { HttpHeaders } from "@angular/common/http";

import { ConfigurationHelper } from "./configuration-helper";
import { ServiceCacheApi } from "./service-cache-api.service";

export class BaseService {
  protected headers: HttpHeaders;
  protected apiUrl: string;
  protected serviceCacheApi: ServiceCacheApi;

  constructor() {
    ConfigurationHelper.settings.subscribe((settings) => {
      if (settings != null) {
        let tmpApiUrl: string = settings.apiUrl;

        this.headers = new HttpHeaders({
          "Access-Control-Allow-Origin": tmpApiUrl,
        });
        this.apiUrl = tmpApiUrl + "/api";
      }
    });

    this.serviceCacheApi = new ServiceCacheApi();
  }
}
