package cz.moneta.test.dsl.util.task.ufo.operations;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.operations.client.creditcard.FeePaymentsMethod;
import cz.moneta.test.dsl.ufo.operations.client.creditcard.OPK705_S101_ProductSelectionPage;
import cz.moneta.test.dsl.ufo.operations.client.product.ProductActivationResultPage;
import cz.moneta.test.dsl.util.DateUtils;
import cz.moneta.test.dsl.util.data.client.NonClient;

import java.util.function.Function;

public class ProductActivationTasks {

    private final Harness harness;

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

    public Function<OPK705_S101_ProductSelectionPage, ProductActivationResultPage> createCreditCard(
            NonClient nonClient,
            String productType,
            String cardVariant,
            String cardBrand,
            String promo,
            String requestedAmount,
            String employmentContractType,
            String dailyPurchaseLimit,
            String dailyWithdrawLimit,
            String dailyOnlinePaymentsLimit,
            String loyaltyProgram,
            String accountType,
            String activationPassword
    ) {
        return start -> start
                    .selectProductType(productType)
                    .selectCardVariant(cardVariant)
                    .selectCardBrand(cardBrand)
                    .selectPromo(promo)
                    .requestedAmount(requestedAmount)
                    .selectEmploymentType(employmentContractType)
                .continueToClientDetails()
                    .selectSecondId("Řidičský průkaz")
                    .setDriveLicenceId(nonClient.driverLicenceId())
                    .setDriveLicenceExpire(DateUtils.getDateWithFormat(nonClient.driveLicenceExpiryDateRaw(),"d.M.yyyy"))
                    .selectJob(nonClient.occupationAdditionalInformation())
                    .selectContractType(employmentContractType)
                    .checkEmploymentDataVerifiedWithClient()
                    .setNumberOfIncomeSources(nonClient.incomeSources())
                    .setNetIncomeThreeMonthsAvg(nonClient.netMonthlyIncome())
                    .setOtherMonthlyExpenses(nonClient.otherExpenses())
                    .setTotalHouseholdIncome(nonClient.homeIncome())
                    .setOtherNonMMBMonthlyPayments(nonClient.otherLoanPayments())
                    .setWageDeductions(nonClient.wageDeductions())
                    .checkIncomeDataVerifiedWithClient()
                    .setActivationPassword(activationPassword)
                    .setDailyPurchaseLimit(dailyPurchaseLimit)
                    .setDailyWithdrawLimit(dailyWithdrawLimit)
                    .setDailyOnlinePaymentsLimit(dailyOnlinePaymentsLimit)
                    .setLoyaltyProgram(loyaltyProgram)
                    .setSendPinViaSMS()
                    .setFeePaymentMethod(FeePaymentsMethod.INKASO)
                    .setAccountType(accountType)
                    .requestFormalControl()
                    .assertFormalControlWasSuccessful()
                    .continueToUserConfirmation()
                    .userConfirmed()
                .continueToProductActivationResult();
    }

    public Function<OPK705_S101_ProductSelectionPage, ProductActivationResultPage> createCreditCardWithDiscountPackage(
            NonClient nonClient,
            String productType,
            String cardVariant,
            String cardBrand,
            String promo,
            String requestedAmount,
            String employmentContractType,
            String dailyPurchaseLimit,
            String dailyWithdrawLimit,
            String dailyOnlinePaymentsLimit,
            String loyaltyProgram,
            String discountPackage,
            String accountType,
            String activationPassword
    ) {
        return start -> start
                .selectProductType(productType)
                .selectCardVariant(cardVariant)
                .selectCardBrand(cardBrand)
                .selectPromo(promo)
                .requestedAmount(requestedAmount)
                .selectEmploymentType(employmentContractType)
                .continueToClientDetails()
                .selectSecondId("Řidičský průkaz")
                .setDriveLicenceId(nonClient.driverLicenceId())
                .setDriveLicenceExpire(DateUtils.getDateWithFormat(nonClient.driveLicenceExpiryDateRaw(),"d.M.yyyy"))
                .selectJob(nonClient.occupationAdditionalInformation())
                .selectContractType(employmentContractType)
                .checkEmploymentDataVerifiedWithClient()
                .setNumberOfIncomeSources(nonClient.incomeSources())
                .setNetIncomeThreeMonthsAvg(nonClient.netMonthlyIncome())
                .setOtherMonthlyExpenses(nonClient.otherExpenses())
                .setTotalHouseholdIncome(nonClient.homeIncome())
                .setOtherNonMMBMonthlyPayments(nonClient.otherLoanPayments())
                .setWageDeductions(nonClient.wageDeductions())
                .checkIncomeDataVerifiedWithClient()
                .setActivationPassword(activationPassword)
                .setDailyPurchaseLimit(dailyPurchaseLimit)
                .setDailyWithdrawLimit(dailyWithdrawLimit)
                .setDailyOnlinePaymentsLimit(dailyOnlinePaymentsLimit)
                .setLoyaltyProgram(loyaltyProgram)
                .setDiscountPackage(discountPackage)
                .setSendPinViaSMS()
                .setFeePaymentMethod(FeePaymentsMethod.INKASO)
                .setAccountType(accountType)
                .requestFormalControl()
                .assertFormalControlWasSuccessful()
                .continueToUserConfirmation()
                .userConfirmed()
                .continueToProductActivationResult();
    }
}