-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPages.ts
More file actions
52 lines (47 loc) · 1.6 KB
/
Copy pathPages.ts
File metadata and controls
52 lines (47 loc) · 1.6 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 { CreatePageTemplate, PageTemplate, UpdatePageTemplate } from "../../models/ProjectTemplate";
/**
* ProjectPageTemplates sub-resource
* Manages page templates within a project
*/
export class Pages extends BaseResource {
constructor(config: Configuration) {
super(config);
}
/**
* List all page templates for a project
*/
async list(workspaceSlug: string, projectId: string): Promise<PageTemplate[]> {
const data = await this.get<PageTemplate[] | { results: PageTemplate[] }>(
`/workspaces/${workspaceSlug}/projects/${projectId}/pages/templates/`
);
return Array.isArray(data) ? data : data.results;
}
/**
* Create a new page template for a project
*/
async create(workspaceSlug: string, projectId: string, data: CreatePageTemplate): Promise<PageTemplate> {
return this.post<PageTemplate>(`/workspaces/${workspaceSlug}/projects/${projectId}/pages/templates/`, data);
}
/**
* Update a page template by ID
*/
async update(
workspaceSlug: string,
projectId: string,
templateId: string,
data: UpdatePageTemplate
): Promise<PageTemplate> {
return this.patch<PageTemplate>(
`/workspaces/${workspaceSlug}/projects/${projectId}/pages/templates/${templateId}/`,
data
);
}
/**
* Delete a page template by ID
*/
async del(workspaceSlug: string, projectId: string, templateId: string): Promise<void> {
return this.httpDelete(`/workspaces/${workspaceSlug}/projects/${projectId}/pages/templates/${templateId}/`);
}
}