// plane internal packages import { API_BASE_URL } from "@plane/constants"; import type { IWorkspace, TWorkspacePaginationInfo } from "@plane/types"; // services import { APIService } from "@/services/api.service"; export class WorkspaceService extends APIService { constructor() { super(API_BASE_URL); } /** * @description Fetches all workspaces * @returns Promise */ async getWorkspaces(nextPageCursor?: string): Promise { return this.get("/api/instances/workspaces/", { cursor: nextPageCursor, }) .then((response) => response.data) .catch((error) => { throw error?.response?.data; }); } /** * @description Checks if a slug is available * @param slug - string * @returns Promise */ async workspaceSlugCheck(slug: string): Promise { const params = new URLSearchParams({ slug }); return this.get(`/api/instances/workspace-slug-check/?${params.toString()}`) .then((response) => response?.data) .catch((error) => { throw error?.response?.data; }); } /** * @description Creates a new workspace * @param data - IWorkspace * @returns Promise */ async createWorkspace(data: IWorkspace): Promise { return this.post("/api/instances/workspaces/", data) .then((response) => response.data) .catch((error) => { throw error?.response?.data; }); } }