import api from './api';
import { type AttributeDefinition } from '../types/AttributeDefinition';

export const attributeService = {
  getByCategoryId: async (categoryId: number): Promise<AttributeDefinition[]> => {
    const response = await api.get<AttributeDefinition[]>(`/attributedefinitions/category/${categoryId}`);
    return response.data;
  },

  create: async (attribute: Partial<AttributeDefinition>): Promise<AttributeDefinition> => {
    const response = await api.post<AttributeDefinition>('/attributedefinitions', attribute);
    return response.data;
  },

  delete: async (id: number): Promise<void> => {
    await api.delete(`/attributedefinitions/${id}`);
  }
};
