2023-08-11 11:48:33 +00:00
|
|
|
// services
|
|
|
|
import APIService from "services/api.service";
|
2023-12-06 11:12:57 +00:00
|
|
|
// helpers
|
2023-09-13 14:51:02 +00:00
|
|
|
import { API_BASE_URL } from "helpers/common.helper";
|
2023-12-06 11:12:57 +00:00
|
|
|
// types
|
|
|
|
import { IUser } from "types/user";
|
2023-08-11 11:48:33 +00:00
|
|
|
|
2023-12-06 11:12:57 +00:00
|
|
|
export class UserService extends APIService {
|
2023-08-11 11:48:33 +00:00
|
|
|
constructor() {
|
2023-09-13 14:51:02 +00:00
|
|
|
super(API_BASE_URL);
|
2023-08-11 11:48:33 +00:00
|
|
|
}
|
|
|
|
|
2023-12-06 11:12:57 +00:00
|
|
|
async currentUser(): Promise<IUser> {
|
2023-08-11 11:48:33 +00:00
|
|
|
return this.get("/api/users/me/")
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
2023-09-01 11:12:30 +00:00
|
|
|
|
|
|
|
async updateMe(data: any): Promise<any> {
|
|
|
|
return this.patch("/api/users/me/", data)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
2023-08-11 11:48:33 +00:00
|
|
|
}
|