Project

General

Profile

1
import {Injectable} from '@angular/core';
2
import {Http, Response, Headers, RequestOptions} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
5

    
6
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
7
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
8
import { catchError } from 'rxjs/operators';
9

    
10
@Injectable()
11
export class  ManageZenodoCommunitiesService {
12
  constructor(private http: Http ) {}
13

    
14
  removeZCommunity (properties: EnvProperties, communityId: string,id: string):any {
15
    let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
16
    let options = new RequestOptions({headers: headers, body: id});
17

    
18
    let url = properties.communityAPI + communityId + "/zenodocommunities";
19

    
20
    return this.http.delete(url, options);
21
  }
22

    
23
  addZCommunity(properties:EnvProperties, communityId: string,zenodoid: string) {
24
      let headers = new Headers({'Content-Type': 'application/json'});
25
      let options = new RequestOptions({headers: headers});
26

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

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

    
37

    
38

    
39

    
40
}
(5-5/5)