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