package cz.moneta.test.dsl.util.data;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.util.data.client.Address;
import cz.moneta.test.dsl.util.data.client.Gender;
import cz.moneta.test.dsl.util.data.client.NonClient;
import cz.moneta.test.dsl.util.data.sb.FourPartToken;
import cz.moneta.test.harness.support.data.Builders;

import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;

import static cz.moneta.test.dsl.util.code.lists.HCisVztahKBanceCIF.EMPLOYEE_MONETA_MONEY_BANK;
import static cz.moneta.test.harness.support.data.GeneratorType.*;

public class Data {

    private final Harness harness;

    public Data(Harness harness) {
        this.harness = harness;
    }

    public NonClient newNonClient() {
        return Builders.newDataBuilder(NonClient.class, harness);
    }

    public NonClient newWomanNonClient() {
        return this.newNonClient()
                .withBirthNumber(harness.generate(RC, Gender.WOMAN))
                .withFirstName(harness.generate(FIRST_NAME, Gender.WOMAN))
                .withLastName(harness.generate(LAST_NAME, Gender.WOMAN));
    }

    public NonClient newFVNonClient() {
        return this.newNonClient()
                // Important - NTB EB -> WEB -> MÍSTO NAROZENÍ 6. Olomouc -> obě hodnoty rámce totožné
                .withPlaceOfBirth("Olomouc")
                // Important - POS (pobočkový proces) -> na CIFu FOP je třeba zadat e-mail schváleno -> dummy.a1a2a3a4a5a6@post.cz
                .withEmail("dummy.a1a2a3a4a5a6@moneta.cz")
                .withWageDeductions(0)
                .withIncomeSources("1")
                .withPassportId("39729636")
                .withPassportExpiryDateRaw(Date.from(LocalDate
                        .of(2022, 7, 14)
                        .atStartOfDay()
                        .atZone(ZoneId.systemDefault())
                        .toInstant()))
                .withDriverLicenceId("EK 608907")
                .withOccupationAdditionalInformation("manager/ředitel")
                .withDriveLicenceExpiryDateRaw(Date.from(LocalDate
                        .of(2026, 8, 31)
                        .atStartOfDay()
                        .atZone(ZoneId.systemDefault())
                        .toInstant()))
                // Important - IB -> v Ufo bance  na CIFu FOP je potřeba nastavit v adrese číslo orientační - Schváleno -> 1111
                .withResidencyAddress(Address.builder()
                        .street("Za poštou")
                        .descriptiveNumber("405")
                        .orientationNumber("1111")
                        .city("Olomouc")
                        .zip("77900")
                        .build());
    }

    public NonClient newFVNonClientEmployee() {
        return this.newFVNonClient()
            // Important - Client is MMB Employee
            .withRelationshipToTheBank(EMPLOYEE_MONETA_MONEY_BANK);
    }

    public FourPartToken fourPartToken(String token) {
        return Builders.newDataBuilder(FourPartToken.class, harness).withToken(token);
    }

    public Payment defaultPayment() {
        return Builders.newDataBuilder(Payment.class, harness);
    }


}
