/**
 * Roles resource: list all roles
 */

import type { AxiosInstance } from 'axios';
import { API_PATHS } from '@effigenix/config';

export interface RoleDTO {
  id: string;
  name: string;
  permissions: string[];
}

export function createRolesResource(client: AxiosInstance) {
  return {
    async list(): Promise<RoleDTO[]> {
      const response = await client.get<RoleDTO[]>(API_PATHS.roles.base);
      return response.data;
    },
  };
}

export type RolesResource = ReturnType<typeof createRolesResource>;
