|
@ -9,35 +9,35 @@ export class APIExampleRepository implements ExampleRepository { |
|
|
) {} |
|
|
) {} |
|
|
|
|
|
|
|
|
async list(projectId: string, { limit = '10', offset = '0', q = '', isChecked = '', filterName = '' }: SearchOption): Promise<ExampleItemList> { |
|
|
async list(projectId: string, { limit = '10', offset = '0', q = '', isChecked = '', filterName = '' }: SearchOption): Promise<ExampleItemList> { |
|
|
const url = `/projects/${projectId}/data?limit=${limit}&offset=${offset}&q=${q}&${filterName}=${isChecked}` |
|
|
|
|
|
|
|
|
const url = `/projects/${projectId}/examples?limit=${limit}&offset=${offset}&q=${q}&${filterName}=${isChecked}` |
|
|
const response = await this.request.get(url) |
|
|
const response = await this.request.get(url) |
|
|
return ExampleItemList.valueOf(response.data) |
|
|
return ExampleItemList.valueOf(response.data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async create(projectId: string, item: ExampleItem): Promise<ExampleItem> { |
|
|
async create(projectId: string, item: ExampleItem): Promise<ExampleItem> { |
|
|
const url = `/projects/${projectId}/data` |
|
|
|
|
|
|
|
|
const url = `/projects/${projectId}/examples` |
|
|
const response = await this.request.post(url, item.toObject()) |
|
|
const response = await this.request.post(url, item.toObject()) |
|
|
return ExampleItem.valueOf(response.data) |
|
|
return ExampleItem.valueOf(response.data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async update(projectId: string, item: ExampleItem): Promise<ExampleItem> { |
|
|
async update(projectId: string, item: ExampleItem): Promise<ExampleItem> { |
|
|
const url = `/projects/${projectId}/data/${item.id}` |
|
|
|
|
|
|
|
|
const url = `/projects/${projectId}/examples/${item.id}` |
|
|
const response = await this.request.patch(url, item.toObject()) |
|
|
const response = await this.request.patch(url, item.toObject()) |
|
|
return ExampleItem.valueOf(response.data) |
|
|
return ExampleItem.valueOf(response.data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async bulkDelete(projectId: string, ids: number[]): Promise<void> { |
|
|
async bulkDelete(projectId: string, ids: number[]): Promise<void> { |
|
|
const url = `/projects/${projectId}/data` |
|
|
|
|
|
|
|
|
const url = `/projects/${projectId}/examples` |
|
|
await this.request.delete(url, { ids }) |
|
|
await this.request.delete(url, { ids }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async deleteAll(projectId: string): Promise<void> { |
|
|
async deleteAll(projectId: string): Promise<void> { |
|
|
const url = `/projects/${projectId}/data` |
|
|
|
|
|
|
|
|
const url = `/projects/${projectId}/examples` |
|
|
await this.request.delete(url) |
|
|
await this.request.delete(url) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async approve(projectId: string, docId: number, approved: boolean): Promise<void> { |
|
|
|
|
|
const url = `/projects/${projectId}/approval/${docId}` |
|
|
|
|
|
|
|
|
async approve(projectId: string, exampleId: number, approved: boolean): Promise<void> { |
|
|
|
|
|
const url = `/projects/${projectId}/approval/${exampleId}` |
|
|
await this.request.post(url, { approved }) |
|
|
await this.request.post(url, { approved }) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |