forked from github/plane
3d09a69d58
* fix: eslint fixes --------- Co-authored-by: gurusainath <gurusainath007@gmail.com>
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { API_BASE_URL } from "helpers/common.helper";
|
|
import { APIService } from "services/api.service";
|
|
// helper
|
|
// types
|
|
import { TIssueAttachment } from "@plane/types";
|
|
|
|
export class IssueAttachmentService extends APIService {
|
|
constructor() {
|
|
super(API_BASE_URL);
|
|
}
|
|
|
|
async uploadIssueAttachment(
|
|
workspaceSlug: string,
|
|
projectId: string,
|
|
issueId: string,
|
|
file: FormData
|
|
): Promise<TIssueAttachment> {
|
|
return this.post(
|
|
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-attachments/`,
|
|
file,
|
|
{
|
|
headers: {
|
|
...this.getHeaders(),
|
|
"Content-Type": "multipart/form-data",
|
|
},
|
|
}
|
|
)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
|
|
async getIssueAttachment(workspaceSlug: string, projectId: string, issueId: string): Promise<TIssueAttachment[]> {
|
|
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-attachments/`)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
|
|
async deleteIssueAttachment(
|
|
workspaceSlug: string,
|
|
projectId: string,
|
|
issueId: string,
|
|
assetId: string
|
|
): Promise<TIssueAttachment> {
|
|
return this.delete(
|
|
`/api/workspaces/${workspaceSlug}/projects/${projectId}/issues/${issueId}/issue-attachments/${assetId}/`
|
|
)
|
|
.then((response) => response?.data)
|
|
.catch((error) => {
|
|
throw error?.response?.data;
|
|
});
|
|
}
|
|
}
|