package cz.moneta.test.dsl.mobile.smartbanking.templates;

import cz.moneta.test.dsl.mobile.smartbanking.SbViewFlow;
import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.smartbanka.SbEndpoint;
import cz.moneta.test.harness.support.web.Click;
import cz.moneta.test.harness.support.web.CustomAction;
import cz.moneta.test.harness.support.web.Lookup;
import cz.moneta.test.harness.support.web.Wait;

@Wait(value = SmartBankingTemplateCompletion.NEW_TEMPLATES, by = Lookup.XPATH)
public interface SmartBankingTemplateCompletion extends SbViewFlow<SmartBankingTemplateCompletion>, StoreAccessor {

    String NEW_TEMPLATES = "//android.widget.TextView[@text = 'Nová šablona']";
    String TEMPLATE_TITLE = "edit_string";
    String TEMPLATE_ACCOUNT_NUMBER = "edit_account_number";
    String TEMPLATE_BANK_CODE = "edit_account_code";
    String TEMPLATE_AMOUNT = "edit_amount";
    String TEMPLATE_VARIABLE_SYMBOL = "edit_template_symbol_variable";
    String TEMPLATE_SPECIFIC_SYMBOL = "edit_template_symbol_specific";
    String TEMPLATE_CONSTANT_SYMBOL = "edit_template_symbol_constant";
    String TEMPLATE_NOTE_FOR_MY = "edit_template_note_for_me";
    String TEMPLATE_NOTE_FOR_RECIPIENT = "edit_template_note_for_receiver";
    String SAVE_TEMPLATE = "btn_template_save";

    @CustomAction
    default SmartBankingTemplateCompletion setTemplate(TemplateFiling templateFiling) {
        SbEndpoint endpoint = getEndpoint(SbEndpoint.class);
        endpoint.type(() -> TEMPLATE_TITLE, templateFiling.getName());
        endpoint.type(() -> TEMPLATE_ACCOUNT_NUMBER, templateFiling.getAccountNumber());
        endpoint.type(() -> TEMPLATE_BANK_CODE, templateFiling.getBankCode());
        endpoint.type(() -> TEMPLATE_AMOUNT, templateFiling.getAmount());
        endpoint.type(() -> TEMPLATE_VARIABLE_SYMBOL, templateFiling.getVariableSymbol());
        endpoint.type(() -> TEMPLATE_SPECIFIC_SYMBOL, templateFiling.getSpecificSymbol());
        endpoint.type(() -> TEMPLATE_CONSTANT_SYMBOL, templateFiling.getConstantSymbol());
        endpoint.type(() -> TEMPLATE_NOTE_FOR_MY, templateFiling.getNoteForMy());
        endpoint.type(() -> TEMPLATE_NOTE_FOR_RECIPIENT, templateFiling.getNoteForRecipient());
        return null;
    }

    @Click(value = SAVE_TEMPLATE)
    SmartBankingTemplateReturn clickOnTemplateCompletion();
}
