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

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

public interface PaymentEngineCreateAuthorizationForDirectDebit extends WebFlow<PaymentEngineCreateAuthorizationForDirectDebit> {
    String PERIOD_TYPE = "//input[@name = 'periodType']//following-sibling::input";
    String PERIOD_TYPE_NOT_EMPTY = "//input[@name = 'periodType' and not(@value='')]";
    String REMARK = "//input[@name = 'remark']";
    String PERIOD_MAX_AMOUNT = "//input[@name = 'periodMaxAmount']";
    String ACCOUNT = "//input[@name = 'accIdent']";
    String DEBTOR_ACC_BUTTON = "//input[@name= 'dbtrAccIdent']//following-sibling::img";
    String CREDITOR_ACC_BUTTON = "//input[@name= 'cdtrAccIdent']//following-sibling::img";
    String SEARCH_BY_ACCOUNT = "//button[text() = 'Hledat']";
    String OK_BUTTON = "//button[text() = 'OK']";
    String OK_BUTTON_IN_THE_WINDOW = "//div[contains(@class, 'x-window-bwrap')]//button[text() = 'OK']";
    String SELECT_ACCOUNT = "//div[contains(@class,'x-grid3-row')]//div[@class='x-grid3-cell-inner x-grid3-col-5'][text() = '%s']";
    String VARIABLE_SYMBOL = "//input[@name='variableSymbol']";
    String SPECIFIC_SYMBOL = "//input[@name='specificSymbol']";
    String NAME = "//input[@name='name']";
    String BRANCH_CODE = "//input[@type='text' and @name='gembOrBranchCode']";

    @Click(DEBTOR_ACC_BUTTON)
    PaymentEngineCreateAuthorizationForDirectDebit clickOnDebtor();

    @Click(CREDITOR_ACC_BUTTON)
    PaymentEngineCreateAuthorizationForDirectDebit clickOnCreditor();

    @Click(SEARCH_BY_ACCOUNT)
    PaymentEngineCreateAuthorizationForDirectDebit clickSearchByAccount();

    @Wait(explicitWaitSeconds = 1)
    @Click(value = OK_BUTTON, andWait = @Wait(value = OK_BUTTON, until = Until.GONE))
    PaymentEngineCreateAuthorizationForDirectDebit clickOk();

    @Click(value = SELECT_ACCOUNT, isStringDynamicXpath = true, andWait = @Wait(explicitWaitSeconds = 1))
    PaymentEngineCreateAuthorizationForDirectDebit selectAccount(String account);

    @Click(OK_BUTTON_IN_THE_WINDOW)
    PaymentEngineCreateAuthorizationForDirectDebit clickOkInTheWindow();

    @TypeIntos({@TypeInto(NAME), @TypeInto(BRANCH_CODE), @TypeInto(REMARK), @TypeInto(VARIABLE_SYMBOL), @TypeInto(SPECIFIC_SYMBOL), @TypeInto(PERIOD_MAX_AMOUNT)})
    PaymentEngineCreateAuthorizationForDirectDebit fillManualDataForDirectDebitWithoutDebtor(String name, String branchCode, String remark, String variableSymbol, String specificSymbol, String periodMaxAmount);

    @TypeInto(PERIOD_TYPE)
    @KeyPress(value = Key.TAB, andWait = @Wait(value = PERIOD_TYPE_NOT_EMPTY, until = Until.PRESENT_IN_DOM))
    PaymentEngineCreateAuthorizationForDirectDebit fillPeriodType(String periodType);

    @TypeInto(ACCOUNT)
    PaymentEngineCreateAuthorizationForDirectDebit fillAccount(String account);
}