From 4a6995be18b15de1834a39c8921a0e4109671bb6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Jun 2016 22:08:03 +0200 Subject: First draft to use webpack instead of systemjs --- client/src/app/friends/friend.service.ts | 31 +++++++++++++++++++++++++++++++ client/src/app/friends/index.ts | 1 + 2 files changed, 32 insertions(+) create mode 100644 client/src/app/friends/friend.service.ts create mode 100644 client/src/app/friends/index.ts (limited to 'client/src/app/friends') diff --git a/client/src/app/friends/friend.service.ts b/client/src/app/friends/friend.service.ts new file mode 100644 index 000000000..a8b1a1bd3 --- /dev/null +++ b/client/src/app/friends/friend.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { Http, Response } from '@angular/http'; +import { Observable } from 'rxjs/Rx'; + +import { AuthService } from '../shared'; + +@Injectable() +export class FriendService { + private static BASE_FRIEND_URL: string = '/api/v1/pods/'; + + constructor (private http: Http, private authService: AuthService) {} + + makeFriends() { + const headers = this.authService.getRequestHeader(); + return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends', { headers }) + .map(res => res.status) + .catch(this.handleError); + } + + quitFriends() { + const headers = this.authService.getRequestHeader(); + return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends', { headers }) + .map(res => res.status) + .catch(this.handleError); + } + + private handleError (error: Response): Observable { + console.error(error); + return Observable.throw(error.json().error || 'Server error'); + } +} diff --git a/client/src/app/friends/index.ts b/client/src/app/friends/index.ts new file mode 100644 index 000000000..0adc256c4 --- /dev/null +++ b/client/src/app/friends/index.ts @@ -0,0 +1 @@ +export * from './friend.service'; -- cgit v1.2.3