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.
 
 
 
 
 
 

33 lines
1.3 KiB

import { plainToInstance } from 'class-transformer'
import ApiService from '@/services/api.service'
import { MemberRepository } 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}/members`
const response = await this.request.get(url)
return response.data.map((item: any) => plainToInstance(MemberItem, item))
}
async create(projectId: string, item: MemberItem): Promise<MemberItem> {
const url = `/projects/${projectId}/members`
const response = await this.request.post(url, item.toObject())
return plainToInstance(MemberItem, response.data)
}
async update(projectId: string, item: MemberItem): Promise<MemberItem> {
const url = `/projects/${projectId}/members/${item.id}`
const response = await this.request.patch(url, item.toObject())
return plainToInstance(MemberItem, response.data)
}
async bulkDelete(projectId: string, memberIds: number[]): Promise<void> {
const url = `/projects/${projectId}/members`
await this.request.delete(url, { ids: memberIds })
}
}