Coverage for src/paperap/models/document/download/model.py: 100%
18 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-20 13:17 -0400
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-20 13:17 -0400
1"""
2----------------------------------------------------------------------------
4METADATA:
6File: download.py
7 Project: paperap
8Created: 2025-03-18
9 Version: 0.0.8
10Author: Jess Mann
11Email: jess@jmann.me
12 Copyright (c) 2025 Jess Mann
14----------------------------------------------------------------------------
16LAST MODIFIED:
182025-03-18 By Jess Mann
20"""
22from __future__ import annotations
24from enum import Enum
25from typing import Any, Optional
27from paperap.const import URLS
28from paperap.models.abstract import StandardModel
31class RetrieveFileMode(str, Enum):
32 """Enum for document file retrieval modes."""
34 DOWNLOAD = "download"
35 PREVIEW = "preview"
36 THUMBNAIL = "thumbnail"
39class DownloadedDocument(StandardModel):
40 """
41 Represents a downloaded Paperless-NgX document file.
43 Attributes:
44 mode: The retrieval mode (download, preview, thumbnail).
45 original: Whether to retrieve the original file.
46 content: The binary content of the file.
47 content_type: The MIME type of the file.
48 disposition_filename: The filename from the Content-Disposition header.
49 disposition_type: The type from the Content-Disposition header.
51 """
53 mode: RetrieveFileMode | None = None
54 original: bool = False
55 content: bytes | None = None
56 content_type: str | None = None
57 disposition_filename: str | None = None
58 disposition_type: str | None = None
60 class Meta(StandardModel.Meta):
61 read_only_fields = {"content", "content_type", "disposition_filename", "disposition_type"}