2024-05-14 14:26:54 +05:30
|
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
2023-08-11 17:18:33 +05:30
|
|
|
// services
|
2024-05-14 22:09:29 +05:30
|
|
|
import { APIService } from "@/services/api.service";
|
2024-06-10 12:16:23 +05:30
|
|
|
// types
|
2024-07-15 18:35:45 +05:30
|
|
|
import { TIssuesResponse, IIssue } from "@/types/issue";
|
2023-08-11 17:18:33 +05:30
|
|
|
|
|
|
|
|
class IssueService extends APIService {
|
|
|
|
|
constructor() {
|
2023-09-13 20:21:02 +05:30
|
|
|
super(API_BASE_URL);
|
2023-08-11 17:18:33 +05:30
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async fetchPublicIssues(anchor: string, params: any): Promise<TIssuesResponse> {
|
|
|
|
|
return this.get(`/api/public/anchor/${anchor}/issues/`, {
|
2023-09-01 16:42:30 +05:30
|
|
|
params,
|
|
|
|
|
})
|
|
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 18:35:45 +05:30
|
|
|
async getIssueById(anchor: string, issueID: string): Promise<IIssue> {
|
2024-06-10 12:16:23 +05:30
|
|
|
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/`)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async getIssueVotes(anchor: string, issueID: string): Promise<any> {
|
|
|
|
|
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async createIssueVote(anchor: string, issueID: string, data: any): Promise<any> {
|
|
|
|
|
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`, data)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async deleteIssueVote(anchor: string, issueID: string): Promise<any> {
|
|
|
|
|
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async getIssueReactions(anchor: string, issueID: string): Promise<any> {
|
|
|
|
|
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async createIssueReaction(anchor: string, issueID: string, data: any): Promise<any> {
|
|
|
|
|
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`, data)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async deleteIssueReaction(anchor: string, issueID: string, reactionId: string): Promise<any> {
|
|
|
|
|
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/${reactionId}/`)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async getIssueComments(anchor: string, issueID: string): Promise<any> {
|
|
|
|
|
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async createIssueComment(anchor: string, issueID: string, data: any): Promise<any> {
|
|
|
|
|
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`, data)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async updateIssueComment(anchor: string, issueID: string, commentId: string, data: any): Promise<any> {
|
|
|
|
|
return this.patch(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`, data)
|
2023-09-01 16:42:30 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async deleteIssueComment(anchor: string, issueID: string, commentId: string): Promise<any> {
|
|
|
|
|
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`)
|
2023-08-11 17:18:33 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-09-06 11:59:57 +05:30
|
|
|
|
|
|
|
|
async createCommentReaction(
|
2024-06-10 12:16:23 +05:30
|
|
|
anchor: string,
|
2023-09-06 11:59:57 +05:30
|
|
|
commentId: string,
|
|
|
|
|
data: {
|
|
|
|
|
reaction: string;
|
|
|
|
|
}
|
|
|
|
|
): Promise<any> {
|
2024-06-10 12:16:23 +05:30
|
|
|
return this.post(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/`, data)
|
2023-09-06 11:59:57 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-10 12:16:23 +05:30
|
|
|
async deleteCommentReaction(anchor: string, commentId: string, reactionHex: string): Promise<any> {
|
|
|
|
|
return this.delete(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/${reactionHex}/`)
|
2023-09-06 11:59:57 +05:30
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response;
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-08-11 17:18:33 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default IssueService;
|