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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.ib.account.current.CurrentAccountPage;
import cz.moneta.test.dsl.ib.accountsandtransactions.paymentawaitingsignature.PaymentsAwaitingSignatureConfirmationPage;

import java.util.function.Function;

public class PaymentsIbTasks {
    private final Harness harness;

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

    public Function<CurrentAccountPage, CurrentAccountPage> preparePaymentToSignatureFromActiveDisponent(String fromAccount, String toAccountNumber, String toAccountBank, String amount) {
        return start -> start.clickNewDomesticPaymentOrder()
                .clickFromAccountSelect()
                .selectFromAccountByName(fromAccount)
                .fillToAccountNumber(toAccountNumber)
                .fillToAccountBank(toAccountBank)
                .fillAmount(amount)
                .clickStandardPayment()
                .clickContinueButton()
                .clickSaveToSign()
                .clickAccountsAndTransactions();
    }

    public Function<CurrentAccountPage, CurrentAccountPage> preparePaymentToSignatureFromPasiveDisponent(String fromAccount, String toAccountNumber, String toAccountBank, String amount) {
        return start -> start.clickNewDomesticPaymentOrder()
                .clickFromAccountSelect()
                .selectFromAccountByName(fromAccount)
                .fillToAccountNumber(toAccountNumber)
                .fillToAccountBank(toAccountBank)
                .fillAmount(amount)
                .clickContinueButton()
                .clickSaveToSign()
                .clickAccountsAndTransactions();
    }

    public Function<CurrentAccountPage, PaymentsAwaitingSignatureConfirmationPage> rejectPaymentForSignature(String authorPayment) {
        return start -> start.clickPaymentsWaitingForSignature()
                .selectAuthorPaymentAndClickShowButton(authorPayment)
                .selectFirstPayment()
                .clickRejectSelectedButton()
                .clickRejectSelectedButton();
    }
}
