/***********************************************************************************************************
 * Name         : ConfigUtils
 * Purpose      : Helper methods to retrieve Config__c values
 **********************************************************************************************************/
public with sharing class ConfigUtils {
    //Withholding tax
    public static final String WITHHOLDING_RATE_RECORD_TYPES = 'WITHHOLDING_RATE_RECORD_TYPES';

    //AWAL
    public static final String AWAL_SECONDARY_APPROVERS = 'AWAL_SECONDARY_APPROVERS';
    public static final String AWAL_CLOSED_WON_EMAIL_RECIPIENTS = 'AWAL_CLOSED_WON_EMAIL_RECIPIENTS';
    public static final String AWAL_CLOSED_WON_EMAIL_SENDER = 'AWAL_CLOSED_WON_EMAIL_SENDER';
    public static final String AWAL_CLOSED_WON_EMAIL_SUBJECT = 'AWAL_CLOSED_WON_EMAIL_SUBJECT';
    public static final String AWAL_CLOSED_WON_EMAIL_BODY = 'AWAL_CLOSED_WON_EMAIL_BODY';

    //AWAL Stage Notifications
    public static final String AWAL_ALERT_FINANCE_SUBJECT = 'AWAL_ALERT_FINANCE_SUBJECT';
    public static final String AWAL_ALERT_FINANCE_RECIPIENTS = 'AWAL_ALERT_FINANCE_RECIPIENTS';
    public static final String AWAL_ALERT_FINANCE_MESSAGE = 'AWAL_ALERT_FINANCE_MESSAGE';
    public static final String AWAL_ALERT_FINANCE_APPROVER_SUBJECT = 'AWAL_ALERT_FINANCE_APPROVER_SUBJECT';
    public static final String AWAL_ALERT_FINANCE_APPROVER_MESSAGE = 'AWAL_ALERT_FINANCE_APPROVER_MESSAGE';
    public static final String AWAL_ALERT_FINANCE_APPROVER_RECIPIENTS = 'AWAL_ALERT_FINANCE_APPROVER_RECIPIENTS';
    public static final String AWAL_ALERT_ANALYSIS_CMPLTD_SUBJECT = 'AWAL_ALERT_ANALYSIS_CMPLTD_SUBJECT';
    public static final String AWAL_ALERT_ANALYSIS_CMPLTD_MESSAGE = 'AWAL_ALERT_ANALYSIS_CMPLTD_MESSAGE';
    public static final String AWAL_ALERT_ANALYSIS_CMPLTD_RECIPIENTS = 'AWAL_ALERT_ANALYSIS_CMPLTD_RECIPIENTS';
    public static final String AWAL_ALERT_APPROVER_SUBJECT = 'AWAL_ALERT_APPROVER_SUBJECT';
    public static final String AWAL_ALERT_APPROVER_RECIPIENTS = 'AWAL_ALERT_APPROVER_RECIPIENTS';
    public static final String AWAL_ALERT_APPROVER_MESSAGE = 'AWAL_ALERT_APPROVER_MESSAGE';
    public static final String AWAL_ALERT_APPROVED_SUBJECT = 'AWAL_ALERT_APPROVED_SUBJECT';
    public static final String AWAL_ALERT_APPROVED_RECIPIENTS = 'AWAL_ALERT_APPROVED_RECIPIENTS';
    public static final String AWAL_ALERT_APPROVED_MESSAGE = 'AWAL_ALERT_APPROVED_MESSAGE';
    public static final String AWAL_ALERT_BA_SUBJECT = 'AWAL_ALERT_BA_SUBJECT';
    public static final String AWAL_ALERT_BA_RECIPIENTS = 'AWAL_ALERT_BA_RECIPIENTS';
    public static final String AWAL_ALERT_BA_MESSAGE = 'AWAL_ALERT_BA_MESSAGE';
    public static final String AWAL_ALERT_CLOSED_LOST_SUBJECT = 'AWAL_ALERT_CLOSED_LOST_SUBJECT';
    public static final String AWAL_ALERT_CLOSED_LOST_RECIPIENTS = 'AWAL_ALERT_CLOSED_LOST_RECIPIENTS';
    public static final String AWAL_ALERT_CLOSED_LOST_MESSAGE = 'AWAL_ALERT_CLOSED_LOST_MESSAGE';

    /**
     * Method Name  : getConfigString
     * Description  : Retrieves a String value
     * @return String setting value
     */
    public static String getConfigString(String key) {
        Config__c config = Config__c.getValues(key);
        return config?.Value__c;
    }

    /**
     * Method Name  : getConfigInt
     * Description  : Retrieves an Integer value
     * @return Integer setting value
     */
    public static Integer getConfigInt(String key) {
        Config__c config = Config__c.getValues(key);
        return Integer.valueOf(config?.Value__c);
    }

    /**
     * Method Name  : getConfigBoolean
     * Description  : Retrieves a Boolean value
     * @return Boolean setting value
     */
    public static Boolean getConfigBoolean(String key) {
        Config__c config = Config__c.getValues(key);
        if (config == null || config.Value__c == null) {
            return false;
        } else {
            return Boolean.valueOf(config.Value__c);
        }
    }

    /**
     * Method Name  : getConfigMultipleStrings
     * Description  : Retrieves a list of values separated by ;
     * @return List<String> setting values
     */
    public static List<String> getConfigMultipleStrings(String key) {
        Config__c config = Config__c.getValues(key);
        return String.isNotBlank(config?.Value__c) ? config.Value__c.split(';') : null;
    }
}
