// types import type { IWorkspace, TWorkspacePaginationInfo } from "@plane/types"; // helpers import { API_BASE_URL } from "@/helpers/common.helper"; // 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 { return this.get(`/api/instances/workspace-slug-check/?slug=${slug}`) .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; }); } }