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

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

public interface PaymentEngineCreateXctFI2FIPayment extends WebFlow<PaymentEngineCreateXctFI2FIPayment> {
    String INVALID_ICON = "//ancestor::div[@class='x-form-field-wrap']//following-sibling::div";
    String AMOUNT = "//input[@name = 'amount']";
    String CURRENCY = "//input[@name = 'curr']/following-sibling::input";
    String INVALID_CURRENCY = CURRENCY + INVALID_ICON;
    String TRX_REFERENCE = "//input[@name = 'txRef']";
    String PREVIOUS_REFERENCE = "//input[@name = 'rTxRef']";
    String BICFI = "//input[@name = 'cpBicfi']";
    String BIC_BANK = "//input[@name = 'cpBankBic']";
    String BANK_CODE = "//input[@name = 'cpClrsysMmbid']";
    String CREDITOR_NAME = "//input[@name = 'cpName']";
    String CLEARING_PARTNER = "//input[@name = 'clpId']/following-sibling::input";
    String INVALID_CLEARING_PARTNER = CLEARING_PARTNER + INVALID_ICON;
    String MESSAGE = "//textArea[@name = 'cpAgentInstr']";
    String DEBTOR_ACCOUNT_PANEL = "//input[@name = 'orAccIdent']/following-sibling::img";
    String ACCOUNT_INPUT = "//input[@name = 'accIdent']";
    String SEARCH = "//button[text() = 'Hledat']";
    String SELECT = "//div[@class = 'x-grid3-row-checker']";
    String OK_BUTTON = "//div[@class='x-window-body x-border-layout-ct']//button[text() = 'OK']";
    String ACCEPT_BUTTON = "//div[@class='x-plain-bwrap']//button[text() = 'OK']";
    String NO_BUTTON = "//button[text()='Ne']";
    String TRANSACTION_ID_KEY = "TRANSACTION_ID_KEY";
    String TRANSACTION_ID_XPATH = "//div[@class = 'ext-mb-content']/span[@class = 'ext-mb-text']";

    @TypeIntos({@TypeInto(AMOUNT), @TypeInto(value = CURRENCY, andWait = @Wait(value = INVALID_CURRENCY, until = Until.GONE)),
            @TypeInto(TRX_REFERENCE), @TypeInto(PREVIOUS_REFERENCE), @TypeInto(BICFI), @TypeInto(BIC_BANK), @TypeInto(CREDITOR_NAME),
            @TypeInto(value = CLEARING_PARTNER, andWait = @Wait(value = INVALID_CLEARING_PARTNER, until = Until.GONE)), @TypeInto(MESSAGE)})
    PaymentEngineCreateXctFI2FIPayment fillMandatoryData(String amount, String currency, String trxReference,
                                                         String previousReference, String bicFi, String bicBank,
                                                         String creditorName, String clearingPartner, String message);

    @TypeInto(BANK_CODE)
    PaymentEngineCreateXctFI2FIPayment fillBankCode(String bankCode);

    @Click(value = DEBTOR_ACCOUNT_PANEL, andWait = @Wait(value = ACCOUNT_INPUT, until = Until.VISIBLE))
    PaymentEngineCreateXctFI2FIPayment clickOnDebtorPanel();

    @TypeInto(ACCOUNT_INPUT)
    @Click(value = SEARCH, andWait = @Wait(value = SELECT, until = Until.VISIBLE))
    PaymentEngineCreateXctFI2FIPayment searchDebtorAccount(String debtorAcc);

    @Click(value = SELECT, andWait = @Wait(value = OK_BUTTON, until = Until.CLICKABLE))
    PaymentEngineCreateXctFI2FIPayment selectDebtorAccount();

    @Click(value = OK_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.GONE))
    PaymentEngineCreateXctFI2FIPayment acceptDebtorAccount();

    @Click(value = ACCEPT_BUTTON, andWait = @Wait(value = NO_BUTTON, until = Until.VISIBLE))
    PaymentEngineCreateXctFI2FIPayment clickAccept();

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

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