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

  1. import ApiService from '@/services/api.service'
  2. import { MemberRepository, MemberItemResponse } from '@/domain/models/member/memberRepository'
  3. import { MemberItem } from '~/domain/models/member/member'
  4. export class APIMemberRepository implements MemberRepository {
  5. constructor(
  6. private readonly request = ApiService
  7. ) {}
  8. async list(projectId: string): Promise<MemberItem[]> {
  9. const url = `/projects/${projectId}/roles`
  10. const response = await this.request.get(url)
  11. const responseItems: MemberItemResponse[] = response.data
  12. return responseItems.map(item => MemberItem.valueOf(item))
  13. }
  14. async create(projectId: string, item: MemberItem): Promise<MemberItem> {
  15. const url = `/projects/${projectId}/roles`
  16. const response = await this.request.post(url, item.toObject())
  17. const responseItem: MemberItemResponse = response.data
  18. return MemberItem.valueOf(responseItem)
  19. }
  20. async update(projectId: string, item: MemberItem): Promise<MemberItem> {
  21. const url = `/projects/${projectId}/roles/${item.id}`
  22. const response = await this.request.patch(url, item.toObject())
  23. const responseItem: MemberItemResponse = response.data
  24. return MemberItem.valueOf(responseItem)
  25. }
  26. async bulkDelete(projectId: string, labelIds: number[]): Promise<void> {
  27. const url = `/projects/${projectId}/roles`
  28. await this.request.delete(url, { ids: labelIds })
  29. }
  30. }