2022-11-19 14:21:26 +00:00
|
|
|
// api routes
|
|
|
|
import { CYCLES_ENDPOINT, CYCLE_DETAIL } from "constants/api-routes";
|
|
|
|
// services
|
|
|
|
import APIService from "lib/services/api.service";
|
|
|
|
|
|
|
|
const { NEXT_PUBLIC_API_BASE_URL } = process.env;
|
|
|
|
|
|
|
|
class ProjectCycleServices extends APIService {
|
|
|
|
constructor() {
|
|
|
|
super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000");
|
|
|
|
}
|
|
|
|
|
2022-12-06 14:38:28 +00:00
|
|
|
async createCycle(workspaceSlug: string, projectId: string, data: any): Promise<any> {
|
|
|
|
return this.post(CYCLES_ENDPOINT(workspaceSlug, projectId), data)
|
2022-11-19 14:21:26 +00:00
|
|
|
.then((response) => {
|
|
|
|
return response?.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-06 14:38:28 +00:00
|
|
|
async getCycles(workspaceSlug: string, projectId: string): Promise<any> {
|
|
|
|
return this.get(CYCLES_ENDPOINT(workspaceSlug, projectId))
|
2022-11-19 14:21:26 +00:00
|
|
|
.then((response) => {
|
|
|
|
return response?.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-06 14:38:28 +00:00
|
|
|
async getCycleIssues(workspaceSlug: string, projectId: string, cycleId: string): Promise<any> {
|
|
|
|
return this.get(CYCLE_DETAIL(workspaceSlug, projectId, cycleId))
|
2022-11-19 14:21:26 +00:00
|
|
|
.then((response) => {
|
|
|
|
return response?.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async updateCycle(
|
2022-12-06 14:38:28 +00:00
|
|
|
workspaceSlug: string,
|
2022-11-19 14:21:26 +00:00
|
|
|
projectId: string,
|
|
|
|
cycleId: string,
|
|
|
|
data: any
|
|
|
|
): Promise<any> {
|
|
|
|
return this.put(
|
2022-12-06 14:38:28 +00:00
|
|
|
CYCLE_DETAIL(workspaceSlug, projectId, cycleId).replace("cycle-issues/", ""),
|
2022-11-19 14:21:26 +00:00
|
|
|
data
|
|
|
|
)
|
|
|
|
.then((response) => {
|
|
|
|
return response?.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-12-06 14:38:28 +00:00
|
|
|
async deleteCycle(workspaceSlug: string, projectId: string, cycleId: string): Promise<any> {
|
|
|
|
return this.delete(CYCLE_DETAIL(workspaceSlug, projectId, cycleId).replace("cycle-issues/", ""))
|
2022-11-19 14:21:26 +00:00
|
|
|
.then((response) => {
|
|
|
|
return response?.data;
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default new ProjectCycleServices();
|