import { FacilityQualificationRatesApi } from "omsorgcore-client-ts";
import { configFor, callApi } from "./apiClientHelpers.js";

// Kapselt /api/facilities/{facilityId}/qualification-rates von omsorgCore
// (FacilityQualificationRatesController) über den generierten Client (omsorgcore-client-ts).
// Qualifikationsabhängige Preise sind eine 1:n-Unterressource von Facility (FR-EIN-4).
export async function listFacilityQualificationRates(accessToken, facilityId) {
  const api = new FacilityQualificationRatesApi(configFor(accessToken));
  return callApi(api.apiFacilitiesFacilityIdQualificationRatesGetRaw({ facilityId }));
}

export async function createFacilityQualificationRate(accessToken, facilityId, payload) {
  const api = new FacilityQualificationRatesApi(configFor(accessToken));
  return callApi(api.apiFacilitiesFacilityIdQualificationRatesPostRaw({ facilityId, createFacilityQualificationRateRequest: payload }));
}

export async function updateFacilityQualificationRate(accessToken, facilityId, id, payload) {
  const api = new FacilityQualificationRatesApi(configFor(accessToken));
  return callApi(api.apiFacilitiesFacilityIdQualificationRatesIdPutRaw({ facilityId, id, updateFacilityQualificationRateRequest: payload }));
}

export async function deleteFacilityQualificationRate(accessToken, facilityId, id) {
  const api = new FacilityQualificationRatesApi(configFor(accessToken));
  return callApi(api.apiFacilitiesFacilityIdQualificationRatesIdDeleteRaw({ facilityId, id }));
}
