"""Coupang 市場活動 read-only adapter skeleton。"""

from services.market_intel.adapters.base import (
    AdapterSafetyPolicy,
    CampaignSource,
    MarketIntelAdapter,
)


class CoupangMarketAdapter(MarketIntelAdapter):
    platform_code = "coupang"
    platform_name = "Coupang 酷澎"
    base_url = "https://www.tw.coupang.com"
    campaign_url_keywords = (
        "tw.coupang.com",
        "/np/",
        "coupangglobal",
        "promotion",
        "event",
        "sale",
    )
    campaign_text_keywords = (
        "coupang",
        "酷澎",
        "活動",
        "優惠",
        "折扣",
        "特價",
        "今日精選",
        "火箭",
    )
    safety_policy = AdapterSafetyPolicy(
        request_interval_sec=2.5,
        timeout_sec=25,
        max_pages_per_run=5,
    )

    def campaign_sources(self):
        return (
            CampaignSource(
                source_key="coupang_home",
                name="Coupang 酷澎首頁入口",
                url="https://www.tw.coupang.com/",
                campaign_type="homepage_campaign",
                notes="只保存官方公開首頁入口；正式抓取需另開 feature flag。",
            ),
            CampaignSource(
                source_key="coupang_global",
                name="Coupang 火箭跨境入口",
                url="https://www.tw.coupang.com/np/coupangglobal",
                campaign_type="cross_border_sale",
                notes="先作為跨境/火箭相關活動 discovery 起點，不代表已建立活動。",
            ),
        )
