Project

General

Profile

1 61381 k.triantaf
import {Injectable} from '@angular/core';
2
import {HttpClient} from '@angular/common/http';
3
import {EnvProperties} from './properties/env-properties';
4
import {Observable, of} from "rxjs";
5
import {catchError, map} from "rxjs/operators";
6
7
8
@Injectable({
9
  providedIn: "root"
10
})
11
export class IndexInfoService {
12
13
  constructor(private http: HttpClient) {
14
  }
15
16
  getLastIndexDate(properties: EnvProperties): Observable<any> {
17
    let url = properties.indexInfoAPI;
18
    return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['claim_load_date'])).pipe(catchError(err => {return of(null)}));
19
  }
20
  getStatsLastDate(properties: EnvProperties): Observable<any> {
21
    let url = properties.indexInfoAPI;
22
    return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['stats_update_date'])).pipe(catchError(err => {return of(null)}));
23
  }
24
  getLastOrcidUpdateDate(properties: EnvProperties): Observable<any> {
25
    let url = properties.indexInfoAPI;
26
    return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url).pipe(map(res => res['orcid_update_date'])).pipe(catchError(err => {return of(null)}));
27
  }
28
}
29
30