Project

General

Profile

1
import {Injectable} from '@angular/core';
2
import {HttpClient, HttpHeaders} from '@angular/common/http';
3
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
4

    
5
@Injectable()
6
export class  ManageZenodoCommunitiesService {
7
  constructor(private http: HttpClient ) {}
8

    
9
  removeZCommunity (properties: EnvProperties, pid: string,id: string):any {
10
    //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
11
    //let options = new RequestOptions({headers: headers, body: id});
12

    
13
    let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
14
    let url = properties.communityAPI + pid + "/zenodocommunities";
15

    
16
    //return this.http.delete(url, options);
17
    return this.http.request('delete', url, { body: id, headers: headers})
18
  }
19

    
20
  addZCommunity(properties:EnvProperties, pid: string,zenodoid: string) {
21
      //let headers = new Headers({'Content-Type': 'application/json'});
22
      //let options = new RequestOptions({headers: headers});
23

    
24
    let headers = new HttpHeaders({'Content-Type': 'application/json'});
25

    
26
      let url = properties.communityAPI+pid+"/zenodocommunities";
27
      var zCommunity: any = {
28
        "communityId": pid,
29

    
30
        "zenodoid": zenodoid
31
      };
32
      return this.http.post<any>(url, JSON.stringify(zCommunity), {headers: headers});
33
                      //.map(res => <any> res.json())
34
    }
35

    
36

    
37

    
38

    
39
}
(4-4/4)