package cz.moneta.test.dsl.kasanova.components;

import cz.moneta.test.dsl.kasanova.KSNPageFlow;
import cz.moneta.test.dsl.kasanova.KSNUtils;
import cz.moneta.test.dsl.kasanova.components.enums.KSNAdress;
import cz.moneta.test.dsl.kasanova.components.enums.KSNBirthPlaces;
import cz.moneta.test.dsl.kasanova.components.enums.KSNCountries;
import cz.moneta.test.dsl.kasanova.components.enums.KSNDescriptions;
import cz.moneta.test.dsl.kasanova.components.enums.KSNGender;
import cz.moneta.test.dsl.kasanova.components.enums.KSNIdCards;
import cz.moneta.test.dsl.kasanova.components.enums.KSNNames;
import cz.moneta.test.dsl.kasanova.components.enums.KSNNumberGenerator;
import cz.moneta.test.dsl.kasanova.components.enums.KSNPatterns;
import cz.moneta.test.dsl.util.DateUtils;
import cz.moneta.test.harness.endpoints.WebEndpoint;
import cz.moneta.test.harness.endpoints.kasanova.KasanovaEndpoint;
import cz.moneta.test.harness.support.web.CustomAction;

public interface KSN19Page extends KSNPageFlow<KSN19Page>, KSNUtils<KSN19Page> {

    default void loadPage(WebEndpoint endpoint) {
        KSNPageFlow.loadLocalPage(endpoint, DEPOSIT_AMOUNT_INPUT);
    }

    @CustomAction
    default KSN19Page fillIdentificationAndSymbolsFunc19Short() {
        KasanovaEndpoint endpoint = getEndpoint(KasanovaEndpoint.class);
        endpoint.type(() -> IDENTIFICATION_CLIENT_NAME_INPUT, KSNNames.getRandomNameValue(), true);
        endpoint.type(() -> IDENTIFICATION_PERSONAL_NUMBER_INPUT, DateUtils.getRandomDate(1940, 2000, KSNPatterns.DD_MM_YYYY.getValue()), false);
        endpoint.selectByVisibleText(IDENTIFICATION_SEX_SELECT, KSNGender.getRandomGenderValue());
        endpoint.selectByVisibleText(IDENTIFICATION_PERSONAL_NUMBER_TYPE_SELECT, KSNIdCards.getRandomIdCardValue());
        endpoint.type(() -> IDENTIFICATION_ID_NUMBER_INPUT, KSNNumberGenerator.getRandomNumberValue(), false);
        endpoint.selectByVisibleText(IDENTIFICATION_NATIONALITY_SELECT, KSNCountries.getRandomCountryValue());
        endpoint.type(() -> IDENTIFICATION_ADDRESS_INPUT, KSNAdress.getRandomAdressValue(), false);
        endpoint.type(() -> DESCRIPTION_INPUT, KSNDescriptions.getRandomDescriptionValue(), false);
        endpoint.type(() -> AGREEMENT_NUMBER_INPUT, "6123456304", false);
        endpoint.type(() -> CONSTANT_SYMBOL_INPUT, KSNNumberGenerator.getRandomNumberValue(), false);
        endpoint.type(() -> SPECIFIC_SYMBOL_INPUT, KSNNumberGenerator.getRandomNumberValue(), false);
        return null;
    }

    @CustomAction
    default KSN19Page fillIdentificationAndSymbolsFunc19Long() {
        KasanovaEndpoint endpoint = getEndpoint(KasanovaEndpoint.class);
        endpoint.type(() -> IDENTIFICATION_CLIENT_NAME_INPUT, KSNNames.getRandomNameValue(), true);
        endpoint.type(() -> IDENTIFICATION_PERSONAL_NUMBER_INPUT, DateUtils.getRandomDate(1940, 2000, KSNPatterns.DD_MM_YYYY.getValue()), false);
        endpoint.selectByVisibleText(IDENTIFICATION_SEX_SELECT, KSNGender.getRandomGenderValue());
        endpoint.selectByVisibleText(IDENTIFICATION_PERSONAL_NUMBER_TYPE_SELECT, KSNIdCards.getRandomIdCardValue());
        endpoint.type(() -> IDENTIFICATION_ID_NUMBER_INPUT, KSNNumberGenerator.getRandomNumberValue(), false);
        endpoint.type(() -> IDENTIFICATION_ID_END_DATE_INPUT, DateUtils.getRandomDate(YEAR_ONE.getYear(), YEAR_MORE.getYear(), KSNPatterns.DDMMYYYY.getValue()), true);
        String coutry = KSNCountries.getRandomCountryValue();
        endpoint.selectByVisibleText(IDENTIFICATION_COUNTRY_ID_SELECT, coutry);
        endpoint.selectByVisibleText(IDENTIFICATION_LONG_TERM_RESIDENCE_SELECT, coutry);
        endpoint.selectByVisibleText(IDENTIFICATION_NATIONALITY_SELECT, coutry);
        endpoint.type(() -> IDENTIFICATION_BIRTH_PLACE_INPUT, KSNBirthPlaces.getRandomBirthPlaceValue(), true);
        endpoint.type(() -> IDENTIFICATION_ADDRESS_INPUT, KSNAdress.getRandomAdressValue(), true);
        endpoint.type(() -> DESCRIPTION_INPUT, KSNDescriptions.getRandomDescriptionValue(), false);
        endpoint.type(() -> AGREEMENT_NUMBER_INPUT, "6123456304", false);
        endpoint.type(() -> CONSTANT_SYMBOL_INPUT, KSNNumberGenerator.getRandomNumberValue(), false);
        endpoint.type(() -> SPECIFIC_SYMBOL_INPUT, KSNNumberGenerator.getRandomNumberValue(), false);
        return null;
    }

}