2024-05-14 08:56:54 +00:00
|
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
2023-08-11 11:48:33 +00:00
|
|
|
// services
|
2024-05-14 16:39:29 +00:00
|
|
|
import { APIService } from "@/services/api.service";
|
2023-08-11 11:48:33 +00:00
|
|
|
|
|
|
|
class IssueService extends APIService {
|
|
|
|
constructor() {
|
2023-09-13 14:51:02 +00:00
|
|
|
super(API_BASE_URL);
|
2023-08-11 11:48:33 +00:00
|
|
|
}
|
|
|
|
|
2023-09-01 11:12:30 +00:00
|
|
|
async getPublicIssues(workspace_slug: string, project_slug: string, params: any): Promise<any> {
|
|
|
|
return this.get(`/api/public/workspaces/${workspace_slug}/project-boards/${project_slug}/issues/`, {
|
|
|
|
params,
|
|
|
|
})
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async getIssueById(workspaceSlug: string, projectId: string, issueId: string): Promise<any> {
|
|
|
|
return this.get(`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async getIssueVotes(workspaceSlug: string, projectId: string, issueId: string): Promise<any> {
|
|
|
|
return this.get(`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/votes/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async createIssueVote(workspaceSlug: string, projectId: string, issueId: string, data: any): Promise<any> {
|
|
|
|
return this.post(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/votes/`,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteIssueVote(workspaceSlug: string, projectId: string, issueId: string): Promise<any> {
|
|
|
|
return this.delete(`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/votes/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async getIssueReactions(workspaceSlug: string, projectId: string, issueId: string): Promise<any> {
|
|
|
|
return this.get(`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/reactions/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async createIssueReaction(workspaceSlug: string, projectId: string, issueId: string, data: any): Promise<any> {
|
|
|
|
return this.post(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/reactions/`,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteIssueReaction(
|
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
|
|
|
issueId: string,
|
|
|
|
reactionId: string
|
|
|
|
): Promise<any> {
|
|
|
|
return this.delete(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/reactions/${reactionId}/`
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async getIssueComments(workspaceSlug: string, projectId: string, issueId: string): Promise<any> {
|
|
|
|
return this.get(`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/comments/`)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async createIssueComment(workspaceSlug: string, projectId: string, issueId: string, data: any): Promise<any> {
|
|
|
|
return this.post(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/comments/`,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async updateIssueComment(
|
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
|
|
|
issueId: string,
|
|
|
|
commentId: string,
|
|
|
|
data: any
|
|
|
|
): Promise<any> {
|
|
|
|
return this.patch(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/comments/${commentId}/`,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteIssueComment(workspaceSlug: string, projectId: string, issueId: string, commentId: string): Promise<any> {
|
|
|
|
return this.delete(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/issues/${issueId}/comments/${commentId}/`
|
|
|
|
)
|
2023-08-11 11:48:33 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
2023-09-06 06:29:57 +00:00
|
|
|
|
|
|
|
async createCommentReaction(
|
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
|
|
|
commentId: string,
|
|
|
|
data: {
|
|
|
|
reaction: string;
|
|
|
|
}
|
|
|
|
): Promise<any> {
|
|
|
|
return this.post(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/comments/${commentId}/reactions/`,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async deleteCommentReaction(
|
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
|
|
|
commentId: string,
|
|
|
|
reactionHex: string
|
|
|
|
): Promise<any> {
|
|
|
|
return this.delete(
|
|
|
|
`/api/public/workspaces/${workspaceSlug}/project-boards/${projectId}/comments/${commentId}/reactions/${reactionHex}/`
|
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response;
|
|
|
|
});
|
|
|
|
}
|
2023-08-11 11:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default IssueService;
|