-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathWorkItems.ts
More file actions
52 lines (47 loc) · 1.7 KB
/
Copy pathWorkItems.ts
File metadata and controls
52 lines (47 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { BaseResource } from "../BaseResource";
import { Configuration } from "../../Configuration";
import { CreateWorkItemTemplate, UpdateWorkItemTemplate, WorkItemTemplate } from "../../models/ProjectTemplate";
/**
* ProjectWorkItemTemplates sub-resource
* Manages work item templates within a project
*/
export class WorkItems extends BaseResource {
constructor(config: Configuration) {
super(config);
}
/**
* List all work item templates for a project
*/
async list(workspaceSlug: string, projectId: string): Promise<WorkItemTemplate[]> {
const data = await this.get<WorkItemTemplate[] | { results: WorkItemTemplate[] }>(
`/workspaces/${workspaceSlug}/projects/${projectId}/workitems/templates/`
);
return Array.isArray(data) ? data : data.results;
}
/**
* Create a new work item template for a project
*/
async create(workspaceSlug: string, projectId: string, data: CreateWorkItemTemplate): Promise<WorkItemTemplate> {
return this.post<WorkItemTemplate>(`/workspaces/${workspaceSlug}/projects/${projectId}/workitems/templates/`, data);
}
/**
* Update a work item template by ID
*/
async update(
workspaceSlug: string,
projectId: string,
templateId: string,
data: UpdateWorkItemTemplate
): Promise<WorkItemTemplate> {
return this.patch<WorkItemTemplate>(
`/workspaces/${workspaceSlug}/projects/${projectId}/workitems/templates/${templateId}/`,
data
);
}
/**
* Delete a work item template by ID
*/
async del(workspaceSlug: string, projectId: string, templateId: string): Promise<void> {
return this.httpDelete(`/workspaces/${workspaceSlug}/projects/${projectId}/workitems/templates/${templateId}/`);
}
}