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.

16 lines
492 B

2 years ago
  1. import { RoleItem } from '@/domain/models/role/role'
  2. import ApiService from '@/services/api.service'
  3. function toModel(item: { [key: string]: any }): RoleItem {
  4. return new RoleItem(item.id, item.name)
  5. }
  6. export class APIRoleRepository {
  7. constructor(private readonly request = ApiService) {}
  8. async list(): Promise<RoleItem[]> {
  9. const url = `/roles`
  10. const response = await this.request.get(url)
  11. return response.data.map((item: { [key: string]: any }) => toModel(item))
  12. }
  13. }