package cz.moneta.test.dsl.hypos.tasks;

import cz.moneta.test.dsl.Harness;
import cz.moneta.test.dsl.hypos.enums.HyposLogType;
import cz.moneta.test.dsl.util.data.client.Address;
import cz.moneta.test.harness.support.data.GeneratorType;

public class HyposCommonTasks {
    private final Harness harness;

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

    public String getFullAddress(Address address) {
        String fullAddress;
        if (address.getOrientationNumber().equals("")) {
            fullAddress = String.format("%s %s, %s %s",
                    address.getStreet(),
                    address.getDescriptiveNumber(),
                    address.getZip(),
                    address.getCity());
        } else {
            fullAddress = String.format("%s %s/%s, %s %s",
                    address.getStreet(),
                    address.getDescriptiveNumber(),
                    address.getOrientationNumber(),
                    address.getZip(),
                    address.getCity());
        }
        return fullAddress;
    }

    public String getAddressWhisper(Address address) {
        return address.getStreet() + " " + address.getDescriptiveNumber() + ", " + address.getCity() + " " + address.getZip();
    }

    public String getMobilePhoneNumber() {
        return "420" + harness.generate(GeneratorType.MOBILE_PHONE_NUMBER);
    }

    public void hyposLog(HyposLogType hyposLogType, String hyposLog) {
        harness.log("HyposLog - {}: {}", hyposLogType.getValue(), hyposLog);
    }
}