package cz.moneta.test.dsl.util.task.monetaportal;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.monetaportal.components.calculators.BusinessLoanCalculator;
import cz.moneta.test.dsl.monetaportal.components.calculators.ExpressLoanBannerCalculator;
import cz.moneta.test.dsl.monetaportal.components.calculators.ExpressLoanCalculator;
import cz.moneta.test.dsl.monetaportal.components.calculators.LoanCalculator;

import java.util.function.Function;

public class CalculatorTasks {

    private final Harness harness;

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

    public Function<ExpressLoanCalculator, ExpressLoanCalculator> fillLoanCalculator(String loanAmount, int moveLoanAmount, int moveLoanLength) {
        return start -> start
                .clickLoanCalculatorAmountInput()
                .fillLoanCalculatorAmountInput(loanAmount)
                .moveCalculatorLoanAmount(moveLoanAmount)
                .moveCalculatorLoanLengthBy(moveLoanLength)
                .clickLoanCalculatorButton();
    }

    public Function<ExpressLoanBannerCalculator, ExpressLoanBannerCalculator> fillLoanBannerCalculator(String loanAmount, int moveLoanAmount, int moveLoanLength) {
        return start -> start
                .clickLoanCalculatorAmountInput()
                .fillLoanCalculatorAmountInput(loanAmount)
                .moveCalculatorLoanAmount(moveLoanAmount)
                .moveCalculatorLoanLengthBy(moveLoanLength)
                .clickLoanCalculatorButton();
    }

    public Function<BusinessLoanCalculator, BusinessLoanCalculator> fillBusinessCalculator(String loanAmount, int moveLoanAmount, String loanLength, int moveLoanLength) {
        return start -> start
                .clickBusinessCalculatorAmountInput()
                .fillBusinessCalculatorAmountInput(loanAmount)
                .moveBusinessCalculatorLoanAmount(moveLoanAmount)
                .fillBusinessCalculatorLengthBy(loanLength)
                .moveBusinessCalculatorLoanLengthBy(moveLoanLength);
    }

    public Function<LoanCalculator, LoanCalculator> fillLoanCalculator(String loanAmount, int moveLoanAmount, String loanLength, int moveLoanLength) {
        return start -> start
                .fillLoanCalculatorAmountInput(loanAmount)
                .moveLoanCalculatorLoanAmount(moveLoanAmount)
                .fillLoanCalculatorLengthBy(loanLength)
                .moveLoanCalculatorLoanLengthBy(moveLoanLength)
                .clickLoanCalculatorFixationButton();
    }
}
