import os

class Config:

    BANK_CODE_MAPPING = {
        "9": "0015", "12": "0014", "13": "0016", "14": "0009",
        "15": "0005", "16": "0001", "7": "0013", "6": "0002",
        "5": "0007", "17": "0020", "1": "0012", "10": "0017",
        "11": "0018", "2": "0003", "4": "0004",
        "8": "0006", "3": "0021"
    }

    FETCH_QUEUE_URL = "https://142.79.249.123:443/IPKS_Queue_Generation/fetchAllQueue"

    def __init__(self):
        self.db_user = os.getenv("DB_USER", "pacs_db")
        self.db_password = os.getenv("DB_PASSWORD", "pacs_db")
        self.db_dsn = os.getenv("DB_DSN", "ipksprod3.c7q7defafeea.ap-south-1.rds.amazonaws.com:1521/IPKSDB")

        self.poll_interval_minutes = int(os.getenv("POLL_INTERVAL_MINUTES", "60"))
        self.bank_codes = self._parse_bank_codes()

    def _parse_bank_codes(self):
        codes_str = os.getenv(
            "BANK_CODES",
            "0012"
        )
        return [c.strip() for c in codes_str.split(",") if c.strip()]

    def validate(self):
        if not self.db_user or not self.db_password or not self.db_dsn:
            raise RuntimeError("Database configuration missing")
