openaire-library/connect/curators/curator.service.ts

27 lines
978 B
TypeScript

import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {Curator} from '../../utils/entities/CuratorInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
@Injectable()
export class CuratorService {
constructor(private http: HttpClient) {
}
public getCurators(properties: EnvProperties, url: string): Observable<Curator[]> {
return this.http.get<Curator[]>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}
public updateCurator(url: string, curator: Curator) {
return this.http.post<Curator>(url, curator, CustomOptions.getAuthOptions());
}
public getCurator(properties: EnvProperties, url: string): Observable<Curator> {
return this.http.get<Curator>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}
}