"""Event definitions for the payment_requests domain."""

from typing import List, Dict

PAYMENT_REQUEST_EVENTS: List[Dict] = [
    {
        "event_id": "payment_request.created",
        "event_name": "Payment Request Created",
        "description": (
            "Emitted when a new payment request is created.  Consumed by "
            "the transactions listener to submit the initial charge to the "
            "active payment provider."
        ),
        "topic": "payment_events_payment_requests",
        "emitted_by": "payment_requests/services.py",
        "consumed_by": ["transactions/listener.py"],
        "data_contract": {
            "payment_request_id": "int",
            "merchant_id": "int",
            "amount": "float",
            "currency": "str",
            "payment_method_token": "str",
            "payment_method_type": "str",
            "customer_id": "int",
            "correlation_id": "str | None",
        },
    },
    {
        "event_id": "payment_request.updated",
        "event_name": "Payment Request Updated",
        "description": (
            "Emitted when a payment request's details are changed.  "
            "No downstream consumers at this time."
        ),
        "topic": "payment_events_payment_requests",
        "emitted_by": "payment_requests/services.py",
        "consumed_by": [],
        "data_contract": {
            "payment_request_id": "int",
            "merchant_id": "int",
            "changed_fields": "dict — map of field_name → new_value",
        },
    },
    {
        "event_id": "payment_request.cancelled",
        "event_name": "Payment Request Cancelled",
        "description": (
            "Emitted when a payment request is cancelled.  Consumed by "
            "the transactions listener to void any in-flight charge."
        ),
        "topic": "payment_events_payment_requests",
        "emitted_by": "payment_requests/services.py",
        "consumed_by": ["transactions/listener.py"],
        "data_contract": {
            "payment_request_id": "int",
            "merchant_id": "int",
            "reason": "str | None — optional cancellation reason",
        },
    },
    {
        "event_id": "payment_request.authorized",
        "event_name": "Payment Request Authorized",
        "description": (
            "Emitted after a customer completes HPP payment and an "
            "authorization record is created.  Consumed by the "
            "payment_requests listener to notify the merchant."
        ),
        "topic": "payment_events_payment_requests",
        "emitted_by": "hpp/router.py",
        "consumed_by": ["payment_requests/listener.py"],
        "data_contract": {
            "payment_request_id": "int",
            "merchant_id": "int",
            "authorization_id": "int",
            "transaction_id": "int",
        },
    },
]
