import { api } from '@/lib/api'
import type { RateLimitRule } from '@/types/api'

export const rateLimitService = {
  getAll: async () => {
    const response = await api.get<RateLimitRule[]>('/v1/settings/ratelimit')
    return response.data
  },

  create: async (data: Partial<RateLimitRule>) => {
    const response = await api.post<RateLimitRule>('/v1/settings/ratelimit', data)
    return response.data
  },

  update: async (id: string, data: Partial<RateLimitRule>) => {
    const response = await api.put<RateLimitRule>(`/v1/settings/ratelimit/${id}`, data)
    return response.data
  },

  delete: async (id: string) => {
    await api.delete(`/v1/settings/ratelimit/${id}`)
  }
}
