/** Typed API functions for the Würfe (litters) resource. */
import { api, resources } from './client'
import { toQueryString, type GridifyQuery } from './gridify'
import type { CreateLitter, Litter, Paged, UpdateLitter } from './types'

export function getLitter(id: string): Promise<Litter> {
  return api.get<Litter>(`${resources.litters}/${id}`)
}

export function listLitters(query: GridifyQuery): Promise<Paged<Litter>> {
  return api.get<Paged<Litter>>(`${resources.litters}${toQueryString(query)}`)
}

export function createLitter(body: CreateLitter): Promise<Litter> {
  return api.post<Litter>(resources.litters, body)
}

export function updateLitter(id: string, body: UpdateLitter): Promise<Litter> {
  return api.put<Litter>(`${resources.litters}/${id}`, body)
}

export function deleteLitter(id: string): Promise<void> {
  return api.delete(`${resources.litters}/${id}`)
}
