"""Event definitions for the merchant_onboarding domain — PRD-HWONB-001 §7.4."""

from typing import List, Dict

ONBOARDING_EVENTS: List[Dict] = [
    {
        "event_id": "onboarding.transmitted",
        "event_name": "Onboarding Application Transmitted",
        "description": (
            "Emitted after POST /onboarding/transmit succeeds — the "
            "application has been queued for Global Payments underwriting. "
            "Consumed by the onboarding listener to send the "
            "'onboarding_submitted' email exactly once."
        ),
        "topic": "payment_events_onboarding",
        "emitted_by": "merchant_onboarding/services.py (transmit)",
        "consumed_by": ["merchant_onboarding/listener.py"],
        "data_contract": {
            "application_id": "int — internal PK of MerchantOnboardingApplication",
            "merchant_id": "int",
            "tsys_app_id": "int",
        },
    },
    {
        "event_id": "onboarding.approved",
        "event_name": "Onboarding Application Approved",
        "description": (
            "Emitted when the nightly poll (or a manual status refresh) "
            "confirms Global Payments approved the application and issued "
            "a MID. Consumed by the onboarding listener to provision TransIT "
            "credentials, flip merchants.is_onboarded=True, and send the "
            "'onboarding_approved' email exactly once."
        ),
        "topic": "payment_events_onboarding",
        "emitted_by": "merchant_onboarding/services.py (refresh_status) / tasks/poll_status.py",
        "consumed_by": ["merchant_onboarding/listener.py"],
        "data_contract": {
            "application_id": "int",
            "merchant_id": "int",
            "tsys_app_id": "int",
            "tsys_mid": "str",
        },
    },
    {
        "event_id": "onboarding.rejected",
        "event_name": "Onboarding Application Rejected",
        "description": (
            "Emitted when the nightly poll (or a manual status refresh) "
            "confirms Global Payments rejected the application. Consumed "
            "by the onboarding listener to send the 'onboarding_rejected' "
            "email exactly once and notify HubWallet admins."
        ),
        "topic": "payment_events_onboarding",
        "emitted_by": "merchant_onboarding/services.py (refresh_status) / tasks/poll_status.py",
        "consumed_by": ["merchant_onboarding/listener.py"],
        "data_contract": {
            "application_id": "int",
            "merchant_id": "int",
            "tsys_app_id": "int",
            "reason": "str | None — raw GP decision detail, if any",
        },
    },
]
