package cz.moneta.test.dsl.util.task.auto.smartauto.insurance;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.auto.smartauto.NewCalculationPage;
import cz.moneta.test.dsl.auto.smartauto.shared.*;
import cz.moneta.test.dsl.util.task.auto.smartauto.SmartAutoTasks;

import java.util.function.Function;

public class InsuranceTasks {

    private final Harness harness;

    public InsuranceTasks(Harness harness) {
        this.harness = harness;
    }

    public Function<NewCalculationPage, NewCalculationPage> fillCustomerData(
            CalculationData calculationData, SmartAutoTasks smartAutoTasks, CompanyData companyData) {
        return fillCustomerData(calculationData, smartAutoTasks, null, null, companyData);
    }

    public Function<NewCalculationPage, NewCalculationPage> fillCustomerData(
            CalculationData calculationData,
            SmartAutoTasks smartAutoTasks,
            ContactData contactData,
            IdentificationData identificationData) {
        return fillCustomerData(calculationData, smartAutoTasks, contactData, identificationData, null);
    }

    public Function<NewCalculationPage, NewCalculationPage> fillCustomerData(
            CalculationData calculationData,
            SmartAutoTasks smartAutoTasks,
            ContactData contactData,
            IdentificationData identificationData,
            CompanyData companyData) {
        return calculationData.getCustomer() == Customer.CONSUMER ?
                smartAutoTasks.calculationType().fillInsuranceCustomerData(contactData, identificationData) :
                smartAutoTasks.calculationType().fillInsuranceFirmData(companyData);
    }

    public Function<NewCalculationPage, NewCalculationPage> fillInsuranceData(
            CalculationData calculationData,
            SmartAutoTasks smartAutoTasks) {
        return switch (calculationData.getBrand()) {
            case AGADOS -> smartAutoTasks.calculationType().fillInsuranceDataTrailer(calculationData);
            case HARLEY -> smartAutoTasks.calculationType().fillInsuranceDataNoVin(calculationData);
            case JCB -> smartAutoTasks.calculationType().fillInsuranceDataAgro(calculationData);
            default -> smartAutoTasks.calculationType().fillInsuranceData(calculationData);
        };
    }

    public Function<NewCalculationPage, NewCalculationPage> fillInsuranceDataFilters(
            CalculationData calculationData,
            SmartAutoTasks smartAutoTasks) {
        return smartAutoTasks.calculationType().fillInsuranceDataNoVin(calculationData);
    }
}