import {Injectable} from '@angular/core'; import {Http, Response} from '@angular/http'; import {Headers, RequestOptions} from '@angular/http'; import {HttpClient} from "@angular/common/http"; import {Observable} from 'rxjs'; import {ZenodoCommunityInfo} from './zenodoCommunityInfo'; import {EnvProperties} from '../../utils/properties/env-properties'; import {map} from "rxjs/operators"; @Injectable() export class ZenodoCommunitiesService { constructor(private http:HttpClient) { } getZenodoCommunities(properties:EnvProperties, url: string) { return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url) //.map(res => res.json()) .pipe(map(res => [this.parseZenodoCommunities(res['hits'].hits),res['hits'].total])); } getZenodoCommunityById(properties:EnvProperties, url: string, openaireId:string) { return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url) //.map(res => res.json()) .pipe(map(res => { var community = this.parseZenodoCommunity(res); community["openaireId"]=openaireId; return community; })); } parseZenodoCommunities(data: any): ZenodoCommunityInfo[] { let zenodoCommunities: ZenodoCommunityInfo[] = []; for (let i=0; i res.json()) .pipe(map(res => res['hits'].total)); } }