package com.centreproject.common.enums;

import lombok.Getter;

/**
 * Data source system enumeration
 * @author zhonglei.xu
 */
@Getter
public enum DataSourceSystem {

    // Core business systems
    OMNI("Omni", "OMNI"),
    YA_BACKEND("YA backend", "YA_BACKEND"),
    TRAVEL_BOX("Travel Box", "TRAVEL_BOX"),
    MARKET_PLACE("Market place", "MARKET_PLACE"),
    CRM("CRM", "CRM"),
    SHAREPOINT("sharepoint", "SHAREPOINT"),
    POWER_BI("PowerBI", "POWER_BI"),

    // Third-party services
    EMARSYS("Emarsys", "EMARSYS"),
    SPRINKLR("sprinklr", "SPRINKLR"),
    QUESTION_PRO("QuestionPro", "QUESTION_PRO"),
    PAYFORT("Payfort", "PAYFORT"),
    SENSE_TIME("SenseTime", "SENSE_TIME"),
    FLIPPING_BOOK_API("flipping book API", "FLIPPING_BOOK_API"),

    // Composite systems
    GENESYS_SPRINKLR_OUTLOOK("Genesys/Sprinklr/Outlook (5% B2B)", "GENESYS_SPRINKLR_OUTLOOK"),
    PAYFORT_MANUAL_MULTI_CHANNEL("Payfort/manual/multi channel", "PAYFORT_MANUAL_MULTI_CHANNEL"),
    OMNI_TUNNEL_TRAVEL_BOX("Omni / Tunnel 3/Travel Box(end this year)", "OMNI_TUNNEL_TRAVEL_BOX"),
    OMNI_SCV("Omni/SCV", "OMNI_SCV"),

    // Special cases
    MANUALLY("Manually", "MANUALLY"),
    REVENUE_GOOGLE_ANALYTICS("revenue from google analytics", "REVENUE_GA");

    private final String displayName;
    private final String code;

    DataSourceSystem(String displayName, String code) {
        this.displayName = displayName;
        this.code = code;
    }

    /**
     * Get enum by display name (case-insensitive)
     */
    public static DataSourceSystem getByDisplayName(String displayName) {
        if (displayName == null) {
            return null;
        }
        for (DataSourceSystem system : values()) {
            if (system.displayName.equalsIgnoreCase(displayName.trim())) {
                return system;
            }
        }
        return null;
    }

    /**
     * Get enum by code (case-sensitive)
     */
    public static DataSourceSystem getByCode(String code) {
        if (code == null) {
            return null;
        }
        for (DataSourceSystem system : values()) {
            if (system.code.equals(code)) {
                return system;
            }
        }
        return null;
    }
}