You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
|
import { Injectable } from '@angular/core';
|
|
import { environment } from '../../../environment';
|
|
import { AuthService } from '../auth/auth.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class FriendsService {
|
|
private apiURL = environment.apiURL;
|
|
constructor(private http: HttpClient, private authService: AuthService) {}
|
|
|
|
getFriend() {
|
|
return this.http.get<any[]>(`${this.apiURL}/friends`);
|
|
}
|
|
|
|
getFriendById(id: string) {
|
|
return this.http.get<any>(`${this.apiURL}/user/${id}`);
|
|
}
|
|
|
|
addFriend(user_id: string) {
|
|
return this.http.post<any>(`${this.apiURL}/friend/add`, { friend_user_id: user_id });
|
|
}
|
|
|
|
acceptFriendById(id: string) {
|
|
return this.http.patch<any>(`${this.apiURL}/friend/${id}/accept`, []);
|
|
}
|
|
|
|
denyFriendById(id: string) {
|
|
return this.http.delete<any>(`${this.apiURL}/friend/${id}/deny`);
|
|
}
|
|
|
|
deleteFriend(id: string) {
|
|
return this.http.delete<any>(`${this.apiURL}/friend/${id}/delete`);
|
|
}
|
|
}
|