diff options
Diffstat (limited to 'client/src/app/admin/friends/shared')
-rw-r--r-- | client/src/app/admin/friends/shared/friend.model.ts | 6 | ||||
-rw-r--r-- | client/src/app/admin/friends/shared/friend.service.ts | 39 | ||||
-rw-r--r-- | client/src/app/admin/friends/shared/index.ts | 2 |
3 files changed, 47 insertions, 0 deletions
diff --git a/client/src/app/admin/friends/shared/friend.model.ts b/client/src/app/admin/friends/shared/friend.model.ts new file mode 100644 index 000000000..7cb28f440 --- /dev/null +++ b/client/src/app/admin/friends/shared/friend.model.ts | |||
@@ -0,0 +1,6 @@ | |||
1 | export interface Friend { | ||
2 | id: string; | ||
3 | url: string; | ||
4 | score: number; | ||
5 | createdDate: Date; | ||
6 | } | ||
diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/admin/friends/shared/friend.service.ts new file mode 100644 index 000000000..75826fc17 --- /dev/null +++ b/client/src/app/admin/friends/shared/friend.service.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { Injectable } from '@angular/core'; | ||
2 | import { Observable } from 'rxjs/Observable'; | ||
3 | |||
4 | import { Friend } from './friend.model'; | ||
5 | import { AuthHttp, RestExtractor } from '../../../shared'; | ||
6 | |||
7 | @Injectable() | ||
8 | export class FriendService { | ||
9 | private static BASE_FRIEND_URL: string = '/api/v1/pods/'; | ||
10 | |||
11 | constructor ( | ||
12 | private authHttp: AuthHttp, | ||
13 | private restExtractor: RestExtractor | ||
14 | ) {} | ||
15 | |||
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)); | ||
22 | } | ||
23 | |||
24 | makeFriends(notEmptyUrls) { | ||
25 | const body = { | ||
26 | urls: notEmptyUrls | ||
27 | }; | ||
28 | |||
29 | return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body) | ||
30 | .map(this.restExtractor.extractDataBool) | ||
31 | .catch((res) => this.restExtractor.handleError(res)); | ||
32 | } | ||
33 | |||
34 | quitFriends() { | ||
35 | return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends') | ||
36 | .map(res => res.status) | ||
37 | .catch((res) => this.restExtractor.handleError(res)); | ||
38 | } | ||
39 | } | ||
diff --git a/client/src/app/admin/friends/shared/index.ts b/client/src/app/admin/friends/shared/index.ts new file mode 100644 index 000000000..0d671637d --- /dev/null +++ b/client/src/app/admin/friends/shared/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './friend.model'; | ||
2 | export * from './friend.service'; | ||