plane/space/services/user.service.ts

44 lines
1.1 KiB
TypeScript

// types
import { IUser, TUserProfile } from "@plane/types";
// helpers
import { API_BASE_URL } from "@/helpers/common.helper";
// services
import APIService from "@/services/api.service";
export class UserService extends APIService {
constructor() {
super(API_BASE_URL);
}
async currentUser(): Promise<IUser> {
return this.get("/api/users/me/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
});
}
async updateUser(data: Partial<IUser>): Promise<IUser> {
return this.patch("/api/users/me/", data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getCurrentUserProfile(): Promise<TUserProfile> {
return this.get("/api/users/me/profile/")
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
});
}
async updateCurrentUserProfile(data: Partial<TUserProfile>): Promise<TUserProfile> {
return this.patch("/api/users/me/profile/", data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response;
});
}
}