[Trunk | Library]: affiliation.service: Add delete and update http requests.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56041 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-06-11 13:33:32 +00:00
parent d8552c8a08
commit 9b21fdf321
1 changed files with 8 additions and 15 deletions

View File

@ -1,9 +1,8 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {BehaviorSubject, Observable} from 'rxjs';
import {Affiliation} from '../../utils/entities/CuratorInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
@Injectable()
export class AffiliationService {
@ -24,20 +23,14 @@ export class AffiliationService {
return this.affiliationsSubject.asObservable();
}
// public updateAffiliations(affiliation: Affiliation) {
// const affiliations = this.affiliationsSubject.value;
// if (affiliations && affiliation) {
// affiliations.push(affiliation);
// this.affiliationsSubject.next(affiliations);
// }
// }
//
// public updateAffiliation(url: string, affiliation: Affiliation) {
// return this.http.post<Affiliation>(url, affiliation, CustomOptions.getAuthOptions());
// }
public updateAffiliation(url: string, affiliation: Affiliation) {
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept' : 'application/json'});
return this.http.post<Affiliation>(url, JSON.stringify(affiliation), {headers: headers});
}
public getAffiliation(properties: EnvProperties, url: string): Observable<Affiliation> {
return this.http.get<Affiliation>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
public deleteAffiliation(url: string, id: string) {
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept' : 'application/json'});
return this.http.request('delete', url, { body: id, headers: headers})
}
}