47 lines
1.0 KiB
Python
47 lines
1.0 KiB
Python
"""
|
|
Pydantic schemas for notifications API.
|
|
"""
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from ninja import Schema
|
|
|
|
|
|
class NotificationOut(Schema):
|
|
"""Notification output schema."""
|
|
id: int
|
|
user_id: int
|
|
type: str
|
|
title: str
|
|
content: Optional[str] = None
|
|
related_id: Optional[int] = None
|
|
related_type: Optional[str] = None
|
|
is_read: bool
|
|
created_at: datetime
|
|
|
|
|
|
class UnreadCountOut(Schema):
|
|
"""Unread count output schema."""
|
|
count: int
|
|
|
|
|
|
class NotificationPreferenceOut(Schema):
|
|
"""Notification preference output schema."""
|
|
user_id: int
|
|
enable_bounty: bool
|
|
enable_price_alert: bool
|
|
enable_system: bool
|
|
updated_at: datetime
|
|
|
|
|
|
class NotificationPreferenceIn(Schema):
|
|
"""Notification preference update schema."""
|
|
enable_bounty: Optional[bool] = None
|
|
enable_price_alert: Optional[bool] = None
|
|
enable_system: Optional[bool] = None
|
|
|
|
|
|
class MessageOut(Schema):
|
|
"""Simple message response."""
|
|
message: str
|
|
success: bool = True
|