]>
Commit | Line | Data |
---|---|---|
230809ef C |
1 | import { Injectable } from '@angular/core'; |
2 | import { Http, Response } from '@angular/http'; | |
44124980 | 3 | import { Observable } from 'rxjs/Rx'; |
dc8bc31b | 4 | |
4a6995be | 5 | import { AuthService } from '../shared'; |
a840d396 | 6 | |
dc8bc31b | 7 | @Injectable() |
41a2aee3 | 8 | export class FriendService { |
ccf6ed16 | 9 | private static BASE_FRIEND_URL: string = '/api/v1/pods/'; |
dc8bc31b | 10 | |
a840d396 | 11 | constructor (private http: Http, private authService: AuthService) {} |
dc8bc31b C |
12 | |
13 | makeFriends() { | |
a840d396 C |
14 | const headers = this.authService.getRequestHeader(); |
15 | return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends', { headers }) | |
ccf6ed16 | 16 | .map(res => res.status) |
dc8bc31b C |
17 | .catch(this.handleError); |
18 | } | |
19 | ||
20 | quitFriends() { | |
a840d396 C |
21 | const headers = this.authService.getRequestHeader(); |
22 | return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends', { headers }) | |
ccf6ed16 | 23 | .map(res => res.status) |
dc8bc31b C |
24 | .catch(this.handleError); |
25 | } | |
26 | ||
ccf6ed16 | 27 | private handleError (error: Response): Observable<number> { |
dc8bc31b C |
28 | console.error(error); |
29 | return Observable.throw(error.json().error || 'Server error'); | |
30 | } | |
31 | } |