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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ufo.operations.client.clientDetail.STS701_S002_ClientDetailPage;
import cz.moneta.test.dsl.ufo.operations.search.OPS001_S001_ClientSearchPageUfoOperations;
import cz.moneta.test.dsl.ufo.operations.ufoOperations.PLK708_S001_DataChangesPage;
import cz.moneta.test.dsl.util.data.client.Address;

import java.util.function.Function;

public class DebitCardChangesTasks {

    private final Harness harness;

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

    public Function<OPS001_S001_ClientSearchPageUfoOperations, STS701_S002_ClientDetailPage> searchClientAndCheckNumberofCard(String rc) {
        return start -> start.fillSearchInput(rc)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickDebitCard()
                .selectPickNewDebitCardCombobox(1)
                .checkNumberOfCard();
    }

    public Function<STS701_S002_ClientDetailPage, STS701_S002_ClientDetailPage> stepsToTurnOnInternetPayments() {
        return start -> start.clickTransactionsSettings()
                .clickInternetTransactionsOn()
                .clickSaveSettings()
                .checkPaymentsThroughMotoInternet("Zapnuto - vše")
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDateInRequirement();
    }

    public Function<STS701_S002_ClientDetailPage, STS701_S002_ClientDetailPage> stepsToTurnOffInternetPayments() {
        return start -> start.clickDebitCard()
                .clickTransactionsSettings()
                .clickInternetTransactionsOff()
                .clickSaveSettings()
                .checkPaymentsThroughMotoInternet("Vypnuto - vše")
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDateInRequirement();
    }

    public Function<PLK708_S001_DataChangesPage, STS701_S002_ClientDetailPage> setSendingAddressAndCheckChange(Address address, String postOffice, String requirementFirstRowText) {
        return start -> start.selectAddressForSending("Adresa OM")
                .selectOMAddressForSending(address.getCity().toUpperCase() + " - " + address.getStreet() + " " + address.getDescriptiveNumber())
                .checkStreetInput(address.getStreet())
                .checkVillageInput(address.getCity())
                .checkPostalCodeInput(address.getZip())
                .checkDescriptiveNumberInput(address.getDescriptiveNumber())
                .checkPostOfficeInput(postOffice)
                .clickSaveButton()
                .checkDebitCardSendingAddressStreetLabel(address.getStreet() + " " + address.getDescriptiveNumber())
                .clickDemand()
                .clickRefreshRequirementButton()
                .checkDateInRequirement()
                .checkDemandDescriptionFirstRow(requirementFirstRowText);
    }
}