import axios from 'axios'
import type { ListResponse, FilamentSpool, PrintJob } from '../types'

const api = axios.create({
  baseURL: '/api',
  headers: { 'Content-Type': 'application/json' },
})

export async function getFilaments(params?: { low_stock?: boolean; limit?: number; offset?: number }) {
  const res = await api.get<ListResponse<FilamentSpool>>('/filaments', { params })
  return res.data
}

export async function getPrintJobs(params?: { limit?: number; offset?: number }) {
  const res = await api.get<ListResponse<PrintJob>>('/print-jobs', { params })
  return res.data
}

export default api
