package cz.moneta.test.dsl.util;

import org.apache.commons.text.WordUtils;

import java.util.LinkedHashMap;
import java.util.stream.Collectors;

public class BankaUtils {

    private BankaUtils() {
    }

    public static String formatBankerName(String bankerName) {
        return bankerName.contains("HARNESS TEST") ? "GEBTHA" + bankerName.charAt(bankerName.length() - 1) : WordUtils.capitalizeFully(bankerName);
    }

    public static String formatUserNameForVerification(String userName) {
        return userName.contains("HARNESS TEST") ? "GEBTHA" + userName.charAt(userName.length() - 1) + " / HARNESS TEST" : WordUtils.capitalize(userName.toLowerCase());
    }

    public static String formatSecondBankerName(String bankerName) {
        if (!bankerName.contains("GEBTHA")) {
            return formatBankerName(bankerName);
        } else return bankerName;
    }

    public static String formatDocumentUrls(LinkedHashMap<String, String> docUrls) {
        return docUrls == null ? "null" : docUrls.values().stream()
                .collect(Collectors.joining("\n"));
    }

    public static String formatDocumentUrlsWithNames(LinkedHashMap<String, String> docUrls) {
        return docUrls == null ? "null" : docUrls.keySet().stream()
                .map(key -> key + ": " + docUrls.get(key))
                .collect(Collectors.joining("\n"));
    }
}