package cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.support.web.*;

import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction.PaymentEngineCreateInstantPayment.CURRENCY_IS_LOAD_XPATH;
import static cz.moneta.test.dsl.payment_engine.parts_of_menu.menu_transaction.PaymentEngineCreateInstantPayment.OK_BUTTON;

@Wait({OK_BUTTON, CURRENCY_IS_LOAD_XPATH})
public interface PaymentEngineCreateInstantPayment extends WebFlow<PaymentEngineCreateInstantPayment>, StoreAccessor {
    String INVALID_ICON = "//ancestor::div[@class='x-form-field-wrap']//following-sibling::div";
    String AMOUNT = "//input[@name = 'amount']";
    String DEBTOR_ACC = "//input[@name = 'orAccIdent']";
    String CREDITOR_ACC = "//input[@name = 'cpAccIdentNum']";
    String ACC_PREFIX = "//input[@name = 'cpAccIdentPrefix']";
    String MESSAGE = "//input[@name = 'rmtInfUnstr']";
    String BANK_CODE = "//input[@name = 'cpBankCode']//following-sibling::input";
    String INVALID_BANK_CODE = BANK_CODE + INVALID_ICON;
    String OK_BUTTON = "//*[@type  = 'submit']";
    String TRANSACTION_ID_KEY = "TRANSACTION_ID_KEY";
    String TRANSACTION_ID_XPATH = "//div[@class = 'ext-mb-content']/span[@class = 'ext-mb-text']";
    String NO_BUTTON = "//button[text() = 'Ne']";
    String VARIABLE_SYMBOL = "//input[@name = 'ceeSymbolVs']";
    String SPECIFIC_SYMBOL = "//input[@name = 'ceeSymbolSs']";
    String CONSTANT_SYMBOL = "//input[@name = 'ceeSymbolKs']";
    String CURRENCY_IS_LOAD_XPATH = "//input[@value='CZK']";

    @TypeIntos({@TypeInto(AMOUNT), @TypeInto(MESSAGE), @TypeInto(DEBTOR_ACC), @TypeInto(CREDITOR_ACC),
            @TypeInto(value = BANK_CODE, andWait = @Wait(value = INVALID_BANK_CODE, until = Until.GONE))})
    PaymentEngineCreateInstantPayment fillManualData(String amount, String message, String debtorAcc,
                                                     String creditorAcc, String bankCode);

    @TypeInto(AMOUNT)
    PaymentEngineCreateInstantPayment fillAmount(String amount);

    @TypeInto(MESSAGE)
    PaymentEngineCreateInstantPayment fillMessage(String message);

    @TypeInto(DEBTOR_ACC)
    PaymentEngineCreateInstantPayment fillDebtorAcc(String debtorAcc);

    @TypeInto(CREDITOR_ACC)
    PaymentEngineCreateInstantPayment fillCreditorAcc(String creditorAcc);

    @TypeInto(value = BANK_CODE, andWait = @Wait(value = INVALID_BANK_CODE, until = Until.GONE))
    PaymentEngineCreateInstantPayment fillBankCode(String bankCode);

    @TypeIntos({@TypeInto(AMOUNT), @TypeInto(MESSAGE), @TypeInto(VARIABLE_SYMBOL), @TypeInto(SPECIFIC_SYMBOL), @TypeInto(CONSTANT_SYMBOL),
            @TypeInto(DEBTOR_ACC), @TypeInto(CREDITOR_ACC), @TypeInto(value = BANK_CODE, andWait = @Wait(value = INVALID_BANK_CODE, until = Until.GONE))})
    PaymentEngineCreateInstantPayment fillManualMaxData(String amount, String message, String variableSymbol, String specificSymbol, String constantSymbol, String debtorAcc,
                                                        String creditorAcc, String bankCode);

    @TypeInto(ACC_PREFIX)
    PaymentEngineCreateInstantPayment fillPrefix(String accPrefix);

    @Click(value = OK_BUTTON, andWait = @Wait(value = TRANSACTION_ID_XPATH, until = Until.VISIBLE))
    PaymentEngineCreateInstantPayment clickOk();

    @StoreElementContent(storeKey = TRANSACTION_ID_KEY, value = TRANSACTION_ID_XPATH, by = Lookup.XPATH)
    PaymentEngineCreateInstantPayment storeTransactionId();

    @Click(value = NO_BUTTON, andWait = @Wait(value = NO_BUTTON, until = Until.GONE))
    PaymentEngineCreateInstantPayment clickNo();

    @Wait(explicitWaitSeconds = 3)
    PaymentEngineCreateInstantPayment wait3sec();

}
