package cz.moneta.test.dsl.util.task.auto.smartauto.customer;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.auto.smartauto.CustomerPage;
import cz.moneta.test.dsl.auto.smartauto.shared.CompanyData;
import cz.moneta.test.dsl.auto.smartauto.shared.ContactData;

import java.util.function.Function;

public class ContactTasks {

    private final Harness harness;

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

    public Function<CustomerPage, CustomerPage> fillContactInformation(ContactData contactData) {
        return start -> start
                .typePhoneNumber(contactData.getPhoneNumber())
                .typeEmail(contactData.getEmail())
                .typeBirthplace(contactData.getBirthplace());
    }

    public Function<CustomerPage, CustomerPage> fillCompanyInformation(CompanyData companyData) {
        return start -> start.typeBusinessmanPhoneNumber(companyData.getCompanyPhoneNumber())
                .typeBusinessmanOtherPhoneNumber(companyData.getCompanyOtherPhoneNumber())
                .typeBusinessmanEmail(companyData.getCompanyEmail())
                .clickBusinessmanSilentCompanion();
    }

    public Function<CustomerPage, CustomerPage> fillCompanyInformationFallback(CompanyData companyData) {
        return start -> start.fillCreationDate("09.01.2004")
                .clickRegistryType()
                .chooseRegistryType()
                .clickNoOfEmployees()
                .chooseNoOfEmployees()
                .typeBusinessmanPhoneNumber(companyData.getCompanyPhoneNumber())
                .typeBusinessmanOtherPhoneNumber(companyData.getCompanyOtherPhoneNumber())
                .clickBusinessmanSilentCompanion();
    }

    public Function<CustomerPage, CustomerPage> fillCompanyInformationFallbackAgro(CompanyData companyData) {
        return start -> start.fillCreationDate("09.01.2004")
            .clickRegistryType()
            .chooseRegistryType()
            .clickNoOfEmployees()
            .chooseNoOfEmployees()
            .typeBusinessmanPhoneNumber(companyData.getCompanyPhoneNumber())
            .typeBusinessmanOtherPhoneNumber(companyData.getCompanyOtherPhoneNumber())
            .typeBusinessmanEmail(companyData.getCompanyEmail())
            .clickBusinessmanSilentCompanion();
    }

    public Function<CustomerPage, CustomerPage> fillBusinessmanInformation(CompanyData companyData) {
        return start -> start.typeBusinessmanPhoneNumber(companyData.getCompanyPhoneNumber())
                .typeBusinessmanOtherPhoneNumber(companyData.getCompanyOtherPhoneNumber())
                .typeBusinessmanEmail(companyData.getCompanyEmail())
                .clickBusinessmanSilentCompanion();
    }
}
