Files
alfred/alfred/application/torrents/dto.py
2025-12-24 07:50:09 +01:00

51 lines
1.2 KiB
Python

"""Torrent application DTOs."""
from dataclasses import dataclass
from typing import Any
@dataclass
class SearchTorrentsResponse:
"""Response from searching for torrents."""
status: str
torrents: list[dict[str, Any]] | None = None
count: int | None = None
error: str | None = None
message: str | None = None
def to_dict(self):
"""Convert to dict for agent compatibility."""
result = {"status": self.status}
if self.error:
result["error"] = self.error
result["message"] = self.message
else:
if self.torrents is not None:
result["torrents"] = self.torrents
if self.count is not None:
result["count"] = self.count
return result
@dataclass
class AddTorrentResponse:
"""Response from adding a torrent."""
status: str
message: str | None = None
error: str | None = None
def to_dict(self):
"""Convert to dict for agent compatibility."""
result = {"status": self.status}
if self.error:
result["error"] = self.error
if self.message:
result["message"] = self.message
return result