openaire-library/utils/indexInfo.service.ts

32 lines
1.2 KiB
TypeScript

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<any> {
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<any> {
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<any> {
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)}));
}
}