aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/friends/friend.service.ts
blob: 7710464846633a0448d7586594b49c0c54062c7e (plain) (tree)
1
2
3
4
5
6
7
8
9
                                           
                                         
                                             
 
                                                  
 
             
                            
                                                           
 
                                                                               

                 
                                                                           
                                           



                                             
                                                                           
                                           


                                             
                                                             



                                                                  
import { Injectable } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';

import { AuthHttp, AuthService } from '../shared';

@Injectable()
export class FriendService {
  private static BASE_FRIEND_URL: string = '/api/v1/pods/';

  constructor (private authHttp: AuthHttp, private authService: AuthService) {}

  makeFriends() {
    return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'makefriends')
                    .map(res => res.status)
                    .catch(this.handleError);
  }

  quitFriends() {
    return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
                    .map(res => res.status)
                    .catch(this.handleError);
  }

  private handleError (error: Response): Observable<number> {
    console.error(error);
    return Observable.throw(error.json().error || 'Server error');
  }
}