from sqlalchemy import (
    Column,
    Integer,
    String,
    JSON,
    TIMESTAMP,
)
from backend.app.db.base import Base


class EpcStore(Base):
    """
    Stores EPC data retrieved from the EPC API and EPC web pages.
    """
    __tablename__ = "epc_store"

    id = Column(Integer, primary_key=True, autoincrement=True)
    uprn = Column(Integer)
    epc_api_created_at = Column(TIMESTAMP(timezone=False))
    epc_api = Column(JSON, nullable=False)
    epc_page_created_at = Column(TIMESTAMP(timezone=False))
    epc_page = Column(String)
    epc_page_rrn = Column(String)

    def __repr__(self):
        return f"<EpcStore(id={self.id}, uprn='{self.uprn}')>"
