1 import { Injectable } from '@angular/core';
2 import { Observable } from 'rxjs/Observable';
4 import { Friend } from './friend.model';
5 import { AuthHttp, RestExtractor } from '../../../shared';
8 export class FriendService {
9 private static BASE_FRIEND_URL: string = '/api/v1/pods/';
12 private authHttp: AuthHttp,
13 private restExtractor: RestExtractor
16 getFriends(): Observable<Friend[]> {
17 return this.authHttp.get(FriendService.BASE_FRIEND_URL)
18 // Not implemented as a data list by the server yet
19 // .map(this.restExtractor.extractDataList)
20 .map((res) => res.json())
21 .catch((res) => this.restExtractor.handleError(res));
24 makeFriends(notEmptyUrls) {
29 return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body)
30 .map(this.restExtractor.extractDataBool)
31 .catch((res) => this.restExtractor.handleError(res));
35 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
36 .map(res => res.status)
37 .catch((res) => this.restExtractor.handleError(res));