# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Optional
from datetime import datetime
from typing_extensions import Literal

from .user import User
from .._models import BaseModel
from .delivery import Delivery

__all__ = ["Notification"]


class Notification(BaseModel):
    """A notification sent to a recipient through a notiflow run"""

    id: str
    """Notification ID"""

    created_at: datetime
    """When the notification was created"""

    data: object
    """Template variables passed when running the notiflow"""

    notiflow_id: str
    """ID of the notiflow that generated this notification"""

    notiflow_run_id: str
    """ID of the specific notiflow run"""

    recipient: User
    """A user (recipient) in your project"""

    status: Literal["pending", "processing", "processed", "failed"]
    """Notification processing status:

    - `pending`: Queued for processing
    - `processing`: Currently being processed
    - `processed`: Successfully processed (deliveries created)
    - `failed`: Processing failed
    """

    updated_at: datetime
    """When the notification was last updated"""

    actor: Optional[User] = None
    """A user (recipient) in your project"""

    deliveries: Optional[List[Delivery]] = None
    """Delivery attempts for this notification (when expanded)"""

    notiflow_handle: Optional[str] = None
    """Handle of the notiflow that generated this notification"""

    processed_at: Optional[datetime] = None
    """When the notification was processed"""

    topic: Optional[str] = None
    """Topic name if triggered via topic"""
