/** POST /api/settings/carrier-rates/store — body: CarrierRateInput (camelCase) → { status, id } */
import { withIdempiere } from '../../../utils/shipping/withIdempiere'
import fetchHelper from '../../../utils/fetchHelper'
import { CARRIER_RATE_MODEL, carrierRateBody } from '../../../utils/shipping/carrierRates'

export default defineEventHandler(withIdempiere(async (event, token) => {
  const body: any = await readBody(event)
  if (!body?.shipperId || !body?.serviceCode) return { status: 400, message: 'shipperId and serviceCode are required' }
  const res: any = await fetchHelper(event, CARRIER_RATE_MODEL, 'POST', token, carrierRateBody(body, true))
  return { ...res, status: 200, message: '' }
}))
