|
|
@ -14,29 +14,29 @@ export class APICommentRepository implements CommentRepository { |
|
|
|
return items.map(item => CommentItem.valueOf(item)) |
|
|
|
} |
|
|
|
|
|
|
|
async list(projectId: string, docId: number): Promise<CommentItem[]> { |
|
|
|
const url = `/projects/${projectId}/docs/${docId}/comments` |
|
|
|
async list(projectId: string, exampleId: number): Promise<CommentItem[]> { |
|
|
|
const url = `/projects/${projectId}/examples/${exampleId}/comments` |
|
|
|
const response = await this.request.get(url) |
|
|
|
const items: CommentItemResponse[] = response.data |
|
|
|
return items.map(item => CommentItem.valueOf(item)) |
|
|
|
} |
|
|
|
|
|
|
|
async create(projectId: string, docId: number, text: string): Promise<CommentItem> { |
|
|
|
const url = `/projects/${projectId}/docs/${docId}/comments` |
|
|
|
const response = await this.request.post(url, { projectId, docId, text }) |
|
|
|
async create(projectId: string, exampleId: number, text: string): Promise<CommentItem> { |
|
|
|
const url = `/projects/${projectId}/examples/${exampleId}/comments` |
|
|
|
const response = await this.request.post(url, { projectId, exampleId, text }) |
|
|
|
const responseItem: CommentItemResponse = response.data |
|
|
|
return CommentItem.valueOf(responseItem) |
|
|
|
} |
|
|
|
|
|
|
|
async update(projectId: string, docId: number, item: CommentItem): Promise<CommentItem> { |
|
|
|
const url = `/projects/${projectId}/docs/${docId}/comments/${item.id}` |
|
|
|
async update(projectId: string, exampleId: number, item: CommentItem): Promise<CommentItem> { |
|
|
|
const url = `/projects/${projectId}/examples/${exampleId}/comments/${item.id}` |
|
|
|
const response = await this.request.put(url, item.toObject()) |
|
|
|
const responseItem: CommentItemResponse = response.data |
|
|
|
return CommentItem.valueOf(responseItem) |
|
|
|
} |
|
|
|
|
|
|
|
async delete(projectId: string, docId: number, commentId: number): Promise<void> { |
|
|
|
const url = `/projects/${projectId}/docs/${docId}/comments/${commentId}` |
|
|
|
async delete(projectId: string, exampleId: number, commentId: number): Promise<void> { |
|
|
|
const url = `/projects/${projectId}/examples/${exampleId}/comments/${commentId}` |
|
|
|
const response = await this.request.delete(url) |
|
|
|
} |
|
|
|
|
|
|
|