// api routes import { CYCLES_ENDPOINT, CYCLE_DETAIL } from "constants/api-routes"; // services import APIService from "lib/services/api.service"; // types import type { ICycle } from "types"; const { NEXT_PUBLIC_API_BASE_URL } = process.env; class ProjectCycleServices extends APIService { constructor() { super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); } async createCycle(workspaceSlug: string, projectId: string, data: any): Promise { return this.post(CYCLES_ENDPOINT(workspaceSlug, projectId), data) .then((response) => { return response?.data; }) .catch((error) => { throw error?.response?.data; }); } async getCycles(workspaceSlug: string, projectId: string): Promise { return this.get(CYCLES_ENDPOINT(workspaceSlug, projectId)) .then((response) => { return response?.data; }) .catch((error) => { throw error?.response?.data; }); } async getCycleIssues(workspaceSlug: string, projectId: string, cycleId: string): Promise { return this.get(CYCLE_DETAIL(workspaceSlug, projectId, cycleId)) .then((response) => { return response?.data; }) .catch((error) => { throw error?.response?.data; }); } async updateCycle( workspaceSlug: string, projectId: string, cycleId: string, data: any ): Promise { return this.put( CYCLE_DETAIL(workspaceSlug, projectId, cycleId).replace("cycle-issues/", ""), data ) .then((response) => { return response?.data; }) .catch((error) => { throw error?.response?.data; }); } async patchCycle( workspaceSlug: string, projectId: string, cycleId: string, data: any ): Promise { return this.patch( CYCLE_DETAIL(workspaceSlug, projectId, cycleId).replace("cycle-issues/", ""), data ) .then((response) => { return response?.data; }) .catch((error) => { throw error?.response?.data; }); } async deleteCycle(workspaceSlug: string, projectId: string, cycleId: string): Promise { return this.delete(CYCLE_DETAIL(workspaceSlug, projectId, cycleId).replace("cycle-issues/", "")) .then((response) => { return response?.data; }) .catch((error) => { throw error?.response?.data; }); } } export default new ProjectCycleServices();