import { useApi } from '~/composables/useApi' import type { BovinShipmentData } from '~/services/dto/bovin-shipment-data' import type { ShipmentBovinePayload, BovinShipmentListResponse } from '~/services/dto/bovin-shipment-data' export async function getBovinShipmentList( shipmentIri: string ): Promise { const api = useApi() const response = await api.get( 'bovin_shipments', { shipment: shipmentIri }, { toastErrorKey: 'errors.shipmentBovine.list' } ) if (Array.isArray(response)) { return response } if (response && typeof response === 'object' && Array.isArray(response['hydra:member'])) { return response['hydra:member'] } return [] } export async function createShipmentBovine( payload: ShipmentBovinePayload ): Promise { const api = useApi() return api.post('bovin_shipments', payload, { toastErrorKey: 'errors.shipmentBovine.create' }) } export async function deleteShipmentBovine(id: number): Promise { const api = useApi() await api.delete(`bovin_shipments/${id}`, {}, { toastErrorKey: 'errors.shipmentBovine.delete' }) } export async function updateShipmentBovine( id: number, payload: Partial ): Promise { const api = useApi() return api.patch(`bovin_shipments/${id}`, payload, { toastErrorKey: 'errors.shipmentBovine.update' }) }