mirror of https://github.com/doccano/doccano.git
pythonannotation-tooldatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learning
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.4 KiB
36 lines
1.4 KiB
import ApiService from '@/services/api.service'
|
|
import { MemberRepository, MemberItemResponse } from '@/domain/models/member/memberRepository'
|
|
import { MemberItem } from '~/domain/models/member/member'
|
|
|
|
|
|
export class APIMemberRepository implements MemberRepository {
|
|
constructor(
|
|
private readonly request = ApiService
|
|
) {}
|
|
|
|
async list(projectId: string): Promise<MemberItem[]> {
|
|
const url = `/projects/${projectId}/roles`
|
|
const response = await this.request.get(url)
|
|
const responseItems: MemberItemResponse[] = response.data
|
|
return responseItems.map(item => MemberItem.valueOf(item))
|
|
}
|
|
|
|
async create(projectId: string, item: MemberItem): Promise<MemberItem> {
|
|
const url = `/projects/${projectId}/roles`
|
|
const response = await this.request.post(url, item.toObject())
|
|
const responseItem: MemberItemResponse = response.data
|
|
return MemberItem.valueOf(responseItem)
|
|
}
|
|
|
|
async update(projectId: string, item: MemberItem): Promise<MemberItem> {
|
|
const url = `/projects/${projectId}/roles/${item.id}`
|
|
const response = await this.request.patch(url, item.toObject())
|
|
const responseItem: MemberItemResponse = response.data
|
|
return MemberItem.valueOf(responseItem)
|
|
}
|
|
|
|
async bulkDelete(projectId: string, labelIds: number[]): Promise<void> {
|
|
const url = `/projects/${projectId}/roles`
|
|
await this.request.delete(url, { ids: labelIds })
|
|
}
|
|
}
|