2024-04-08 13:41:47 +00:00
|
|
|
// types
|
|
|
|
import type { TInboxIssue, TIssue, TInboxIssueWithPagination } from "@plane/types";
|
2024-03-19 14:38:35 +00:00
|
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
|
|
|
import { APIService } from "@/services/api.service";
|
2024-01-24 15:03:54 +00:00
|
|
|
// helpers
|
|
|
|
|
|
|
|
export class InboxIssueService extends APIService {
|
|
|
|
constructor() {
|
|
|
|
super(API_BASE_URL);
|
|
|
|
}
|
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
async list(workspaceSlug: string, projectId: string, params = {}): Promise<TInboxIssueWithPagination> {
|
|
|
|
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inbox-issues/`, {
|
|
|
|
params,
|
|
|
|
})
|
2024-01-24 15:03:54 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
async retrieve(workspaceSlug: string, projectId: string, inboxIssueId: string): Promise<TInboxIssue> {
|
2024-01-24 15:03:54 +00:00
|
|
|
return this.get(
|
2024-04-08 13:41:47 +00:00
|
|
|
`/api/workspaces/${workspaceSlug}/projects/${projectId}/inbox-issues/${inboxIssueId}/?expand=issue_inbox`
|
2024-01-24 15:03:54 +00:00
|
|
|
)
|
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
async create(workspaceSlug: string, projectId: string, data: Partial<TIssue>): Promise<TInboxIssue> {
|
|
|
|
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inbox-issues/`, {
|
|
|
|
source: "IN_APP",
|
|
|
|
issue: data,
|
|
|
|
})
|
2024-01-24 15:03:54 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
async update(
|
2024-01-24 15:03:54 +00:00
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
|
|
|
inboxIssueId: string,
|
2024-04-08 13:41:47 +00:00
|
|
|
data: Partial<TInboxIssue>
|
|
|
|
): Promise<TInboxIssue> {
|
|
|
|
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inbox-issues/${inboxIssueId}/`, data)
|
2024-01-24 15:03:54 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
async updateIssue(
|
2024-01-24 15:03:54 +00:00
|
|
|
workspaceSlug: string,
|
|
|
|
projectId: string,
|
2024-04-08 13:41:47 +00:00
|
|
|
inboxIssueId: string,
|
|
|
|
data: Partial<TIssue>
|
|
|
|
): Promise<TInboxIssue> {
|
|
|
|
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inbox-issues/${inboxIssueId}/`, {
|
|
|
|
issue: data,
|
|
|
|
})
|
2024-01-24 15:03:54 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-08 13:41:47 +00:00
|
|
|
async destroy(workspaceSlug: string, projectId: string, inboxIssueId: string): Promise<void> {
|
|
|
|
return this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inbox-issues/${inboxIssueId}/`)
|
2024-01-24 15:03:54 +00:00
|
|
|
.then((response) => response?.data)
|
|
|
|
.catch((error) => {
|
|
|
|
throw error?.response?.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|