40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import {Injectable} from '@angular/core';
|
|
import {HttpClient, HttpHeaders} from '@angular/common/http';
|
|
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
|
|
|
@Injectable()
|
|
export class ManageZenodoCommunitiesService {
|
|
constructor(private http: HttpClient ) {}
|
|
|
|
removeZCommunity (properties: EnvProperties, pid: string,id: string):any {
|
|
//let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
|
|
//let options = new RequestOptions({headers: headers, body: id});
|
|
|
|
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
|
|
let url = properties.communityAPI + pid + "/zenodocommunities";
|
|
|
|
//return this.http.delete(url, options);
|
|
return this.http.request('delete', url, { body: id, headers: headers})
|
|
}
|
|
|
|
addZCommunity(properties:EnvProperties, pid: string,zenodoid: string) {
|
|
//let headers = new Headers({'Content-Type': 'application/json'});
|
|
//let options = new RequestOptions({headers: headers});
|
|
|
|
let headers = new HttpHeaders({'Content-Type': 'application/json'});
|
|
|
|
let url = properties.communityAPI+pid+"/zenodocommunities";
|
|
var zCommunity: any = {
|
|
"communityId": pid,
|
|
|
|
"zenodoid": zenodoid
|
|
};
|
|
return this.http.post<any>(url, JSON.stringify(zCommunity), {headers: headers});
|
|
//.map(res => <any> res.json())
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|