import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {EnvProperties} from './properties/env-properties'; import {Observable, of} from "rxjs"; import {catchError, map} from "rxjs/operators"; @Injectable({ providedIn: "root" }) export class IndexInfoService { constructor(private http: HttpClient) { } getLastIndexDate(properties: EnvProperties): Observable { let url = properties.indexInfoAPI; return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['claim_load_date'])).pipe(catchError(err => {return of(null)})); } getStatsLastDate(properties: EnvProperties): Observable { let url = properties.indexInfoAPI; return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['stats_update_date'])).pipe(catchError(err => {return of(null)})); } getLastOrcidUpdateDate(properties: EnvProperties): Observable { let url = properties.indexInfoAPI; return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['orcid_update_date'])).pipe(catchError(err => {return of(null)})); } }