From 9b21fdf32141ed876f7e09a94dc69489bc3e07cc Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 11 Jun 2019 13:33:32 +0000 Subject: [PATCH] [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 --- connect/affiliations/affiliation.service.ts | 23 +++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/connect/affiliations/affiliation.service.ts b/connect/affiliations/affiliation.service.ts index 3ff9eab0..751cd7fc 100644 --- a/connect/affiliations/affiliation.service.ts +++ b/connect/affiliations/affiliation.service.ts @@ -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(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(url, JSON.stringify(affiliation), {headers: headers}); + } - public getAffiliation(properties: EnvProperties, url: string): Observable { - return this.http.get((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}) } }