import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { ConfigService } from 'src/app/service/config.service';

interface VersionConf {
  version: string;
}

@Injectable({
  providedIn: 'root',
})
export class VersionService {
  constructor(
    private http: HttpClient,
    private config: ConfigService
  ) {}

  getApiVersion(): Observable<string> {
    return this.http.get<string>(`${this.config.settings.api.url}/version`);
  }

  getWebVersion(): Observable<VersionConf> {
    return this.http.get<VersionConf>(`/assets/version.json`);
  }
}
