package cz.moneta.test.regression.backoffice.callcenter.jenkinstests.ccretail.cczakladbanka;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.credentials.Keys;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.dsl.util.task.ufo.operations.OperationsTasks;
import cz.moneta.test.harness.annotations.JiraTestCase;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
import cz.moneta.test.harness.support.auth.Credentials;
import cz.moneta.test.harness.support.auth.Key;
import org.junit.jupiter.api.BeforeAll;

import static cz.moneta.test.harness.annotations.Environment.PPE;
import static cz.moneta.test.harness.annotations.Environment.TST1;


@TestScenario(name = "Create new meetings and sms")
public class CreateMeetingsAndSms {

    private NonClient nonClient;
    private OperationsTasks operationsTasks;
    private String rcOfExistingClient;

    @BeforeAll
    public void getInfo(Harness harness) {
        operationsTasks = harness.tasks().ufo().operations();
        nonClient = harness.data().newNonClient()
                .withMobileNumber(harness.getSystemOrConfigValue("cc.client.phone-number"))
                .withEmail(harness.getSystemOrConfigValue("cc.client.email"));
        rcOfExistingClient = harness.getSystemOrConfigValue("cc.client.rc");
    }

    @TestCase(name = "Create meeting for nonClient-Prodej", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2044")
    public void createMeetingAndSMSForNonClient_Sell(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .clickMeetingsAndSms()
                .typeName(nonClient.fullName())
                .typePhoneNumber(nonClient.mobileNumber())
                .clickSendEmailCheckbox()
                .typeEmail(nonClient.email())
                .selectOM("HRADEC KRÁLOVÉ - OC ATRIUM - Dukelská třída 1713/7")
                .setMeetingType("Prodej")
                .setProduct("Flexikredit")
                .clickCalendar()
                .clickNextMonth()
                .clickAvailableDayInCalendar()
                .selectTime(2)
                .typeValue("100000")
                .typeInterestRate("6,5")
                .clickNotes()
                .clickFirstTaxReturnDocument()
                .clickBirthCertificateDocument()
                .clickCreditCardDocument()
                .clickSendWithoutRCCheck();
    }

    @TestCase(name = "Create meeting for nonClient-Servis", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2045")
    public void createMeetingAndSMSForNonClient_Servis(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .clickMeetingsAndSms()
                .typeName(nonClient.fullName())
                .typePhoneNumber(nonClient.mobileNumber())
                .clickSendEmailCheckbox()
                .typeEmail(nonClient.email())
                .selectOM("KLATOVY - Rybníčky 812")
                .setMeetingType("Servis")
                .clickCalendar()
                .clickNextMonth()
                .clickAvailableDayInCalendar()
                .selectTime(2)
                .clickNotes()
                .typeIntoNotes("test-servis")
                .clickDrivingLicenseDocument()
                .clickIDCardDocument()
                .clickSendWithoutRCCheck();
    }

    @TestCase(name = "Create meeting for nonClient-Retence", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2046")
    public void createMeetingAndSMSForNonClient_Retence(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .clickMeetingsAndSms()
                .typeName(nonClient.fullName())
                .typePhoneNumber(nonClient.mobileNumber())
                .clickSendEmailCheckbox()
                .typeEmail(nonClient.email())
                .selectOM("PARDUBICE I - náměstí Republiky 2686")
                .setMeetingType("Retence")
                .clickCalendar()
                .clickNextMonth()
                .clickAvailableDayInCalendar()
                .selectTime(2)
                .typeValue("1180000")
                .typeInterestRate("10,5")
                .clickNotes()
                .typeIntoNotes("Test-Retence")
                .clickConfirmationOfIncomeDocument()
                .clickDrivingLicenseDocument()
                .clickLoanAgreementsDocument()
                .clickSendWithoutRCCheck();
    }

    @TestCase(name = "Create meeting for Client-Prodej", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2041")
    public void createMeetingAndSMSForClient_Sell(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickMeetingsAndSms()
                .typePhoneNumber(nonClient.mobileNumber())
                .clickSendEmailCheckbox()
                .selectOM("TÁBOR - Palackého 357/5")
                .setMeetingType("Prodej")
                .setProduct("Platební karta")
                .clickCalendar()
                .clickNextMonth()
                .clickAvailableDayInCalendar()
                .selectTime(2)
                .typeValue("100000")
                .typeInterestRate("6,5")
                .clickNotes()
                .clickFirstTaxReturnDocument()
                .clickBirthCertificateDocument()
                .clickCreditCardDocument()
                .clickSend();

    }

    @TestCase(name = "Create meeting for Client-Retence", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2043")
    public void createMeetingAndSMSForClient_Retence(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickMeetingsAndSms()
                .typePhoneNumber(nonClient.mobileNumber())
                .clickSendEmailCheckbox()
                .selectOM("VYŠKOV - Husova 111/1")
                .setMeetingType("Retence")
                .clickCalendar()
                .clickNextMonth()
                .clickAvailableDayInCalendar()
                .selectTime(2)
                .typeValue("1180000")
                .typeInterestRate("10,5")
                .clickNotes()
                .typeIntoNotes("Test-Retence")
                .clickLoanAgreementsDocument()
                .clickSend();
    }

    @TestCase(name = "Create meeting for Client-Servis", environments = {PPE, TST1})
    @JiraTestCase(id = "CC-T2042")
    public void createMeetingAndSMSForClient_Servis(Harness harness, @Key(Keys.ufo.banka.banker) Credentials credentials) {

        harness.withUfo()
                .openLoginPage()
                .then(operationsTasks.login().withCredentials(credentials))
                .fillSearchInput(rcOfExistingClient)
                .clickSearchClient()
                .onClientDetailsPage()
                .clickMeetingsAndSms()
                .typePhoneNumber(nonClient.mobileNumber())
                .clickSendEmailCheckbox()
                .selectOM("SEDLČANY - nám. T. G. Masaryka 34")
                .setMeetingType("Servis")
                .clickCalendar()
                .clickNextMonth()
                .clickAvailableDayInCalendar()
                .selectTime(2)
                .typeIntoNotes("test-servis")
                .clickIDCardDocument()
                .clickPasportDocument()
                .clickSend();
    }
}