import { backendApiClient } from './api-client';
export class CarsCalculatorApi {
  async getCarsMakes() {
    const res = (await backendApiClient().url('/makes').get().json());
    return res.qt_makes;
  }
  async getCarsModels(makeId) {
    const res = (await backendApiClient()
      .url(`/makes/${makeId}/models`)
      .get()
      .json());
    return res.qt_models;
  }
  async getCarsModelYears(modelId) {
    return backendApiClient().url(`/models/${modelId}/years`).get().json();
  }
  async getCarsModelBodyTypes(modelId, year) {
    const res = (await backendApiClient()
      .url(`/models/${modelId}/years/${year}/body-types`)
      .get()
      .json());
    return res.qt_body_types;
  }
  async getCarsModelVariant(modelId, year, bodyTypeId) {
    const res = (await backendApiClient()
      .url(`/models/${modelId}/years/${year}/body-types/${bodyTypeId}/variants`)
      .get()
      .json());
    return res.qt_variants;
  }
  async getCarsVariantPhotos(variantId) {
    const res = (await backendApiClient()
      .url(`/variants/${variantId}/photos`)
      .get()
      .json());
    return res.qt_variant_photos;
  }
  async postCarsQuoteResult(req) {
    return (await backendApiClient().url(`/quote`).post(req).json());
  }
  async postQuoteInfoAsync(req) {
    return backendApiClient().url(`/enquiry`).post(req).text();
  }
}
export default new CarsCalculatorApi();
