import {Injectable} from '@angular/core'; import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {Observable} from 'rxjs/Observable'; import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { ErrorObservable } from 'rxjs/observable/ErrorObservable'; import { catchError } from 'rxjs/operators'; @Injectable() export class ManageZenodoCommunitiesService { constructor(private http: Http ) {} removeZCommunity (properties: EnvProperties, communityId: string,id: string):any { let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); let options = new RequestOptions({headers: headers, body: id}); let url = properties.communityAPI + communityId + "/zenodocommunities"; return this.http.delete(url, options); } addZCommunity(properties:EnvProperties, communityId: string,zenodoid: string) { let headers = new Headers({'Content-Type': 'application/json'}); let options = new RequestOptions({headers: headers}); let url = properties.communityAPI+communityId+"/zenodocommunities"; var zCommunity: any = { "communityId": communityId, "zenodoid": zenodoid }; return this.http.post(url, JSON.stringify(zCommunity), options) .map(res => res.json()) } }