aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/services/users.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/services/users.service.ts')
-rw-r--r--ufund-ui/src/app/services/users.service.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/ufund-ui/src/app/services/users.service.ts b/ufund-ui/src/app/services/users.service.ts
new file mode 100644
index 0000000..65a9e61
--- /dev/null
+++ b/ufund-ui/src/app/services/users.service.ts
@@ -0,0 +1,35 @@
+import { Injectable } from '@angular/core';
+import {HttpClient, HttpHeaders} from '@angular/common/http';
+import {Observable} from 'rxjs';
+import {User} from '../models/User';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class UsersService {
+
+ private url = "localhost:8080/cupboard"
+ private httpOptions = {
+ headers: new HttpHeaders({'Content-Type': 'application/json'})
+ };
+
+ constructor(
+ private http: HttpClient
+ ) {}
+
+ createUser(data: User): Observable<User> {
+ return this.http.post<User>(this.url, data, this.httpOptions)
+ }
+
+ getUser(id: number): Observable<User> {
+ return this.http.get<User>(`${this.url}/${id}`, this.httpOptions)
+ }
+
+ updateUser(id: number): Observable<User> {
+ return this.http.put<User>(`${this.url}/${id}`, this.httpOptions)
+ }
+
+ deleteUser(id: number): Observable<boolean> {
+ return this.http.delete<boolean>(`${this.url}/${id}`, this.httpOptions)
+ }
+}