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

import { ConfigurationHelper } from './configuration-helper';
import { ServiceRefData } from './service-ref-data.service';

export class BaseService {
    protected headers: HttpHeaders;
    protected apiUrl: string;
    protected serviceRefData : ServiceRefData;

    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.serviceRefData = new ServiceRefData();
    }
}
