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

from typing import Optional
from datetime import datetime
from typing_extensions import Literal

from .user import User
from .._models import BaseModel

__all__ = ["Delivery"]


class Delivery(BaseModel):
    """A single delivery attempt through a specific channel"""

    id: str
    """Delivery ID"""

    channel_type: Literal["in_app", "email", "sms", "chat", "web_push", "mobile_push"]
    """Type of channel used for this delivery"""

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

    notification_id: str
    """ID of the parent notification"""

    notiflow_id: str
    """ID of the notiflow"""

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

    status: Literal["pending", "sent", "failed"]
    """Delivery status:

    - `pending`: Queued for sending
    - `sent`: Successfully sent to the provider
    - `failed`: Delivery failed
    """

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

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

    archived_at: Optional[datetime] = None
    """When the recipient archived it"""

    channel_id: Optional[str] = None
    """ID of the channel used for delivery"""

    clicked_at: Optional[datetime] = None
    """When the recipient clicked/interacted"""

    data: Optional[object] = None
    """Rendered notification content (varies by channel type)"""

    notiflow_handle: Optional[str] = None
    """Handle of the notiflow"""

    read_at: Optional[datetime] = None
    """When the recipient marked it as read"""

    seen_at: Optional[datetime] = None
    """When the recipient saw the notification"""

    sent_at: Optional[datetime] = None
    """When the delivery was sent to the provider"""

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