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

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.auto.smartauto.OthersPage;
import cz.moneta.test.dsl.auto.smartauto.shared.BankCode;

import java.util.function.Function;

public class AccountTasks {

    private final Harness harness;

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

    public Function<OthersPage, OthersPage> fillBankContact(int accountNumber, BankCode bankCode) {
        return start -> start.typeAccountNumber(accountNumber)
                .typeBankCode(bankCode.getValue())
                .clickBankCode(bankCode);
    }

    public Function<OthersPage, OthersPage> fillOthersPageForC2C(int phoneNumber, int accountNumber, BankCode bankCode, String approvalMessage) {
        return start -> start.typeDealerContactPhoneNumber(phoneNumber)
                .then(fillBankContact(accountNumber, bankCode))
                .typeApprovalMessage(approvalMessage);
    }

    public Function<OthersPage, OthersPage> fillOthersPageForStandard(int phoneNumber, String approvalMessage) {
        return start -> start.typeDealerContactPhoneNumber(phoneNumber)
                .typeApprovalMessage(approvalMessage);
    }

    public Function<OthersPage, OthersPage> fillOthersPageForC2CBussiness(int phoneNumber, int accountNumber, BankCode bankCode, String approvalMessage, String c2cCompanyName, String c2cCompanyIco) {
        return start -> start.typeC2CCompanyName(c2cCompanyName)
                .typeC2CCompanyIco(c2cCompanyIco)
                .then(fillOthersPageForC2C(phoneNumber, accountNumber, bankCode, approvalMessage));
    }

    public Function<OthersPage, OthersPage> fillOthersPageForC2CConsumer(int phoneNumber, int accountNumber, BankCode bankCode, String approvalMessage, String c2cFirstName, String c2cSurname, String c2cBirthDate) {
        return start -> start.clickConsumer()
                .typeC2CFirstName(c2cFirstName)
                .typeC2CSurname(c2cSurname)
                .typeC2CBirthDate(c2cBirthDate)
                .then(fillOthersPageForC2C(phoneNumber, accountNumber, bankCode, approvalMessage));
    }
}
